Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
Dieses Repo ist archiviert. Du kannst Dateien sehen und es klonen, kannst aber nicht pushen oder Issues/Pull-Requests öffnen.

90 Zeilen
2.1KB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. class ActionSequence : ActionInterval
  5. {
  6. protected Action[] actions;
  7. protected int index;
  8. public ActionSequence(Action action1, Action action2)
  9. : base(0)
  10. {
  11. actions = new Action[] {action1, action2};
  12. }
  13. public ActionSequence(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 ActionSequence(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[actions.Length - 1 - i] = actions[i].reverse();
  33. }
  34. return new ActionSequence(aList);
  35. }
  36. public override void start()
  37. {
  38. base.start();
  39. index = 0;
  40. actions[0].setActor(target);
  41. actions[0].start();
  42. while (!actions[index].isRunning() && index < actions.Length)
  43. {
  44. index += 1;
  45. actions[index].setActor(target);
  46. actions[index].start();
  47. }
  48. }
  49. public override void step(float dt)
  50. {
  51. dt *= timeScale;
  52. float dtrdata = 0;
  53. if (actions[index].isRunning())
  54. {
  55. actions[index].step(dt);
  56. if (!actions[index].isRunning())
  57. dtrdata = actions[index].dtr;
  58. }
  59. while (!actions[index].isRunning() && index < actions.Length - 1)
  60. {
  61. index += 1;
  62. actions[index].setActor(target);
  63. actions[index].start();
  64. if (actions[index].isRunning() && dtrdata > 0)
  65. actions[index].step(dtrdata);
  66. }
  67. if (!actions[index].isRunning())
  68. {
  69. stop();
  70. dtr = dtrdata;
  71. }
  72. }
  73. public override void stop()
  74. {
  75. base.stop();
  76. for (int i = 0; i < actions.Length; i++)
  77. {
  78. actions[i].stop();
  79. }
  80. }
  81. }