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.

76 lines
1.7KB

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