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.

62 lines
1.8KB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace coa4u
  5. {
  6. /// <summary>
  7. /// Blinks the target.
  8. /// </summary>
  9. class ActionBlink : ActionRepeat
  10. {
  11. protected bool randomDelay;
  12. protected ActionDelay delay = new ActionDelay(0);
  13. protected ActionInstant[] blinkSeq;
  14. protected float durationMin;
  15. protected float durationMax;
  16. public ActionBlink(int tgtBlinks, float tgtDuration)
  17. : base(null, 0)
  18. {
  19. durationMin = tgtDuration;
  20. durationMax = tgtDuration;
  21. count = (tgtBlinks) * 2;
  22. blinkSeq = new ActionInstant[]
  23. {
  24. new ActionToggleVisibility(),
  25. new ActionDelay(tgtDuration / tgtBlinks)
  26. };
  27. action = new ActionSequence(blinkSeq);
  28. }
  29. public ActionBlink(int tgtBlinks, float tgtDurationMin, float tgtDurationMax)
  30. : base(null, 0)
  31. {
  32. durationMin = tgtDurationMin;
  33. durationMax = tgtDurationMax;
  34. count = (tgtBlinks) * 2;
  35. blinkSeq = new ActionInstant[]
  36. {
  37. new ActionToggleVisibility(),
  38. new ActionDelay(tgtDurationMin / tgtBlinks, tgtDurationMax / tgtBlinks)
  39. };
  40. action = new ActionSequence(blinkSeq);
  41. }
  42. /// <summary>
  43. /// Returns a copy of the action.
  44. /// </summary>
  45. public override ActionInstant clone()
  46. {
  47. return new ActionBlink(count / 2 - 1, durationMin, durationMax);
  48. }
  49. /// <summary>
  50. /// Returns the reversed version of the action, if it is possible.
  51. /// </summary>
  52. public override ActionInstant reverse()
  53. {
  54. return new ActionBlink(count / 2 - 1, durationMin, durationMax);
  55. }
  56. }
  57. }