Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private IStrategy currStrategy;
- private Queue<IStrategy> strategies = new Queue<IStrategy>();
- public void SetStrategy(IStrategy[] strategy)
- {
- currStrategy?.Stop();
- strategies = new Queue<IStrategy>(strategy);
- }
- public void Stop()
- {
- currStrategy?.Stop();
- strategies.Clear();
- }
- void Update()
- {
- if(strategies.Count <= 0) return;
- if (currStrategy.Execute())
- {
- currStrategy?.Stop();
- if(strategies.Count <= 0)
- {
- Stop();
- return;
- }
- currStrategy = strategies.Dequeue();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement