Browse Source

Update 4.4 21:58

LiuQilin 8 years ago
parent
commit
6253406f6e

BIN
.vs/MyLovelyGarden/v14/.suo


BIN
Assets/Resource/Animations/UIFlashLight.anim


+ 8 - 0
Assets/Resource/Animations/UIFlashLight.anim.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: fb372b7e1f7d8e8418dfbd552cfebde5
+timeCreated: 1491269124
+licenseType: Pro
+NativeFormatImporter:
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 325 - 36
Assets/Script/Manage/ManaAnim.cs

@@ -12,6 +12,13 @@ public enum Curve
     EaseOutQuad,
 }
 
+public delegate float ShakeFunctionF(float timer, float duration, int repeat, float start, float strength);
+
+public delegate Color ShakeFunctionC(float timer, float duration, int repeat, Color start, Color strength);
+
+public delegate Vector3 ShakeFunctionV(float timer, float duration, int repeat, Vector3 start, Vector3 strength);
+
+
 public delegate float CurveFunctionF(float timer, float duration, float start, float delta);
 
 public delegate Color CurveFunctionC(float timer, float duration, Color start, Color delta);
@@ -22,15 +29,19 @@ public class ManaAnim : Regist
 {
     #region 变量
 
-    public static List<Move> MoveList;
+    public static List<Anim> AnimList;
     public static List<Tween> TweenForList;
     public static List<Tween> TweenBacList;
 
-    public static Dictionary<Curve, CurveFunctionF> FunctionDicF;
-    public static Dictionary<Curve, CurveFunctionC> FunctionDicC;
-    public static Dictionary<Curve, CurveFunctionV> FunctionDicV;
+    public static Dictionary<Curve, ShakeFunctionF> ShakeFunctionDicF;
+    public static Dictionary<Curve, ShakeFunctionC> ShakeFunctionDicC;
+    public static Dictionary<Curve, ShakeFunctionV> ShakeFunctionDicV;
+    public static Dictionary<Curve, CurveFunctionF> CurveFunctionDicF;
+    public static Dictionary<Curve, CurveFunctionC> CurveFunctionDicC;
+    public static Dictionary<Curve, CurveFunctionV> CurveFunctionDicV;
     
-    public static Dictionary<Transform, MoveVec> MoveVecDic;
+    public static Dictionary<Transform, Move> MoveDic;
+    public static Dictionary<Transform, Shake> ShakeDic;
     public static Dictionary<Transform, TweenSr> TweenSrDic;
     public static Dictionary<Transform, TweenCG> TweenCgDic;
     public static Dictionary<Transform, TweenGra> TweenGraDic;
@@ -44,9 +55,9 @@ public class ManaAnim : Regist
 
     private void FixedUpdate()
     {
-        for (int i = 0; i < MoveList.Count; i++)
+        for (int i = 0; i < AnimList.Count; i++)
         {
-            if (MoveList[i].DoMove())
+            if (AnimList[i].Do())
             {
                 i--;
             }
@@ -72,15 +83,19 @@ public class ManaAnim : Regist
 
     public override void RegistValueA()
     {
-        MoveList = new List<Move>();
+        AnimList = new List<Anim>();
         TweenForList = new List<Tween>();
         TweenBacList = new List<Tween>();
 
-        FunctionDicF = new Dictionary<Curve, CurveFunctionF>();
-        FunctionDicC = new Dictionary<Curve, CurveFunctionC>();
-        FunctionDicV = new Dictionary<Curve, CurveFunctionV>();
+        CurveFunctionDicF = new Dictionary<Curve, CurveFunctionF>();
+        CurveFunctionDicC = new Dictionary<Curve, CurveFunctionC>();
+        CurveFunctionDicV = new Dictionary<Curve, CurveFunctionV>();
+        ShakeFunctionDicF = new Dictionary<Curve, ShakeFunctionF>();
+        ShakeFunctionDicC = new Dictionary<Curve, ShakeFunctionC>();
+        ShakeFunctionDicV = new Dictionary<Curve, ShakeFunctionV>();
 
-        MoveVecDic = new Dictionary<Transform, MoveVec>();
+        MoveDic = new Dictionary<Transform, Move>();
+        ShakeDic = new Dictionary<Transform, Shake>();
         TweenSrDic = new Dictionary<Transform, TweenSr>();
         TweenCgDic = new Dictionary<Transform, TweenCG>();
         TweenGraDic = new Dictionary<Transform, TweenGra>();
@@ -90,19 +105,245 @@ public class ManaAnim : Regist
         TweenScaleDic = new Dictionary<Transform, TweenScale>();
         TweenAudioDic = new Dictionary<Transform, TweenAudio>();
 
-        FunctionDicF.Add(Curve.Linear, Linear);
-        FunctionDicF.Add(Curve.EaseOutQuad, EaseOutQuad);
+        ShakeFunctionDicF.Add(Curve.Linear, ShakeLinear);
+        ShakeFunctionDicF.Add(Curve.EaseOutQuad, ShakeEaseOutQuad);
+
+        ShakeFunctionDicC.Add(Curve.Linear, ShakeLinear);
+        ShakeFunctionDicC.Add(Curve.EaseOutQuad, ShakeEaseOutQuad);
+
+        ShakeFunctionDicV.Add(Curve.Linear, ShakeLinear);
+        ShakeFunctionDicV.Add(Curve.EaseOutQuad, ShakeEaseOutQuad);
 
-        FunctionDicC.Add(Curve.Linear, Linear);
-        FunctionDicC.Add(Curve.EaseOutQuad, EaseOutQuad);
+        CurveFunctionDicF.Add(Curve.Linear, Linear);
+        CurveFunctionDicF.Add(Curve.EaseOutQuad, EaseOutQuad);
 
-        FunctionDicV.Add(Curve.Linear, Linear);
-        FunctionDicV.Add(Curve.EaseOutQuad, EaseOutQuad);
+        CurveFunctionDicC.Add(Curve.Linear, Linear);
+        CurveFunctionDicC.Add(Curve.EaseOutQuad, EaseOutQuad);
+
+        CurveFunctionDicV.Add(Curve.Linear, Linear);
+        CurveFunctionDicV.Add(Curve.EaseOutQuad, EaseOutQuad);
     }
 
 
     #region 曲线
 
+    public static float LinearTimer(float value, float duration, float start, float delta)
+    {
+        return (value - start) * duration / delta;
+    }
+
+    public static float EaseOutQuadTimer(float value, float duration, float start, float delta)
+    {
+        return ((2 - Mathf.Sqrt(4 - 4*(value - start)/delta))/2)*duration;
+    }
+
+
+    public static float ShakeLinear(float timer, float duration, int repeat, float start, float strength)
+    {
+        float sliceTime = duration/(4*repeat);
+
+        for (int i = 0; i < repeat*4; i += 4)
+        {
+            if (timer > duration)
+            {
+                return start;
+            }
+
+            if (timer <= (i + 1) * sliceTime)
+            {
+                timer -= (i)*sliceTime;
+
+                return Linear(timer, sliceTime, start, strength/(i/4 + 1));
+            }
+            else if (timer <= (i + 3)*sliceTime)
+            {
+                timer -= (i + 1)*sliceTime;
+
+                return Linear(timer, 2*sliceTime, start + strength/(i/4 + 1), -2*strength/(i/4 + 1));
+            }
+            else if (timer <= (i + 4)*sliceTime)
+            {
+                timer -= (i + 3)*sliceTime;
+
+                return Linear(timer, sliceTime, start - strength/(i/4 + 1), strength/(i/4 + 1));
+            }
+        }
+
+        throw new Exception();
+    }
+
+    public static Color ShakeLinear(float timer, float duration, int repeat, Color start, Color strength)
+    {
+        float sliceTime = duration / (4 * repeat);
+
+        for (int i = 0; i < repeat * 4; i += 4)
+        {
+            if (timer > duration)
+            {
+                return start;
+            }
+
+            if (timer <= (i + 1) * sliceTime)
+            {
+                timer -= (i) * sliceTime;
+
+                return Linear(timer, sliceTime, start, strength / (i / 4 + 1));
+            }
+            else if (timer <= (i + 3) * sliceTime)
+            {
+                timer -= (i + 1) * sliceTime;
+
+                return Linear(timer, 2 * sliceTime, start + strength / (i / 4 + 1), -2 * strength / (i / 4 + 1));
+            }
+            else if (timer <= (i + 4) * sliceTime)
+            {
+                timer -= (i + 3) * sliceTime;
+
+                return Linear(timer, sliceTime, start - strength / (i / 4 + 1), strength / (i / 4 + 1));
+            }
+        }
+
+        throw new Exception();
+    }
+
+    public static Vector3 ShakeLinear(float timer, float duration, int repeat, Vector3 start, Vector3 strength)
+    {
+        float sliceTime = duration / (4 * repeat);
+
+        for (int i = 0; i < repeat * 4; i += 4)
+        {
+            if (timer > duration)
+            {
+                return start;
+            }
+
+            if (timer <= (i + 1) * sliceTime)
+            {
+                timer -= (i) * sliceTime;
+
+                return Linear(timer, sliceTime, start, strength / (i / 4 + 1));
+            }
+            else if (timer <= (i + 3) * sliceTime)
+            {
+                timer -= (i + 1) * sliceTime;
+
+                return Linear(timer, 2 * sliceTime, start + strength / (i / 4 + 1), -2 * strength / (i / 4 + 1));
+            }
+            else if (timer <= (i + 4) * sliceTime)
+            {
+                timer -= (i + 3) * sliceTime;
+
+                return Linear(timer, sliceTime, start - strength / (i / 4 + 1), strength / (i / 4 + 1));
+            }
+        }
+
+        throw new Exception();
+    }
+
+
+    public static float ShakeEaseOutQuad(float timer, float duration, int repeat, float start, float strength)
+    {
+        float sliceTime = duration / (4 * repeat);
+
+        for (int i = 0; i < repeat * 4; i += 4)
+        {
+            if (timer > duration)
+            {
+                return start;
+            }
+
+            if (timer <= (i + 1) * sliceTime)
+            {
+                timer -= (i) * sliceTime;
+
+                return EaseOutQuad(timer, sliceTime, start, strength / (i / 4 + 1));
+            }
+            else if (timer <= (i + 3) * sliceTime)
+            {
+                timer -= (i + 1) * sliceTime;
+
+                return EaseOutQuad(timer, 2 * sliceTime, start + strength / (i / 4 + 1), -2 * strength / (i / 4 + 1));
+            }
+            else if (timer <= (i + 4) * sliceTime)
+            {
+                timer -= (i + 3) * sliceTime;
+
+                return EaseOutQuad(timer, sliceTime, start - strength / (i / 4 + 1), strength / (i / 4 + 1));
+            }
+        }
+
+        throw new Exception();
+    }
+
+    public static Color ShakeEaseOutQuad(float timer, float duration, int repeat, Color start, Color strength)
+    {
+        float sliceTime = duration / (4 * repeat);
+
+        for (int i = 0; i < repeat * 4; i += 4)
+        {
+            if (timer > duration)
+            {
+                return start;
+            }
+
+            if (timer <= (i + 1) * sliceTime)
+            {
+                timer -= (i) * sliceTime;
+
+                return EaseOutQuad(timer, sliceTime, start, strength / (i / 4 + 1));
+            }
+            else if (timer <= (i + 3) * sliceTime)
+            {
+                timer -= (i + 1) * sliceTime;
+
+                return EaseOutQuad(timer, 2 * sliceTime, start + strength / (i / 4 + 1), -2 * strength / (i / 4 + 1));
+            }
+            else if (timer <= (i + 4) * sliceTime)
+            {
+                timer -= (i + 3) * sliceTime;
+
+                return EaseOutQuad(timer, sliceTime, start - strength / (i / 4 + 1), strength / (i / 4 + 1));
+            }
+        }
+
+        throw new Exception();
+    }
+
+    public static Vector3 ShakeEaseOutQuad(float timer, float duration, int repeat, Vector3 start, Vector3 strength)
+    {
+        float sliceTime = duration / (4 * repeat);
+
+        for (int i = 0; i < repeat * 4; i += 4)
+        {
+            if (timer > duration)
+            {
+                return start;
+            }
+
+            if (timer <= (i + 1) * sliceTime)
+            {
+                timer -= (i) * sliceTime;
+
+                return EaseOutQuad(timer, sliceTime, start, strength / (i / 4 + 1));
+            }
+            else if (timer <= (i + 3) * sliceTime)
+            {
+                timer -= (i + 1) * sliceTime;
+
+                return EaseOutQuad(timer, 2 * sliceTime, start + strength / (i / 4 + 1), -2 * strength / (i / 4 + 1));
+            }
+            else if (timer <= (i + 4) * sliceTime)
+            {
+                timer -= (i + 3) * sliceTime;
+
+                return EaseOutQuad(timer, sliceTime, start - strength / (i / 4 + 1), strength / (i / 4 + 1));
+            }
+        }
+
+        throw new Exception();
+    }
+
+
     public static float Linear(float timer, float duration, float start, float delta)
     {
         if (Math.Abs(duration) < 0.0005f)
@@ -154,19 +395,35 @@ public class ManaAnim : Regist
 
     #region 播放动画
 
-    public static void MoveVec(Transform target, Vector3 destination, float duration, Curve curve)
+    public static void Move(Transform target, Vector3 destination, float duration, Curve curve)
     {
-        MoveVec moveVec;
+        Move move;
 
-        if (MoveVecDic.TryGetValue(target, out moveVec))
+        if (MoveDic.TryGetValue(target, out move))
         {
-            moveVec.StartMove(destination, duration, curve);
+            move.StartMove(destination, duration, curve);
         }
         else
         {
-            moveVec = CreateMoveVec(target);
+            move = CreateMove(target);
 
-            moveVec.StartMove(destination, duration, curve);
+            move.StartMove(destination, duration, curve);
+        }
+    }
+
+    public static void Shake(Transform target, float duration, int repeat, Vector3 strength, Curve curve)
+    {
+        Shake shake;
+
+        if (ShakeDic.TryGetValue(target, out shake))
+        {
+            shake.StartShake(repeat, duration, strength, curve);
+        }
+        else
+        {
+            shake = CreateShake(target);
+
+            shake.StartShake(repeat, duration, strength, curve);
         }
     }
 
@@ -626,13 +883,27 @@ public class ManaAnim : Regist
 
     #region 得到动画
 
-    public static MoveVec GetMoveVec(Transform target)
+    public static Move GetMove(Transform target)
     {
-        MoveVec moveVec;
+        Move move;
 
-        if (MoveVecDic.TryGetValue(target, out moveVec))
+        if (MoveDic.TryGetValue(target, out move))
         {
-            return moveVec;
+            return move;
+        }
+        else
+        {
+            throw new Exception();
+        }
+    }
+
+    public static Shake GetShake(Transform target)
+    {
+        Shake shake;
+
+        if (ShakeDic.TryGetValue(target, out shake))
+        {
+            return shake;
         }
         else
         {
@@ -655,7 +926,6 @@ public class ManaAnim : Regist
         }
     }
 
-
     public static TweenCG GetTweenCG(Transform target)
     {
         TweenCG tweenCG;
@@ -758,26 +1028,46 @@ public class ManaAnim : Regist
 
     #region 创建动画
 
-    public static MoveVec CreateMoveVec(Transform target)
+    public static Move CreateMove(Transform target)
     {
-        if (MoveVecDic.ContainsKey(target))
+        if (MoveDic.ContainsKey(target))
         {
-            MoveVec move = MoveVecDic[target];
+            Move move = MoveDic[target];
 
-            move = new MoveVec(target);
+            move = new Move(target);
 
             return move;
         }
         else
         {
-            MoveVec move = new MoveVec(target);
+            Move move = new Move(target);
 
-            MoveVecDic.Add(target, move);
+            MoveDic.Add(target, move);
 
             return move;
         }
     }
 
+    public static Shake CreateShake(Transform target)
+    {
+        if (ShakeDic.ContainsKey(target))
+        {
+            Shake shake = ShakeDic[target];
+
+            shake = new Shake(target);
+
+            return shake;
+        }
+        else
+        {
+            Shake shake = new Shake(target);
+
+            ShakeDic.Add(target, shake);
+
+            return shake;
+        }
+    }
+
 
     public static TweenSr CreateTweenSr(Transform target, Color origin, Color destination, float duration, bool originActive, bool destActive, Curve curve)
     {
@@ -827,7 +1117,6 @@ public class ManaAnim : Regist
         }
     }
 
-
     public static TweenCG CreateTweenCG(Transform target, float origin, float destination,  float duration, bool originActive, bool destActive, Curve curve)
     {
         if (TweenCgDic.ContainsKey(target))

+ 8 - 8
Assets/Script/Manage/ManaAudio.cs

@@ -11,17 +11,17 @@ public class ManaAudio : Regist
     public static Transform AudioParent;
     public static Transform MusicParent;
 
-    public Coroutine CoroTheme;
-    public Coroutine CoroMiniGame;
-    public AudioSource MusicMini;
-    public AudioSource MusicTheme;
+    public static Coroutine CoroTheme;
+    public static Coroutine CoroMiniGame;
+    public static AudioSource MusicMini;
+    public static AudioSource MusicTheme;
 
     #endregion
 
     public override void Instantiate()
     {
         MusicParent = new GameObject("Music").transform;
-
+        
         ManaReso.Get("MusicMini", Folder.Object, true, MusicParent, true);
         ManaReso.Get("MusicTheme", Folder.Object, true, MusicParent, true);
     }
@@ -88,7 +88,7 @@ public class ManaAudio : Regist
 
             ManaReso.SetActive("L_MusicOn", false);
             ManaReso.SetActive("L_MusicOff", true);
-
+            
             MusicParent.SetActive(false);
         }
         else
@@ -129,9 +129,9 @@ public class ManaAudio : Regist
             {
                 yield return null;
             }
-            
+
             yield return new WaitForSeconds(3);
-            
+
             audioSource.Play();
         }
     }

+ 2 - 33
Assets/Script/Object/Flower.cs

@@ -337,38 +337,7 @@ public class Flower : ObjRoot, IPointerClickHandler
             FlowerIcon.TweenForSr();
             OperateIcon.TweenForSr();
 
-            MoveVec move = OperateIcon.CreateMoveVec();
-
-            move.StartMove(OperateIcon.transform.position + new Vector3(0.2f, 0), 0.1f, Curve.Linear);
-            move.OnFinish = () =>
-            {
-                move.StartMove(OperateIcon.transform.position + new Vector3(-0.4f, 0), 0.1f, Curve.Linear);
-
-                move.OnFinish = () =>
-                {
-                    move.StartMove(OperateIcon.transform.position + new Vector3(0.2f, 0), 0.1f, Curve.Linear);
-
-                    move.OnFinish = () =>
-                    {
-                        move.StartMove(OperateIcon.transform.position + new Vector3(0.1f, 0), 0.1f, Curve.Linear);
-
-                        move.OnFinish = () =>
-                        {
-                            move.StartMove(OperateIcon.transform.position + new Vector3(-0.2f, 0), 0.1f, Curve.Linear);
-
-                            move.OnFinish = () =>
-                            {
-                                move.StartMove(OperateIcon.transform.position + new Vector3(0.1f, 0), 0.1f, Curve.Linear);
-
-                                move.OnFinish = () =>
-                                {
-
-                                };
-                            };
-                        };
-                    };
-                };
-            };
+            OperateIcon.Shake(1, 3, new Vector3(0.2f, 0, 0), Curve.EaseOutQuad);
 
             return false;
         }
@@ -418,7 +387,7 @@ public class Flower : ObjRoot, IPointerClickHandler
         GoldBk.TweenForSr();
         GoldIcon.TweenForSr();
 
-        GoldBk.MoveVec
+        GoldBk.Move
         (
             GoldBk.transform.position + new Vector3(0, 0.5f, 0),
             1f,

+ 38 - 30
Assets/Script/Object/Garden.cs

@@ -105,14 +105,14 @@ public class Garden : Regist, IDragHandler, IPointerClickHandler, IEndDragHandle
 
         #region GardenA
 
-        MoveVec moveVec = GardenA.CreateMoveVec();
+        Move move = GardenA.CreateMove();
 
-        moveVec.OnStart += () =>
+        move.OnStart += () =>
         {
             Flag2 = false;
         };
 
-        moveVec.OnFinish += () =>
+        move.OnFinish += () =>
         {
             Flag2 = true;
         };
@@ -266,16 +266,20 @@ public class Garden : Regist, IDragHandler, IPointerClickHandler, IEndDragHandle
                     }
                     else
                     {
-                        float tempX = Mathf.Clamp(eventData.delta.x / 10, -2, 2) * SlideSpeed;
+                        float ratio = Mathf.Abs(GardenA.position.x - GardenPosA[ValidPage - 1].x)/0.7f;
+
+                        float speed = Mathf.Lerp(SlideSpeed, 0, ratio);
+
+                        float tempX = Mathf.Clamp(eventData.delta.x / 10, -2, 2) * speed;
 
                         GardenA.Translate(GardenA.right * tempX, Space.World);
 
-                        if (GardenA.position.x - GardenPosA[ValidPage - 1].x < -0.7f)
-                        {
-                            GardenA.SetX(GardenPosA[ValidPage - 1].x - 0.7f);
+                        //if (GardenA.position.x - GardenPosA[ValidPage - 1].x < -0.7f)
+                        //{
+                        //    GardenA.SetX(GardenPosA[ValidPage - 1].x - 0.7f);
 
-                            Return();
-                        }
+                        //    Return();
+                        //}
                     }
 
                     #endregion
@@ -311,16 +315,20 @@ public class Garden : Regist, IDragHandler, IPointerClickHandler, IEndDragHandle
                     }
                     else
                     {
-                        float tempX = Mathf.Clamp(eventData.delta.x / 10, -2, 2) * SlideSpeed;
+                        float ratio = Mathf.Abs(GardenA.position.x - GardenPosA[0].x) / 0.7f;
+
+                        float speed = Mathf.Lerp(SlideSpeed, 0, ratio);
+
+                        float tempX = Mathf.Clamp(eventData.delta.x / 10, -2, 2) * speed;
 
                         GardenA.Translate(GardenA.right * tempX, Space.World);
 
-                        if (GardenA.position.x - GardenPosA[0].x > 0.7f)
-                        {
-                            GardenA.SetX(GardenPosA[0].x + 0.7f);
+                        //if (GardenA.position.x - GardenPosA[0].x > 0.7f)
+                        //{
+                        //    GardenA.SetX(GardenPosA[0].x + 0.7f);
 
-                            Return();
-                        }
+                        //    Return();
+                        //}
                     }
 
                     #endregion
@@ -409,11 +417,11 @@ public class Garden : Regist, IDragHandler, IPointerClickHandler, IEndDragHandle
     {
         Flag1 = false;
 
-        Player.MoveVec(PlayerPos[Page], 0.25f, Curve.EaseOutQuad);
-        GardenA.MoveVec(GardenPosA[Page], 0.25f, Curve.EaseOutQuad);
-        GardenBk2.MoveVec(GardenPosBk2[Page], 0.25f, Curve.EaseOutQuad);
-        GardenBk3.MoveVec(GardenPosBk3[Page], 0.25f, Curve.EaseOutQuad);
-        GardenBk4.MoveVec(GardenPosBk4[Page], 0.25f, Curve.EaseOutQuad);
+        Player.Move(PlayerPos[Page], 0.25f, Curve.EaseOutQuad);
+        GardenA.Move(GardenPosA[Page], 0.25f, Curve.EaseOutQuad);
+        GardenBk2.Move(GardenPosBk2[Page], 0.25f, Curve.EaseOutQuad);
+        GardenBk3.Move(GardenPosBk3[Page], 0.25f, Curve.EaseOutQuad);
+        GardenBk4.Move(GardenPosBk4[Page], 0.25f, Curve.EaseOutQuad);
     }
 
     private void PrevPage()
@@ -422,11 +430,11 @@ public class Garden : Regist, IDragHandler, IPointerClickHandler, IEndDragHandle
         
         Flag1 = false;
 
-        Player.MoveVec(PlayerPos[Page], 0.5f, Curve.EaseOutQuad);
-        GardenA.MoveVec(GardenPosA[Page], 0.5f, Curve.EaseOutQuad);
-        GardenBk2.MoveVec(GardenPosBk2[Page], 0.5f, Curve.EaseOutQuad);
-        GardenBk3.MoveVec(GardenPosBk3[Page], 0.5f, Curve.EaseOutQuad);
-        GardenBk4.MoveVec(GardenPosBk4[Page], 0.5f, Curve.EaseOutQuad);
+        Player.Move(PlayerPos[Page], 0.5f, Curve.EaseOutQuad);
+        GardenA.Move(GardenPosA[Page], 0.5f, Curve.EaseOutQuad);
+        GardenBk2.Move(GardenPosBk2[Page], 0.5f, Curve.EaseOutQuad);
+        GardenBk3.Move(GardenPosBk3[Page], 0.5f, Curve.EaseOutQuad);
+        GardenBk4.Move(GardenPosBk4[Page], 0.5f, Curve.EaseOutQuad);
     }
 
     private void NextPage()
@@ -435,10 +443,10 @@ public class Garden : Regist, IDragHandler, IPointerClickHandler, IEndDragHandle
         
         Flag1 = false;
 
-        Player.MoveVec(PlayerPos[Page], 0.5f, Curve.EaseOutQuad);
-        GardenA.MoveVec(GardenPosA[Page], 0.5f, Curve.EaseOutQuad);
-        GardenBk2.MoveVec(GardenPosBk2[Page], 0.5f, Curve.EaseOutQuad);
-        GardenBk3.MoveVec(GardenPosBk3[Page], 0.5f, Curve.EaseOutQuad);
-        GardenBk4.MoveVec(GardenPosBk4[Page], 0.5f, Curve.EaseOutQuad);
+        Player.Move(PlayerPos[Page], 0.5f, Curve.EaseOutQuad);
+        GardenA.Move(GardenPosA[Page], 0.5f, Curve.EaseOutQuad);
+        GardenBk2.Move(GardenPosBk2[Page], 0.5f, Curve.EaseOutQuad);
+        GardenBk3.Move(GardenPosBk3[Page], 0.5f, Curve.EaseOutQuad);
+        GardenBk4.Move(GardenPosBk4[Page], 0.5f, Curve.EaseOutQuad);
     }
 }

+ 24 - 0
Assets/Script/Tool/Anim/Anim.cs

@@ -0,0 +1,24 @@
+using UnityEngine;
+
+using System.Collections;
+using UnityEngine.Events;
+
+public abstract class Anim 
+{
+    #region 变量
+
+    protected virtual bool InDestination
+    {
+        get { return _InDestination; }
+        set { _InDestination = value; }
+    }
+
+    protected bool _InDestination;
+
+    public UnityAction OnStart;
+    public UnityAction OnFinish;
+
+    #endregion
+
+    public abstract bool Do();
+}

+ 2 - 2
Assets/Script/Tool/Anim/MoveVec.cs.meta → Assets/Script/Tool/Anim/Anim.cs.meta

@@ -1,6 +1,6 @@
 fileFormatVersion: 2
-guid: 15d25b48775dc7c4dbc614ce0c80df93
-timeCreated: 1488182161
+guid: 8231cf803f7d7c1408fd9470fb977135
+timeCreated: 1489628126
 licenseType: Pro
 MonoImporter:
   serializedVersion: 2

+ 90 - 6
Assets/Script/Tool/Anim/Move.cs

@@ -1,17 +1,101 @@
 using UnityEngine;
+using UnityEngine.Events;
 
+using System;
 using System.Collections;
-using UnityEngine.Events;
 
-public abstract class Move 
+public class Move : Anim
 {
     #region 变量
 
-    public bool Finish;
-    public UnityAction OnStart;
-    public UnityAction OnFinish;
+    protected override bool InDestination
+    {
+        get
+        {
+            if (Target.position == Destination)
+            {
+                _InDestination = true;
+            }
+            else
+            {
+                _InDestination = false;
+            }
+
+            return _InDestination;
+        }
+        set
+        {
+            _InDestination = value;
+
+            if (_InDestination)
+            {
+                Target.position = Destination;
+            }
+        }
+    }
+
+    protected float Timer;
+    protected float Duration;
+    protected Vector3 Delta;
+    protected Vector3 Origin;
+    protected Vector3 Destination;
+    protected Transform Target;
+
+    protected CurveFunctionV Func;
 
     #endregion
 
-    public abstract bool DoMove();
+    public Move(Transform target)
+    {
+        Target = target;
+    }
+
+
+    public override bool Do()
+    {
+        Timer += Time.fixedDeltaTime;
+
+        if (Timer > Duration)
+        {
+            Timer = 0;
+
+            Target.position = Destination;
+
+            ManaAnim.AnimList.Remove(this);
+
+            if (OnFinish != null)
+            {
+                OnFinish.Invoke();
+            }
+
+            return true;
+        }
+        else
+        {
+            Target.position = Func(Timer, Duration, Origin, Delta);
+
+            return false;
+        }
+    }
+
+    public void StartMove(Vector3 destination, float duration, Curve curve)
+    {
+        InDestination = false;
+        destination.z = Target.position.z;
+
+        Delta = destination - Target.position;
+        Origin = Target.position;
+        Duration = duration;
+        Destination = destination;
+
+        Func = ManaAnim.CurveFunctionDicV[curve];
+
+        if (OnStart != null)
+        {
+            OnStart.Invoke();
+        }
+
+        ManaAnim.AnimList.Remove(this);
+        ManaAnim.AnimList.Add(this);
+    }
 }

+ 2 - 2
Assets/Script/Tool/Anim/Move.cs.meta

@@ -1,6 +1,6 @@
 fileFormatVersion: 2
-guid: 8231cf803f7d7c1408fd9470fb977135
-timeCreated: 1489628126
+guid: 15d25b48775dc7c4dbc614ce0c80df93
+timeCreated: 1488182161
 licenseType: Pro
 MonoImporter:
   serializedVersion: 2

+ 0 - 75
Assets/Script/Tool/Anim/MoveVec.cs

@@ -1,75 +0,0 @@
-using UnityEngine;
-using UnityEngine.Events;
-
-using System;
-using System.Collections;
-
-public class MoveVec : Move
-{
-    #region 变量
-
-    protected float Timer;
-    protected float Duration;
-    protected Vector3 Delta;
-    protected Vector3 Origin;
-    protected Vector3 Destination;
-    protected Transform Target;
-
-    protected CurveFunctionV Func;
-
-    #endregion
-
-    public MoveVec(Transform target)
-    {
-        Target = target;
-    }
-
-
-    public override bool DoMove()
-    {
-        Timer += Time.fixedDeltaTime;
-
-        if (Timer > Duration)
-        {
-            Timer = 0;
-
-            Target.position = Destination;
-
-            ManaAnim.MoveList.Remove(this);
-
-            if (OnFinish != null)
-            {
-                OnFinish.Invoke();
-            }
-
-            return true;
-        }
-        else
-        {
-            Target.position = Func(Timer, Duration, Origin, Delta);
-
-            return false;
-        }
-    }
-
-    public void StartMove(Vector3 destination, float duration, Curve curve)
-    {
-        Finish = false;
-        destination.z = Target.position.z;
-
-        Delta = destination - Target.position;
-        Origin = Target.position;
-        Duration = duration;
-        Destination = destination;
-
-        Func = ManaAnim.FunctionDicV[curve];
-
-        if (OnStart != null)
-        {
-            OnStart.Invoke();
-        }
-
-        ManaAnim.MoveList.Remove(this);
-        ManaAnim.MoveList.Add(this);
-    }
-}

+ 90 - 9
Assets/Script/Tool/Anim/Shake.cs

@@ -2,22 +2,103 @@
 
 using System.Collections;
 using System.Collections.Generic;
+using Debug = System.Diagnostics.Debug;
 
-public class Shake : MonoBehaviour
+public class Shake : Anim
 {
-	#region 变量
+    #region 变量
 
+    protected override bool InDestination
+    {
+        get
+        {
+            if (Target.position == Origin)
+            {
+                _InDestination = true;
+            }
+            else
+            {
+                _InDestination = false;
+            }
+
+            return _InDestination;
+        }
+        set
+        {
+            _InDestination = value;
+
+            if (_InDestination)
+            {
+                Target.position = Origin;
+            }
+        }
+    }
 
+    protected int Repeat;
+    protected float Z;
+    protected float Timer;
+    protected float Duration;
+    protected Vector3 Origin;
+    protected Vector3 Strength;
+    protected Transform Target;
+
+    protected ShakeFunctionV Func;
 
     #endregion
 
-	private void Awake()
+    public Shake(Transform transform)
     {
-	    
-	}
-	
-	private void FixedUpdate()
+        Target = transform;
+    }
+
+    public override bool Do()
     {
-		
-	}
+        Timer += Time.fixedDeltaTime;
+
+        if (Timer > Duration)
+        {
+            Timer = 0;
+
+            InDestination = true;
+
+            ManaAnim.AnimList.Remove(this);
+
+            if (OnFinish != null)
+            {
+                OnFinish.Invoke();
+            }
+
+            return true;
+        }
+        else
+        {
+            Target.position = Func(Timer, Duration, Repeat, Origin, Strength);
+            Target.SetZ(Z);
+
+            return false;
+        }
+    }
+
+    public void StartShake(int repeat, float duration, Vector3 strength, Curve curve)
+    {
+        InDestination = false;
+
+        Repeat = repeat;
+
+        Z = Target.position.z;
+
+        Origin = Target.position;
+        Strength = strength;
+        Duration = duration;
+
+        Func = ManaAnim.ShakeFunctionDicV[curve];
+
+        if (OnStart != null)
+        {
+            OnStart.Invoke();
+        }
+
+        ManaAnim.AnimList.Remove(this);
+        ManaAnim.AnimList.Add(this);
+    }
 }

+ 0 - 2
Assets/Script/Tool/Anim/Tween.cs

@@ -58,7 +58,6 @@ public abstract class Tween
     public virtual void StartForward()
     {
         InForward = true;
-        InOrigin = false;
 
         OnForwardStart.Invoke();
 
@@ -69,7 +68,6 @@ public abstract class Tween
     public virtual void StartBackward()
     {
         InBackward = true;
-        InDestination = false;
 
         OnBackwardStart.Invoke();
 

+ 10 - 4
Assets/Script/Tool/Anim/TweenAudio.cs

@@ -15,6 +15,10 @@ public class TweenAudio : Tween
             {
                 _InOrigin = true;
             }
+            else
+            {
+                _InOrigin = false;
+            }
 
             return _InOrigin;
         }
@@ -36,7 +40,11 @@ public class TweenAudio : Tween
         {
             if (Math.Abs(Target.volume - Destination) < 0.0005f)
             {
-                InDestination = true;
+                _InDestination = true;
+            }
+            else
+            {
+                _InDestination = false;
             }
 
             return _InDestination;
@@ -62,7 +70,7 @@ public class TweenAudio : Tween
 
     public TweenAudio(AudioSource target, float origin, float destination, float duration, bool originActive, bool destActive, Curve curve)
     {
-        Func = ManaAnim.FunctionDicF[curve];
+        Func = ManaAnim.CurveFunctionDicF[curve];
         Target = target;
 
         InForward = false;
@@ -132,7 +140,6 @@ public class TweenAudio : Tween
             Timer = 0;
 
             InForward = false;
-            InDestination = true;
 
             OnForwardFinish.Invoke();
 
@@ -157,7 +164,6 @@ public class TweenAudio : Tween
             Timer = 0;
 
             InBackward = false;
-            InOrigin = true;
 
             OnBackwardFinish.Invoke();
 

+ 10 - 4
Assets/Script/Tool/Anim/TweenCG.cs

@@ -15,6 +15,10 @@ public class TweenCG : Tween
             {
                 _InOrigin = true;
             }
+            else
+            {
+                _InOrigin = false;
+            }
 
             return _InOrigin;
         }
@@ -38,7 +42,11 @@ public class TweenCG : Tween
         {
             if (Math.Abs(Target.alpha - Destination) < 0.0005f)
             {
-                InDestination = true;
+                _InDestination = true;
+            }
+            else
+            {
+                _InDestination = false;
             }
 
             return _InDestination;
@@ -65,7 +73,7 @@ public class TweenCG : Tween
 
     public TweenCG(CanvasGroup target, float origin, float destination, float duration, bool originActive, bool destActive, Curve curve)
     {
-        Func = ManaAnim.FunctionDicF[curve];
+        Func = ManaAnim.CurveFunctionDicF[curve];
         Target = target;
 
         InForward = false;
@@ -140,7 +148,6 @@ public class TweenCG : Tween
             Timer = 0;
 
             InForward = false;
-            InDestination = true;
 
             OnForwardFinish.Invoke();
 
@@ -165,7 +172,6 @@ public class TweenCG : Tween
             Timer = 0;
 
             InBackward = false;
-            InOrigin = true;
 
             OnBackwardFinish.Invoke();
 

+ 9 - 3
Assets/Script/Tool/Anim/TweenGra.cs

@@ -16,6 +16,10 @@ public class TweenGra : Tween
             {
                 _InOrigin = true;
             }
+            else
+            {
+                _InOrigin = false;
+            }
 
             return _InOrigin;
         }
@@ -41,6 +45,10 @@ public class TweenGra : Tween
             {
                 _InDestination = true;
             }
+            else
+            {
+                _InDestination = false;
+            }
 
             return _InDestination;
         }
@@ -66,7 +74,7 @@ public class TweenGra : Tween
 
     public TweenGra(Graphic target, Color origin, Color destination, float duration, bool originActive, bool destActive, Curve curve)
     {
-        Func = ManaAnim.FunctionDicC[curve];
+        Func = ManaAnim.CurveFunctionDicC[curve];
         Target = target;
 
         InForward = false;
@@ -137,7 +145,6 @@ public class TweenGra : Tween
             Timer = 0;
 
             InForward = false;
-            InDestination = true;
 
             OnForwardFinish.Invoke();
 
@@ -162,7 +169,6 @@ public class TweenGra : Tween
             Timer = 0;
 
             InBackward = false;
-            InOrigin = true;
 
             OnBackwardFinish.Invoke();
 

+ 9 - 3
Assets/Script/Tool/Anim/TweenRect.cs

@@ -14,6 +14,10 @@ public class TweenRect : Tween
             {
                 _InOrigin = true;
             }
+            else
+            {
+                _InOrigin = false;
+            }
 
             return _InOrigin;
         }
@@ -38,6 +42,10 @@ public class TweenRect : Tween
             {
                 _InDestination = true;
             }
+            else
+            {
+                _InDestination = false;
+            }
 
             return _InDestination;
         }
@@ -65,7 +73,7 @@ public class TweenRect : Tween
     public TweenRect(RectTransform target, Vector2 origin, Vector2 destination, float duration, bool originActive, bool destActive, Curve curve)
     {
         CG = target.GetComponent<CanvasGroup>();
-        Func = ManaAnim.FunctionDicV[curve];
+        Func = ManaAnim.CurveFunctionDicV[curve];
         Target = target;
 
         InForward = false;
@@ -156,7 +164,6 @@ public class TweenRect : Tween
             Timer = 0;
 
             InForward = false;
-            InDestination = true;
 
             OnForwardFinish.Invoke();
 
@@ -181,7 +188,6 @@ public class TweenRect : Tween
             Timer = 0;
 
             InBackward = false;
-            InOrigin = true;
 
             OnBackwardFinish.Invoke();
 

+ 9 - 3
Assets/Script/Tool/Anim/TweenScale.cs

@@ -15,6 +15,10 @@ public class TweenScale : Tween
             {
                 _InOrigin = true;
             }
+            else
+            {
+                _InOrigin = false;
+            }
 
             return _InOrigin;
         }
@@ -39,6 +43,10 @@ public class TweenScale : Tween
             {
                 _InDestination = true;
             }
+            else
+            {
+                _InDestination = false;
+            }
 
             return _InDestination;
         }
@@ -66,7 +74,7 @@ public class TweenScale : Tween
     public TweenScale(Transform target, Vector3 origin, Vector3 destination, float duration, bool originActive, bool destActive, Curve curve)
     {
         CG = target.GetComponent<CanvasGroup>();
-        Func = ManaAnim.FunctionDicV[curve];
+        Func = ManaAnim.CurveFunctionDicV[curve];
         Target = target;
 
         InForward = false;
@@ -158,7 +166,6 @@ public class TweenScale : Tween
             Timer = 0;
 
             InForward = false;
-            InDestination = true;
 
             OnForwardFinish.Invoke();
 
@@ -183,7 +190,6 @@ public class TweenScale : Tween
             Timer = 0;
 
             InBackward = false;
-            InOrigin = true;
 
             OnBackwardFinish.Invoke();
 

+ 9 - 3
Assets/Script/Tool/Anim/TweenSr.cs

@@ -14,6 +14,10 @@ public class TweenSr : Tween
             {
                 _InOrigin = true;
             }
+            else
+            {
+                _InOrigin = false;
+            }
 
             return _InOrigin;
         }
@@ -38,6 +42,10 @@ public class TweenSr : Tween
             {
                 _InDestination = true;
             }
+            else
+            {
+                _InDestination = false;
+            }
 
             return _InDestination;
         }
@@ -63,7 +71,7 @@ public class TweenSr : Tween
 
     public TweenSr(SpriteRenderer target, Color origin, Color destination, float duration, bool originActive, bool destActive, Curve curve)
     {
-        Func = ManaAnim.FunctionDicC[curve];
+        Func = ManaAnim.CurveFunctionDicC[curve];
         Target = target;
 
         InForward = false;
@@ -134,7 +142,6 @@ public class TweenSr : Tween
             Timer = 0;
 
             InForward = false;
-            InDestination = true;
 
             OnForwardFinish.Invoke();
 
@@ -159,7 +166,6 @@ public class TweenSr : Tween
             Timer = 0;
 
             InBackward = false;
-            InOrigin = true;
 
             OnBackwardFinish.Invoke();
 

+ 10 - 4
Assets/Script/Tool/Anim/TweenText.cs

@@ -16,6 +16,10 @@ public class TweenText : Tween
             {
                 _InOrigin = true;
             }
+            else
+            {
+                _InOrigin = false;
+            }
 
             return _InOrigin;
         }
@@ -38,7 +42,11 @@ public class TweenText : Tween
         {
             if (Math.Abs(Target.fontSize - Destination) < 0.0005f)
             {
-                InDestination = true;
+                _InDestination = true;
+            }
+            else
+            {
+                _InDestination = false;
             }
 
             return _InDestination;
@@ -66,7 +74,7 @@ public class TweenText : Tween
 
     public TweenText(Text target, float origin, float destination, float duration, bool originActive, bool destActive, Curve curve)
     {
-        Func = ManaAnim.FunctionDicF[curve];
+        Func = ManaAnim.CurveFunctionDicF[curve];
         Target = target;
 
         InForward = false;
@@ -137,7 +145,6 @@ public class TweenText : Tween
             Timer = 0;
 
             InForward = false;
-            InDestination = true;
 
             OnForwardFinish.Invoke();
 
@@ -162,7 +169,6 @@ public class TweenText : Tween
             Timer = 0;
 
             InBackward = false;
-            InOrigin = true;
 
             OnBackwardFinish.Invoke();
 

+ 9 - 3
Assets/Script/Tool/Anim/TweenVec.cs

@@ -15,6 +15,10 @@ public class TweenVec : Tween
             {
                 _InOrigin = true;
             }
+            else
+            {
+                _InOrigin = false;
+            }
 
             return _InOrigin;
         }
@@ -39,6 +43,10 @@ public class TweenVec : Tween
             {
                 _InDestination = true;
             }
+            else
+            {
+                _InDestination = false;
+            }
 
             return _InDestination;
         }
@@ -66,7 +74,7 @@ public class TweenVec : Tween
     public TweenVec(Transform target, Vector3 origin, Vector3 destination, float duration, bool originActive, bool destActive, Curve curve)
     {
         CG = target.GetComponent<CanvasGroup>();
-        Func = ManaAnim.FunctionDicV[curve];
+        Func = ManaAnim.CurveFunctionDicV[curve];
         Target = target;
 
         InForward = false;
@@ -157,7 +165,6 @@ public class TweenVec : Tween
             Timer = 0;
 
             InForward = false;
-            InDestination = true;
 
             OnForwardFinish.Invoke();
 
@@ -182,7 +189,6 @@ public class TweenVec : Tween
             Timer = 0;
 
             InBackward = false;
-            InOrigin = true;
 
             OnBackwardFinish.Invoke();
 

+ 26 - 6
Assets/Script/Tool/Extension.cs

@@ -73,20 +73,40 @@ public static class Extension
 
     #region Move
 
-    public static void MoveVec(this Component comp, Vector3 destination, float duration, Curve curve)
+    public static void Move(this Component comp, Vector3 destination, float duration, Curve curve)
     {
-        ManaAnim.MoveVec(comp.transform, destination, duration, curve);
+        ManaAnim.Move(comp.transform, destination, duration, curve);
     }
 
 
-    public static MoveVec GetMoveVec(this Component comp)
+    public static Move GetMove(this Component comp)
     {
-        return ManaAnim.GetMoveVec(comp.transform);
+        return ManaAnim.GetMove(comp.transform);
     }
 
-    public static MoveVec CreateMoveVec(this Component comp)
+    public static Move CreateMove(this Component comp)
     {
-        return ManaAnim.CreateMoveVec(comp.transform);
+        return ManaAnim.CreateMove(comp.transform);
+    }
+
+    #endregion
+
+    #region Shake
+
+    public static void Shake(this Component comp, float duration, int repeat, Vector3 strength, Curve curve)
+    {
+        ManaAnim.Shake(comp.transform, duration, repeat, strength, curve);
+    }
+
+
+    public static Shake GetShake(this Component comp)
+    {
+        return ManaAnim.GetShake(comp.transform);
+    }
+
+    public static Shake CreateShake(this Component comp)
+    {
+        return ManaAnim.CreateShake(comp.transform);
     }
 
     #endregion

+ 6 - 6
Assets/Script/Tool/UI/FlowerCard.cs

@@ -37,14 +37,14 @@ public class FlowerCard : MonoBehaviour
         ScrollRect.DragEvent += OnDrag;
         ScrollRect.EndDragEvent += OnEndDrag;
 
-        MoveVec moveVec = ScrollRect.content.CreateMoveVec();
+        Move move = ScrollRect.content.CreateMove();
 
-        moveVec.OnStart += () =>
+        move.OnStart += () =>
         {
             SelectLock = true;
         };
 
-        moveVec.OnFinish += () =>
+        move.OnFinish += () =>
         {
             SelectLock = false;
         };
@@ -102,7 +102,7 @@ public class FlowerCard : MonoBehaviour
         delta.y = 0;
         delta.z = 0;
 
-        ScrollRect.content.MoveVec(ScrollRect.content.transform.position + delta, 0.25f, Curve.EaseOutQuad);
+        ScrollRect.content.Move(ScrollRect.content.transform.position + delta, 0.25f, Curve.EaseOutQuad);
 
         InfoList = new List<FlowerInfo>();
         ItemList = new List<Transform>();
@@ -140,7 +140,7 @@ public class FlowerCard : MonoBehaviour
             delta.y = 0;
             delta.z = 0;
 
-            ScrollRect.content.MoveVec(ScrollRect.content.transform.position + delta, 0.25f, Curve.EaseOutQuad);
+            ScrollRect.content.Move(ScrollRect.content.transform.position + delta, 0.25f, Curve.EaseOutQuad);
         }
     }
 
@@ -222,6 +222,6 @@ public class FlowerCard : MonoBehaviour
         delta.y = 0;
         delta.z = 0;
 
-        ScrollRect.content.MoveVec(ScrollRect.content.transform.position + delta, 0.25f, Curve.EaseOutQuad);
+        ScrollRect.content.Move(ScrollRect.content.transform.position + delta, 0.25f, Curve.EaseOutQuad);
     }
 }

+ 1 - 1
MyLovelyGarden.csproj

@@ -123,8 +123,8 @@
     <Compile Include="Assets\Script\Object\Skill\Skill.cs" />
     <Compile Include="Assets\Script\Object\Skill\SkillRoot.cs" />
     <Compile Include="Assets\Script\Object\Slot.cs" />
+    <Compile Include="Assets\Script\Tool\Anim\Anim.cs" />
     <Compile Include="Assets\Script\Tool\Anim\Move.cs" />
-    <Compile Include="Assets\Script\Tool\Anim\MoveVec.cs" />
     <Compile Include="Assets\Script\Tool\Anim\Shake.cs" />
     <Compile Include="Assets\Script\Tool\Anim\Tween.cs" />
     <Compile Include="Assets\Script\Tool\Anim\TweenAudio.cs" />

+ 3 - 6
MyLovelyGarden.txt

@@ -1,12 +1,9 @@
-切换后台后功能(音效 收入 技能)
+修改了花园的PageView
 
-改变PageView效果
 
-成就
-
-Shake脚本
+切换后台
 
-分段生成场景
+成就
 
 语言切换功能