123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- using UnityEngine;
- using UnityEngine.UI;
- using System;
- using System.Collections;
- public class TweenGra : Tween
- {
- #region 变量
- public override bool InOrigin
- {
- get
- {
- if (Target.color.Equal(Origin))
- {
- _InOrigin = true;
- }
- else
- {
- _InOrigin = false;
- }
- return _InOrigin;
- }
- set
- {
- _InOrigin = value;
- if (_InOrigin)
- {
- Target.color = Origin;
- BackwardFinish();
- }
- }
- }
- public override bool InDestination
- {
- get
- {
- if (Target.color.Equal(Destination))
- {
- _InDestination = true;
- }
- else
- {
- _InDestination = false;
- }
- return _InDestination;
- }
- set
- {
- _InDestination = value;
- if (_InDestination)
- {
- Target.color = Destination;
- ForwardFinish();
- }
- }
- }
- public Color Delta;
- public Color Origin;
- public Color Destination;
- public Graphic Target;
- public CurveFunctionC Func;
-
- #endregion
- public TweenGra(Graphic target, Color origin, Color destination, float duration, bool originActive, bool destActive, Curve curve, bool cg = false) : base(cg, curve, target)
- {
- Func = ManaAnim.CurveFuncDicC[curve];
- Target = target;
- InForward = false;
- InBackward = false;
- Delta = destination - origin;
- Origin = origin;
- Duration = duration;
- DestActive = destActive;
- Destination = destination;
- OriginActive = originActive;
- }
- public override void StartForward()
- {
- base.StartForward();
- if (InBackward)
- {
- Timer = ManaAnim.GetTimerColor(Target.color, Duration, Origin, Delta, Curve);
- }
- }
- public override void StartBackward()
- {
- base.StartBackward();
- if (InForward)
- {
- Timer = ManaAnim.GetTimerColor(Target.color, Duration, Destination, new Color(-Delta.r, -Delta.g, -Delta.b, -Delta.a), Curve);
- }
- }
- public override bool DoForward()
- {
- Timer += Time.fixedDeltaTime;
- if (Timer > Duration)
- {
- InForward = false;
- InDestination = true;
- if (OnForwardFinish != null)
- {
- OnForwardFinish.Invoke();
- }
- return true;
- }
- else
- {
- Target.color = Func(Timer, Duration, Origin, Delta);
- return false;
- }
- }
- public override bool DoBackward()
- {
- Timer += Time.fixedDeltaTime;
- if (Timer > Duration)
- {
- InBackward = false;
- InOrigin = true;
- if (OnBackwardFinish != null)
- {
- OnBackwardFinish.Invoke();
- }
- return true;
- }
- else
- {
- Target.color = Func(Timer, Duration, Destination, new Color(-Delta.r, -Delta.g, -Delta.b, -Delta.a));
- return false;
- }
- }
- }
|