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.

48 lines
853B

  1. using UnityEngine;
  2. using System.Collections;
  3. public class Actor : MonoBehaviour
  4. {
  5. protected Action action;
  6. private bool paused = false;
  7. protected void Update()
  8. {
  9. if (paused || action == null)
  10. return;
  11. if (action.isRunning())
  12. action.step(Time.deltaTime);
  13. }
  14. public void AttachAction(Action tgtAction)
  15. {
  16. action = tgtAction;
  17. action.setActor(this);
  18. action.start();
  19. }
  20. public void StopAction()
  21. {
  22. action.stop();
  23. action = null;
  24. }
  25. public void PauseAction()
  26. {
  27. paused = true;
  28. }
  29. public void UnpauseAction()
  30. {
  31. paused = false;
  32. }
  33. public void SetTimeScale(float ts)
  34. {
  35. if (action is ActionInterval)
  36. {
  37. ((ActionInterval)action).setTimeScale(ts);
  38. }
  39. }
  40. }