25개 이상의 토픽을 선택하실 수 없습니다. 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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace coa4u
  5. {
  6. class ActionIf : ActionInterval
  7. {
  8. protected ActionInstant action;
  9. protected Predicate predicate;
  10. protected bool started;
  11. public ActionIf(Predicate targetPredicate, ActionInstant targetAction)
  12. : base(0)
  13. {
  14. action = targetAction;
  15. predicate = targetPredicate;
  16. }
  17. public override ActionInstant Clone()
  18. {
  19. return new ActionIf(predicate, action);
  20. }
  21. public override ActionInstant Reverse()
  22. {
  23. return new ActionIf(predicate, action.Reverse());
  24. }
  25. public override void Start()
  26. {
  27. base.Start();
  28. if (predicate.check())
  29. {
  30. started = true;
  31. action.SetActor(target);
  32. action.Start();
  33. duration = action.duration;
  34. }
  35. else
  36. {
  37. running = false;
  38. }
  39. }
  40. public override void StepTimer(float dt)
  41. {
  42. if (!started)
  43. return;
  44. dt *= timeScale;
  45. if (action.running)
  46. action.StepTimer(dt);
  47. if (!action.running)
  48. {
  49. Stop();
  50. dtr = action.dtr;
  51. }
  52. }
  53. public override void Stop()
  54. {
  55. base.Stop();
  56. action.Stop();
  57. }
  58. }
  59. }