Advertisement
Guest User

Untitled

a guest
Sep 1st, 2022
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. private IStrategy currStrategy;
  2. private Queue<IStrategy> strategies;
  3.  
  4.  
  5. public void SetStrategy(IStrategy[] strategy)
  6. {
  7. currStrategy?.Stop();
  8.  
  9. strategies = new Queue<IStrategy>(strategy);
  10. }
  11.  
  12. void Update()
  13. {
  14. if (currStrategy.Execute())
  15. {
  16. currStrategy?.Stop();
  17. currStrategy = strategies.Dequeue();
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement