TweenOutline.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System;
  4. using System.Collections;
  5. public class TweenOutline : TweenRoot
  6. {
  7. #region 变量
  8. public override bool InOrigin
  9. {
  10. get
  11. {
  12. if (Target.effectColor.Equal(Origin))
  13. {
  14. InOrigin_ = true;
  15. }
  16. else
  17. {
  18. InOrigin_ = false;
  19. }
  20. return InOrigin_;
  21. }
  22. set
  23. {
  24. InOrigin_ = value;
  25. InPause = false;
  26. InForward = false;
  27. InBackward = false;
  28. if (InOrigin_)
  29. {
  30. Target.effectColor = Origin;
  31. BackwardFinish();
  32. }
  33. }
  34. }
  35. public override bool InDestination
  36. {
  37. get
  38. {
  39. if (Target.effectColor.Equal(Destination))
  40. {
  41. InDestination_ = true;
  42. }
  43. else
  44. {
  45. InDestination_ = false;
  46. }
  47. return InDestination_;
  48. }
  49. set
  50. {
  51. InDestination_ = value;
  52. InPause = false;
  53. InForward = false;
  54. InBackward = false;
  55. if (InDestination_)
  56. {
  57. Target.effectColor = Destination;
  58. ForwardFinish();
  59. }
  60. }
  61. }
  62. public Color Delta;
  63. public Color Origin;
  64. public Color Destination;
  65. public Outline Target;
  66. public CurveFunctionC Func;
  67. #endregion
  68. public TweenOutline(Outline target, Color origin, Color destination, float duration, bool originActive, bool destActive, Curve curve, bool cg = false) : base(cg, curve, target)
  69. {
  70. Func = ManaAnim.CurveFuncDicC[curve];
  71. Target = target;
  72. InForward = false;
  73. InBackward = false;
  74. Delta = destination - origin;
  75. Origin = origin;
  76. Duration = duration;
  77. DestActive = destActive;
  78. Destination = destination;
  79. OriginActive = originActive;
  80. }
  81. public override bool StartForward()
  82. {
  83. if (base.StartForward())
  84. {
  85. return true;
  86. }
  87. Target.enabled = true;
  88. if (InBackward)
  89. {
  90. InBackward = false;
  91. Timer = ManaAnim.GetTimerColor(Target.effectColor, Duration, Origin, Delta, Curve);
  92. }
  93. return false;
  94. }
  95. public override bool StartBackward()
  96. {
  97. if (base.StartBackward())
  98. {
  99. return true;
  100. }
  101. Target.enabled = true;
  102. if (InForward)
  103. {
  104. InForward = false;
  105. Timer = ManaAnim.GetTimerColor(Target.effectColor, Duration, Destination, new Color(-Delta.r, -Delta.g, -Delta.b, -Delta.a), Curve);
  106. }
  107. return false;
  108. }
  109. public override bool DoForward()
  110. {
  111. Timer += Time.fixedDeltaTime;
  112. if (Timer > Duration)
  113. {
  114. InDestination = true;
  115. if (OnForwardFinish != null)
  116. {
  117. OnForwardFinish.Invoke();
  118. }
  119. SetLoop(EventType.ForwardFinish);
  120. return true;
  121. }
  122. else
  123. {
  124. Target.effectColor = Func(Timer, Duration, Origin, Delta);
  125. return false;
  126. }
  127. }
  128. public override bool DoBackward()
  129. {
  130. Timer += Time.fixedDeltaTime;
  131. if (Timer > Duration)
  132. {
  133. InOrigin = true;
  134. if (OnBackwardFinish != null)
  135. {
  136. OnBackwardFinish.Invoke();
  137. }
  138. SetLoop(EventType.BackwardFinish);
  139. return true;
  140. }
  141. else
  142. {
  143. Target.effectColor = Func(Timer, Duration, Destination, new Color(-Delta.r, -Delta.g, -Delta.b, -Delta.a));
  144. return false;
  145. }
  146. }
  147. }