Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
Tento repozitář je archivovaný. Můžete prohlížet soubory, klonovat, ale nemůžete nahrávat a vytvářet nové úkoly a požadavky na natažení.

69 řádky
1.5KB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. class ActionRandom : ActionInterval
  5. {
  6. protected Action[] actions;
  7. protected int index;
  8. public ActionRandom(Action action1, Action action2)
  9. : base(0)
  10. {
  11. actions = new Action[] {action1, action2};
  12. }
  13. public ActionRandom(Action[] actionsList)
  14. : base(0)
  15. {
  16. actions = actionsList;
  17. }
  18. public override Action clone()
  19. {
  20. Action[] aList = new Action[actions.Length];
  21. for (int i = 0; i < actions.Length; i++)
  22. {
  23. aList[i] = actions[i].clone();
  24. }
  25. return new ActionRandom(aList);
  26. }
  27. public override Action reverse()
  28. {
  29. Action[] aList = new Action[actions.Length];
  30. for (int i = 0; i < actions.Length; i++)
  31. {
  32. aList[i] = actions[i].reverse();
  33. }
  34. return new ActionRandom(aList);
  35. }
  36. public override void start()
  37. {
  38. base.start();
  39. index = UnityEngine.Random.Range(0, actions.Length);
  40. actions[index].setActor(target);
  41. actions[index].start();
  42. }
  43. public override void step(float dt)
  44. {
  45. dt *= timeScale;
  46. if (actions[index].isRunning())
  47. actions[index].step(dt);
  48. if (!actions[index].isRunning())
  49. {
  50. stop();
  51. dtr = actions[index].dtr;
  52. }
  53. }
  54. public override void stop()
  55. {
  56. base.stop();
  57. actions[index].stop();
  58. }
  59. }