|
@@ -0,0 +1,358 @@
|
|
|
+using UnityEngine;
|
|
|
+using UnityEngine.UI;
|
|
|
+
|
|
|
+using System;
|
|
|
+using System.Collections;
|
|
|
+using System.Collections.Generic;
|
|
|
+using UnityEngine.Events;
|
|
|
+
|
|
|
+public struct VecPair
|
|
|
+{
|
|
|
+ public Vector3 Key;
|
|
|
+ public Vector3 Value;
|
|
|
+
|
|
|
+ public VecPair(Vector3 key, Vector3 value)
|
|
|
+ {
|
|
|
+ Key = key;
|
|
|
+ Value = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ public VecPair(float x1, float y1, float z1, float x2, float y2, float z2)
|
|
|
+ {
|
|
|
+ Key = new Vector3(x1, y1, z1);
|
|
|
+ Value = new Vector3(x2, y2, z2);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+public class StreamScale : Tween
|
|
|
+{
|
|
|
+ #region 变量
|
|
|
+
|
|
|
+ public override bool InOrigin
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ if (Consecutive)
|
|
|
+ {
|
|
|
+ if (Target.localScale.Equal(DestList[0]))
|
|
|
+ {
|
|
|
+ _InOrigin = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _InOrigin = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (Target.localScale.Equal(DestKvList[0].Key))
|
|
|
+ {
|
|
|
+ _InOrigin = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _InOrigin = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return _InOrigin;
|
|
|
+ }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ _InOrigin = value;
|
|
|
+
|
|
|
+ if (_InOrigin)
|
|
|
+ {
|
|
|
+ if (Consecutive)
|
|
|
+ {
|
|
|
+ Target.localScale = DestList[0];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Target.localScale = DestKvList[0].Key;
|
|
|
+ }
|
|
|
+
|
|
|
+ FinishBackward();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public override bool InDestination
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ if (Consecutive)
|
|
|
+ {
|
|
|
+ if (Target.localScale.Equal(DestList.Last(0)))
|
|
|
+ {
|
|
|
+ _InDestination = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _InDestination = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (Target.localScale.Equal(DestKvList.Last(0).Value))
|
|
|
+ {
|
|
|
+ _InDestination = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _InDestination = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return _InDestination;
|
|
|
+ }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ _InDestination = value;
|
|
|
+
|
|
|
+ if (_InDestination)
|
|
|
+ {
|
|
|
+ if (Consecutive)
|
|
|
+ {
|
|
|
+ Target.localScale = DestList.Last(0);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Target.localScale = DestKvList.Last(0).Value;
|
|
|
+ }
|
|
|
+
|
|
|
+ FinishForward();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public int Phase;
|
|
|
+ public int TotPhase;
|
|
|
+ public bool Consecutive;
|
|
|
+ public float TempDelay;
|
|
|
+ public float TempDuration;
|
|
|
+ public Vector3 TempDest;
|
|
|
+ public Vector3 TempDelta;
|
|
|
+ public Vector3 TempOrigin;
|
|
|
+ public List<float> DelayList = new List<float>();
|
|
|
+ public List<float> DurationList = new List<float>();
|
|
|
+ public List<VecPair> DestKvList = new List<VecPair>();
|
|
|
+ public List<Vector3> DestList = new List<Vector3>();
|
|
|
+ public List<UnityAction> ActionList = new List<UnityAction>();
|
|
|
+
|
|
|
+ public Transform Target;
|
|
|
+ public CurveFunctionV Func;
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ public StreamScale(Transform target, List<float> delayList, List<float> durationList, List<VecPair> destKvList, bool originActive, bool destActive, Curve curve, bool cg = false, List<UnityAction> actionList = null) : base(cg, curve, target)
|
|
|
+ {
|
|
|
+ Func = ManaAnim.CurveFuncDicV[curve];
|
|
|
+ Target = target;
|
|
|
+ TotPhase = destKvList.Count - 1;
|
|
|
+ Consecutive = false;
|
|
|
+
|
|
|
+ DelayList = delayList;
|
|
|
+ ActionList = actionList;
|
|
|
+ DestKvList = destKvList;
|
|
|
+ DurationList = durationList;
|
|
|
+
|
|
|
+ if (ActionList.Valid())
|
|
|
+ {
|
|
|
+ if (DestKvList.Count - ActionList.Count != -1)
|
|
|
+ {
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (DestKvList.Count - DelayList.Count != 1)
|
|
|
+ {
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (DestKvList.Count - DurationList.Count != 0)
|
|
|
+ {
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+
|
|
|
+ InForward = false;
|
|
|
+ InBackward = false;
|
|
|
+
|
|
|
+ DestActive = destActive;
|
|
|
+ OriginActive = originActive;
|
|
|
+ }
|
|
|
+
|
|
|
+ public StreamScale(Transform target, List<float> delayList, List<float> durationList, List<Vector3> destList, bool originActive, bool destActive, Curve curve, bool cg = false, List<UnityAction> actionList = null) : base(cg, curve, target)
|
|
|
+ {
|
|
|
+ Func = ManaAnim.CurveFuncDicV[curve];
|
|
|
+ Target = target;
|
|
|
+ TotPhase = destList.Count - 1;
|
|
|
+ Consecutive = true;
|
|
|
+
|
|
|
+ DestList = destList;
|
|
|
+ DelayList = delayList;
|
|
|
+ ActionList = actionList;
|
|
|
+ DurationList = durationList;
|
|
|
+
|
|
|
+ if (ActionList.Valid())
|
|
|
+ {
|
|
|
+ if ((DestList.Count - 1) - ActionList.Count != -1)
|
|
|
+ {
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (DestList.Count - DelayList.Count != 2)
|
|
|
+ {
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (DestList.Count - DurationList.Count != 1)
|
|
|
+ {
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+
|
|
|
+ InForward = false;
|
|
|
+ InBackward = false;
|
|
|
+
|
|
|
+ DestActive = destActive;
|
|
|
+ OriginActive = originActive;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public override void StartForward()
|
|
|
+ {
|
|
|
+ base.StartForward();
|
|
|
+
|
|
|
+ if (Consecutive)
|
|
|
+ {
|
|
|
+ Phase = 1;
|
|
|
+ TempDest = DestList[1];
|
|
|
+ TempDelay = DelayList[0];
|
|
|
+ TempOrigin = DestList[0];
|
|
|
+ TempDuration = DurationList[0];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Phase = 0;
|
|
|
+ TempDest = DestKvList[0].Value;
|
|
|
+ TempDelay = DelayList[0];
|
|
|
+ TempOrigin = DestKvList[0].Key;
|
|
|
+ TempDuration = DurationList[0];
|
|
|
+ }
|
|
|
+
|
|
|
+ TempDelta = TempDest - TempOrigin;
|
|
|
+
|
|
|
+ if (ActionList.Valid())
|
|
|
+ {
|
|
|
+ ActionList[0].SafeInvoke();
|
|
|
+ }
|
|
|
+
|
|
|
+ //if (InBackward)
|
|
|
+ //{
|
|
|
+ // Timer = ManaAnim.GetTimerFloat(Target.fontSize, Duration, TempOrigin, TempDelta, Curve);
|
|
|
+ //}
|
|
|
+ }
|
|
|
+
|
|
|
+ public override void StartBackward()
|
|
|
+ {
|
|
|
+ base.StartBackward();
|
|
|
+
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public override bool DoForward()
|
|
|
+ {
|
|
|
+ Timer += Time.fixedDeltaTime;
|
|
|
+
|
|
|
+ if (Phase == TotPhase)
|
|
|
+ {
|
|
|
+ if (Timer > TempDuration)
|
|
|
+ {
|
|
|
+ FinishForward();
|
|
|
+
|
|
|
+ Timer = 0;
|
|
|
+
|
|
|
+ InForward = false;
|
|
|
+ InDestination = true;
|
|
|
+
|
|
|
+ if (OnForwardFinish != null)
|
|
|
+ {
|
|
|
+ OnForwardFinish.Invoke();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ActionList.Valid())
|
|
|
+ {
|
|
|
+ ActionList.Last(0).SafeInvoke();
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Target.localScale = Func(Timer, TempDuration, TempOrigin, TempDelta);
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (Timer > TempDuration + TempDelay)
|
|
|
+ {
|
|
|
+ Timer = 0;
|
|
|
+ Phase++;
|
|
|
+
|
|
|
+ if (Consecutive)
|
|
|
+ {
|
|
|
+ TempDest = DestList[Phase];
|
|
|
+ TempOrigin = DestList[Phase - 1];
|
|
|
+ TempDuration = DurationList[Phase - 1];
|
|
|
+
|
|
|
+ TempDelta = TempDest - TempOrigin;
|
|
|
+
|
|
|
+ if (Phase != DestList.Count - 1)
|
|
|
+ {
|
|
|
+ TempDelay = DelayList[Phase - 1];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ActionList.Valid())
|
|
|
+ {
|
|
|
+ ActionList[Phase - 1].SafeInvoke();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ TempDest = DestKvList[Phase].Value;
|
|
|
+ TempOrigin = DestKvList[Phase].Key;
|
|
|
+ TempDuration = DurationList[Phase];
|
|
|
+
|
|
|
+ TempDelta = TempDest - TempOrigin;
|
|
|
+
|
|
|
+ if (Phase != DestKvList.Count - 1)
|
|
|
+ {
|
|
|
+ TempDelay = DelayList[Phase];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ActionList.Valid())
|
|
|
+ {
|
|
|
+ ActionList[Phase].SafeInvoke();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Target.localScale = Func(Timer, TempDuration, TempOrigin, TempDelta);
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public override bool DoBackward()
|
|
|
+ {
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+}
|