您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
此仓库已存档。您可以查看文件和克隆,但不能推送或创建工单/合并请求。

62 行
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. }