|
@@ -31,12 +31,11 @@ public class ManaAnim : MonoBehaviour
|
|
|
public static Dictionary<Curve, CurveFunctionV> FunctionDicV;
|
|
|
|
|
|
public static Dictionary<Transform, MoveVec> MoveVecDic;
|
|
|
- public static Dictionary<Transform, MoveScrr> MoveScrrDic;
|
|
|
-
|
|
|
public static Dictionary<Transform, TweenCG> TweenCgDic;
|
|
|
- public static Dictionary<Transform, TweenVec> TweenVecDic;
|
|
|
public static Dictionary<Transform, TweenGra> TweenGraDic;
|
|
|
+ public static Dictionary<Transform, TweenVec> TweenVecDic;
|
|
|
public static Dictionary<Transform, TweenScale> TweenScaleDic;
|
|
|
+ public static Dictionary<Transform, TweenAudio> TweenAudioDic;
|
|
|
|
|
|
#endregion
|
|
|
|
|
@@ -84,12 +83,11 @@ public class ManaAnim : MonoBehaviour
|
|
|
FunctionDicV = new Dictionary<Curve, CurveFunctionV>();
|
|
|
|
|
|
MoveVecDic = new Dictionary<Transform, MoveVec>();
|
|
|
- MoveScrrDic = new Dictionary<Transform, MoveScrr>();
|
|
|
-
|
|
|
TweenCgDic = new Dictionary<Transform, TweenCG>();
|
|
|
- TweenVecDic = new Dictionary<Transform, TweenVec>();
|
|
|
TweenGraDic = new Dictionary<Transform, TweenGra>();
|
|
|
+ TweenVecDic = new Dictionary<Transform, TweenVec>();
|
|
|
TweenScaleDic = new Dictionary<Transform, TweenScale>();
|
|
|
+ TweenAudioDic = new Dictionary<Transform, TweenAudio>();
|
|
|
|
|
|
FunctionDicF.Add(Curve.Linear, Linear);
|
|
|
FunctionDicF.Add(Curve.EaseOutQuad, EaseOutQuad);
|
|
@@ -102,11 +100,18 @@ public class ManaAnim : MonoBehaviour
|
|
|
}
|
|
|
|
|
|
|
|
|
- #region 动画函数
|
|
|
+ #region 曲线
|
|
|
|
|
|
public static float Linear(float timer, float duration, float start, float delta)
|
|
|
{
|
|
|
- return delta*timer/duration + start;
|
|
|
+ if (Math.Abs(duration) < 0.0005f)
|
|
|
+ {
|
|
|
+ return delta + start;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return delta * timer / duration + start;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static Color Linear(float timer, float duration, Color start, Color delta)
|
|
@@ -122,9 +127,16 @@ public class ManaAnim : MonoBehaviour
|
|
|
|
|
|
public static float EaseOutQuad(float timer, float duration, float start, float delta)
|
|
|
{
|
|
|
- timer /= duration;
|
|
|
+ if (Math.Abs(duration) < 0.0005f)
|
|
|
+ {
|
|
|
+ return delta + start;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ timer /= duration;
|
|
|
|
|
|
- return -delta*timer*(timer - 2) + start;
|
|
|
+ return -delta * timer * (timer - 2) + start;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static Color EaseOutQuad(float timer, float duration, Color start, Color delta)
|
|
@@ -139,7 +151,6 @@ public class ManaAnim : MonoBehaviour
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
-
|
|
|
#region 播放动画
|
|
|
|
|
|
public static void MoveVec(Transform target, Vector3 destination, float duration, Curve curve)
|
|
@@ -158,30 +169,28 @@ public class ManaAnim : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static void MoveScrr(Transform target, float destination, float duration, Curve curve)
|
|
|
+
|
|
|
+ public static void TweenForCG(Transform target)
|
|
|
{
|
|
|
- MoveScrr moveScrr;
|
|
|
+ TweenCG tweenCG;
|
|
|
|
|
|
- if (MoveScrrDic.TryGetValue(target, out moveScrr))
|
|
|
+ if (TweenCgDic.TryGetValue(target, out tweenCG))
|
|
|
{
|
|
|
- moveScrr.StartMove(destination, duration, curve);
|
|
|
+ tweenCG.StartForward();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- moveScrr = CreateMoveScrr(target);
|
|
|
-
|
|
|
- moveScrr.StartMove(destination, duration, curve);
|
|
|
+ throw new Exception();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public static void TweenForCG(Transform target)
|
|
|
+ public static void TweenForGra(Transform target)
|
|
|
{
|
|
|
- TweenCG tweenCG;
|
|
|
+ TweenGra tweenGra;
|
|
|
|
|
|
- if (TweenCgDic.TryGetValue(target, out tweenCG))
|
|
|
+ if (TweenGraDic.TryGetValue(target, out tweenGra))
|
|
|
{
|
|
|
- tweenCG.StartForward();
|
|
|
+ tweenGra.StartForward();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -203,13 +212,13 @@ public class ManaAnim : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static void TweenForGra(Transform target)
|
|
|
+ public static void TweenForScale(Transform target)
|
|
|
{
|
|
|
- TweenGra tweenGra;
|
|
|
+ TweenScale tweenScale;
|
|
|
|
|
|
- if (TweenGraDic.TryGetValue(target, out tweenGra))
|
|
|
+ if (TweenScaleDic.TryGetValue(target, out tweenScale))
|
|
|
{
|
|
|
- tweenGra.StartForward();
|
|
|
+ tweenScale.StartForward();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -217,13 +226,13 @@ public class ManaAnim : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static void TweenForScale(Transform target)
|
|
|
+ public static void TweenForAudio(Transform target)
|
|
|
{
|
|
|
- TweenScale tweenScale;
|
|
|
+ TweenAudio tween;
|
|
|
|
|
|
- if (TweenScaleDic.TryGetValue(target, out tweenScale))
|
|
|
+ if (TweenAudioDic.TryGetValue(target, out tween))
|
|
|
{
|
|
|
- tweenScale.StartForward();
|
|
|
+ tween.StartForward();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -246,13 +255,13 @@ public class ManaAnim : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static void TweenBacVec(Transform target)
|
|
|
+ public static void TweenBacGra(Transform target)
|
|
|
{
|
|
|
- TweenVec tweenVec;
|
|
|
+ TweenGra tweenGra;
|
|
|
|
|
|
- if (TweenVecDic.TryGetValue(target, out tweenVec))
|
|
|
+ if (TweenGraDic.TryGetValue(target, out tweenGra))
|
|
|
{
|
|
|
- tweenVec.StartBackward();
|
|
|
+ tweenGra.StartBackward();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -260,13 +269,13 @@ public class ManaAnim : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static void TweenBacGra(Transform target)
|
|
|
+ public static void TweenBacVec(Transform target)
|
|
|
{
|
|
|
- TweenGra tweenGra;
|
|
|
+ TweenVec tweenVec;
|
|
|
|
|
|
- if (TweenGraDic.TryGetValue(target, out tweenGra))
|
|
|
+ if (TweenVecDic.TryGetValue(target, out tweenVec))
|
|
|
{
|
|
|
- tweenGra.StartBackward();
|
|
|
+ tweenVec.StartBackward();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -288,8 +297,21 @@ public class ManaAnim : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
+ public static void TweenBacAudio(Transform target)
|
|
|
+ {
|
|
|
+ TweenAudio tween;
|
|
|
+
|
|
|
+ if (TweenAudioDic.TryGetValue(target, out tween))
|
|
|
+ {
|
|
|
+ tween.StartBackward();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new Exception();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ #endregion
|
|
|
|
|
|
#region 得到动画
|
|
|
|
|
@@ -307,13 +329,14 @@ public class ManaAnim : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static MoveScrr GetMoveScrr(Transform target)
|
|
|
+
|
|
|
+ public static TweenCG GetTweenCG(Transform target)
|
|
|
{
|
|
|
- MoveScrr moveScrr;
|
|
|
+ TweenCG tweenCG;
|
|
|
|
|
|
- if (MoveScrrDic.TryGetValue(target, out moveScrr))
|
|
|
+ if (TweenCgDic.TryGetValue(target, out tweenCG))
|
|
|
{
|
|
|
- return moveScrr;
|
|
|
+ return tweenCG;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -321,14 +344,13 @@ public class ManaAnim : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public static TweenCG GetTweenCG(Transform target)
|
|
|
+ public static TweenGra GetTweenGra(Transform target)
|
|
|
{
|
|
|
- TweenCG tweenCG;
|
|
|
+ TweenGra tweenGra;
|
|
|
|
|
|
- if (TweenCgDic.TryGetValue(target, out tweenCG))
|
|
|
+ if (TweenGraDic.TryGetValue(target, out tweenGra))
|
|
|
{
|
|
|
- return tweenCG;
|
|
|
+ return tweenGra;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -350,13 +372,13 @@ public class ManaAnim : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static TweenGra GetTweenGra(Transform target)
|
|
|
+ public static TweenScale GetTweenScale(Transform target)
|
|
|
{
|
|
|
- TweenGra tweenGra;
|
|
|
+ TweenScale tweenScale;
|
|
|
|
|
|
- if (TweenGraDic.TryGetValue(target, out tweenGra))
|
|
|
+ if (TweenScaleDic.TryGetValue(target, out tweenScale))
|
|
|
{
|
|
|
- return tweenGra;
|
|
|
+ return tweenScale;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -364,13 +386,13 @@ public class ManaAnim : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static TweenScale GetTweenScale(Transform target)
|
|
|
+ public static TweenAudio GetTweenAudio(Transform target)
|
|
|
{
|
|
|
- TweenScale tweenScale;
|
|
|
+ TweenAudio tween;
|
|
|
|
|
|
- if (TweenScaleDic.TryGetValue(target, out tweenScale))
|
|
|
+ if (TweenAudioDic.TryGetValue(target, out tween))
|
|
|
{
|
|
|
- return tweenScale;
|
|
|
+ return tween;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -380,48 +402,28 @@ public class ManaAnim : MonoBehaviour
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
-
|
|
|
#region 创建动画
|
|
|
|
|
|
public static MoveVec CreateMoveVec(Transform target)
|
|
|
{
|
|
|
if (MoveVecDic.ContainsKey(target))
|
|
|
{
|
|
|
- MoveVec moveVec = MoveVecDic[target];
|
|
|
+ MoveVec move = MoveVecDic[target];
|
|
|
|
|
|
- moveVec = new MoveVec(target);
|
|
|
+ move = new MoveVec(target);
|
|
|
|
|
|
- return moveVec;
|
|
|
+ return move;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- MoveVec moveVec = new MoveVec(target);
|
|
|
+ MoveVec move = new MoveVec(target);
|
|
|
|
|
|
- MoveVecDic.Add(target, moveVec);
|
|
|
+ MoveVecDic.Add(target, move);
|
|
|
|
|
|
- return moveVec;
|
|
|
+ return move;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static MoveScrr CreateMoveScrr(Transform target)
|
|
|
- {
|
|
|
- if (MoveScrrDic.ContainsKey(target))
|
|
|
- {
|
|
|
- MoveScrr moveScrr = MoveScrrDic[target];
|
|
|
-
|
|
|
- moveScrr = new MoveScrr(target.GetComponent<ScrollRect>());
|
|
|
-
|
|
|
- return moveScrr;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MoveScrr moveScrr = new MoveScrr(target.GetComponent<ScrollRect>());
|
|
|
-
|
|
|
- MoveScrrDic.Add(target, moveScrr);
|
|
|
-
|
|
|
- return moveScrr;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
public static TweenCG CreateTweenCG(Transform target, float origin, float destination, float duration, bool originActive, bool destActive, Curve curve)
|
|
|
{
|
|
@@ -471,6 +473,54 @@ public class ManaAnim : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static TweenGra CreateTweenGra(Transform target, Color origin, Color destination, float duration, bool originActive, bool destActive, Curve curve)
|
|
|
+ {
|
|
|
+ if (TweenGraDic.ContainsKey(target))
|
|
|
+ {
|
|
|
+ Graphic graphic = target.GetComponent<Graphic>();
|
|
|
+
|
|
|
+ TweenGra tween = TweenGraDic[target];
|
|
|
+
|
|
|
+ tween = new TweenGra(graphic, origin, destination, duration, originActive, destActive, curve);
|
|
|
+
|
|
|
+ return tween;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Graphic graphic = target.GetComponent<Graphic>();
|
|
|
+
|
|
|
+ TweenGra tween = new TweenGra(graphic, origin, destination, duration, originActive, destActive, curve);
|
|
|
+
|
|
|
+ TweenGraDic.Add(target, tween);
|
|
|
+
|
|
|
+ return tween;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static TweenGra CreateTweenGra(Transform target, Color destination, float duration, bool originActive, bool destActive, Curve curve)
|
|
|
+ {
|
|
|
+ if (TweenGraDic.ContainsKey(target))
|
|
|
+ {
|
|
|
+ Graphic graphic = target.GetComponent<Graphic>();
|
|
|
+
|
|
|
+ TweenGra tween = TweenGraDic[target];
|
|
|
+
|
|
|
+ tween = new TweenGra(graphic, graphic.color, destination, duration, originActive, destActive, curve);
|
|
|
+
|
|
|
+ return tween;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Graphic graphic = target.GetComponent<Graphic>();
|
|
|
+
|
|
|
+ TweenGra tween = new TweenGra(graphic, graphic.color, destination, duration, originActive, destActive, curve);
|
|
|
+
|
|
|
+ TweenGraDic.Add(target, tween);
|
|
|
+
|
|
|
+ return tween;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static TweenVec CreateTweenVec(Transform target, Vector3 origin, Vector3 destination, float duration, bool originActive, bool destActive, Curve curve)
|
|
|
{
|
|
|
origin.z = target.position.z;
|
|
@@ -516,89 +566,85 @@ public class ManaAnim : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static TweenGra CreateTweenGra(Transform target, Color origin, Color destination, float duration, bool originActive, bool destActive, Curve curve)
|
|
|
+ public static TweenScale CreateTweenScale(Transform target, Vector3 origin, Vector3 destination, float duration, bool originActive, bool destActive, Curve curve)
|
|
|
{
|
|
|
- if (TweenGraDic.ContainsKey(target))
|
|
|
+ if (TweenScaleDic.ContainsKey(target))
|
|
|
{
|
|
|
- Graphic graphic = target.GetComponent<Graphic>();
|
|
|
-
|
|
|
- TweenGra tween = TweenGraDic[target];
|
|
|
+ TweenScale tween = TweenScaleDic[target];
|
|
|
|
|
|
- tween = new TweenGra(graphic, origin, destination, duration, originActive, destActive, curve);
|
|
|
+ tween = new TweenScale(target, origin, destination, duration, originActive, destActive, curve);
|
|
|
|
|
|
return tween;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- Graphic graphic = target.GetComponent<Graphic>();
|
|
|
-
|
|
|
- TweenGra tween = new TweenGra(graphic, origin, destination, duration, originActive, destActive, curve);
|
|
|
+ TweenScale tween = new TweenScale(target, origin, destination, duration, originActive, destActive, curve);
|
|
|
|
|
|
- TweenGraDic.Add(target, tween);
|
|
|
+ TweenScaleDic.Add(target, tween);
|
|
|
|
|
|
return tween;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static TweenGra CreateTweenGra(Transform target, Color destination, float duration, bool originActive, bool destActive, Curve curve)
|
|
|
+ public static TweenScale CreateTweenScale(Transform target, Vector3 destination, float duration, bool originActive, bool destActive, Curve curve)
|
|
|
{
|
|
|
- if (TweenGraDic.ContainsKey(target))
|
|
|
+ if (TweenScaleDic.ContainsKey(target))
|
|
|
{
|
|
|
- Graphic graphic = target.GetComponent<Graphic>();
|
|
|
-
|
|
|
- TweenGra tween = TweenGraDic[target];
|
|
|
+ TweenScale tween = TweenScaleDic[target];
|
|
|
|
|
|
- tween = new TweenGra(graphic, graphic.color, destination, duration, originActive, destActive, curve);
|
|
|
+ tween = new TweenScale(target, target.lossyScale, destination, duration, originActive, destActive, curve);
|
|
|
|
|
|
return tween;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- Graphic graphic = target.GetComponent<Graphic>();
|
|
|
-
|
|
|
- TweenGra tween = new TweenGra(graphic, graphic.color, destination, duration, originActive, destActive, curve);
|
|
|
+ TweenScale tween = new TweenScale(target, target.lossyScale, destination, duration, originActive, destActive, curve);
|
|
|
|
|
|
- TweenGraDic.Add(target, tween);
|
|
|
+ TweenScaleDic.Add(target, tween);
|
|
|
|
|
|
return tween;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static TweenScale CreateTweenScale(Transform target, Vector3 origin, Vector3 destination, float duration, bool originActive, bool destActive, Curve curve)
|
|
|
+ public static TweenAudio CreateTweenAudio(Transform target, float origin, float destination, float duration, bool originActive, bool destActive, Curve curve)
|
|
|
{
|
|
|
- if (TweenScaleDic.ContainsKey(target))
|
|
|
+ if (TweenAudioDic.ContainsKey(target))
|
|
|
{
|
|
|
- TweenScale tween = TweenScaleDic[target];
|
|
|
+ TweenAudio tween = TweenAudioDic[target];
|
|
|
|
|
|
- tween = new TweenScale(target, origin, destination, duration, originActive, destActive, curve);
|
|
|
+ tween = new TweenAudio(target.GetComponent<AudioSource>(), origin, destination, duration, originActive, destActive, curve);
|
|
|
|
|
|
return tween;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- TweenScale tween = new TweenScale(target, origin, destination, duration, originActive, destActive, curve);
|
|
|
+ TweenAudio tween = new TweenAudio(target.GetComponent<AudioSource>(), origin, destination, duration, originActive, destActive, curve);
|
|
|
|
|
|
- TweenScaleDic.Add(target, tween);
|
|
|
+ TweenAudioDic.Add(target, tween);
|
|
|
|
|
|
return tween;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static TweenScale CreateTweenScale(Transform target, Vector3 destination, float duration, bool originActive, bool destActive, Curve curve)
|
|
|
+ public static TweenAudio CreateTweenAudio(Transform target, float destination, float duration, bool originActive, bool destActive, Curve curve)
|
|
|
{
|
|
|
- if (TweenScaleDic.ContainsKey(target))
|
|
|
+ if (TweenAudioDic.ContainsKey(target))
|
|
|
{
|
|
|
- TweenScale tween = TweenScaleDic[target];
|
|
|
+ AudioSource audio = target.GetComponent<AudioSource>();
|
|
|
|
|
|
- tween = new TweenScale(target, target.lossyScale, destination, duration, originActive, destActive, curve);
|
|
|
+ TweenAudio tween = TweenAudioDic[target];
|
|
|
+
|
|
|
+ tween = new TweenAudio(audio , audio.volume, destination, duration, originActive, destActive, curve);
|
|
|
|
|
|
return tween;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- TweenScale tween = new TweenScale(target, target.lossyScale, destination, duration, originActive, destActive, curve);
|
|
|
+ AudioSource audio = target.GetComponent<AudioSource>();
|
|
|
|
|
|
- TweenScaleDic.Add(target, tween);
|
|
|
+ TweenAudio tween = new TweenAudio(audio, audio.volume, destination, duration, originActive, destActive, curve);
|
|
|
+
|
|
|
+ TweenAudioDic.Add(target, tween);
|
|
|
|
|
|
return tween;
|
|
|
}
|