No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
Este repositorio está archivado. Puede ver los archivos y clonarlo, pero no puede subir cambios o reportar incidencias ni pedir Pull Requests.

54 líneas
1.2KB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace coa4u
  5. {
  6. /// <summary>
  7. /// Plays the action on another actor;
  8. /// </summary>
  9. class ActionPlayer : ActionInterval
  10. {
  11. protected ActionInstant action;
  12. protected Actor actor;
  13. public ActionPlayer(ActionInstant targetAction, Actor targetActor)
  14. : base(0)
  15. {
  16. action = targetAction;
  17. actor = targetActor;
  18. }
  19. public override ActionInstant Clone()
  20. {
  21. return new ActionPlayer(action, actor);
  22. }
  23. public override void Start()
  24. {
  25. base.Start();
  26. actor.AttachAction(action);
  27. if (!action.running)
  28. running = false;
  29. }
  30. public override void StepTimer(float dt)
  31. {
  32. if (target == null)
  33. throw new Exception("Can update the action only after it's atached to the actor");
  34. action.StepTimer(dt);
  35. if (!action.running)
  36. {
  37. dtr = action.dtr;
  38. Stop();
  39. }
  40. }
  41. public override void Step(float dt)
  42. {
  43. if (!action.running)
  44. running = false;
  45. }
  46. }
  47. }