TweenOutline.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System;
  4. using System.Collections;
  5. public class TweenOutline : Tween
  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. if (_InOrigin)
  26. {
  27. Target.effectColor = Origin;
  28. BackwardFinish();
  29. }
  30. }
  31. }
  32. public override bool InDestination
  33. {
  34. get
  35. {
  36. if (Target.effectColor.Equal(Destination))
  37. {
  38. _InDestination = true;
  39. }
  40. else
  41. {
  42. _InDestination = false;
  43. }
  44. return _InDestination;
  45. }
  46. set
  47. {
  48. _InDestination = value;
  49. if (_InDestination)
  50. {
  51. Target.effectColor = Destination;
  52. ForwardFinish();
  53. }
  54. }
  55. }
  56. public Color Delta;
  57. public Color Origin;
  58. public Color Destination;
  59. public Outline Target;
  60. public CurveFunctionC Func;
  61. #endregion
  62. public TweenOutline(Outline target, Color origin, Color destination, float duration, bool originActive, bool destActive, Curve curve, bool cg = false) : base(cg, curve, target)
  63. {
  64. Func = ManaAnim.CurveFuncDicC[curve];
  65. Target = target;
  66. InForward = false;
  67. InBackward = false;
  68. Delta = destination - origin;
  69. Origin = origin;
  70. Duration = duration;
  71. DestActive = destActive;
  72. Destination = destination;
  73. OriginActive = originActive;
  74. }
  75. public override void StartForward()
  76. {
  77. base.StartForward();
  78. Target.enabled = true;
  79. if (InBackward)
  80. {
  81. Timer = ManaAnim.GetTimerColor(Target.effectColor, Duration, Origin, Delta, Curve);
  82. }
  83. }
  84. public override void StartBackward()
  85. {
  86. base.StartBackward();
  87. Target.enabled = true;
  88. if (InForward)
  89. {
  90. Timer = ManaAnim.GetTimerColor(Target.effectColor, Duration, Destination, new Color(-Delta.r, -Delta.g, -Delta.b, -Delta.a), Curve);
  91. }
  92. }
  93. public override bool DoForward()
  94. {
  95. Timer += Time.fixedDeltaTime;
  96. if (Timer > Duration)
  97. {
  98. InForward = false;
  99. InDestination = true;
  100. if (OnForwardFinish != null)
  101. {
  102. OnForwardFinish.Invoke();
  103. }
  104. return true;
  105. }
  106. else
  107. {
  108. Target.effectColor = Func(Timer, Duration, Origin, Delta);
  109. return false;
  110. }
  111. }
  112. public override bool DoBackward()
  113. {
  114. Timer += Time.fixedDeltaTime;
  115. if (Timer > Duration)
  116. {
  117. InBackward = false;
  118. InOrigin = true;
  119. if (OnBackwardFinish != null)
  120. {
  121. OnBackwardFinish.Invoke();
  122. }
  123. return true;
  124. }
  125. else
  126. {
  127. Target.effectColor = Func(Timer, Duration, Destination, new Color(-Delta.r, -Delta.g, -Delta.b, -Delta.a));
  128. return false;
  129. }
  130. }
  131. }