You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

80 lines
1.8KB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Action
  5. {
  6. protected Actor target;
  7. public float duration = 0;
  8. protected Transform transform;
  9. protected Renderer renderer;
  10. public Action()
  11. {
  12. }
  13. public virtual Action clone()
  14. {
  15. return new Action();
  16. }
  17. public virtual bool isRunning()
  18. {
  19. return false;
  20. }
  21. /// <summary>
  22. /// This method is called at the action start. Usable for instant and interval actions.
  23. /// </summary>
  24. public virtual Action reverse()
  25. {
  26. throw new Exception("Can reverse only the reversable interval actions");
  27. }
  28. /// <summary>
  29. /// This method is called at the action start. Usable for instant and interval actions.
  30. /// </summary>
  31. public virtual void start()
  32. {
  33. if (target == null)
  34. throw new Exception("Can start the action only after it's atached to the actor");
  35. transform = target.gameObject.transform;
  36. renderer = target.gameObject.renderer;
  37. }
  38. /// <summary>
  39. /// This method is called at every frame update. Not usable for instant actions.
  40. /// </summary>
  41. public virtual void step(float dt)
  42. {
  43. if (target == null)
  44. throw new Exception("Can update the action only after it's atached to the actor");
  45. }
  46. /// <summary>
  47. /// This method is called after the interval action is stopped. Not usable for instant actions.
  48. /// </summary>
  49. public virtual void stop()
  50. {
  51. if (target == null)
  52. throw new Exception("Can stop the action only after it's atached to the actor");
  53. }
  54. public void setActor(Actor actor)
  55. {
  56. target = actor;
  57. }
  58. public virtual float dtr
  59. {
  60. get
  61. {
  62. return 0;
  63. }
  64. protected set
  65. {
  66. }
  67. }
  68. }