Преглед изворни кода

资源【X】的需求
需要怪物掉落“魂”的资源功能设计
1.敌方怪物死亡后会掉落“魂”资源,不同怪物掉落的“魂”数量不一样。
2.玩家靠近后可以拾取这些“魂”,不拾取也会一直存在。

wulifu пре 1 година
родитељ
комит
44af09023c
69 измењених фајлова са 3749 додато и 1 уклоњено
  1. 60 0
      ActionTowerDefense/Assets/Resources/Prefab/Player.prefab
  2. 106 1
      ActionTowerDefense/Assets/Resources/Prefab/soul.prefab
  3. 28 0
      ActionTowerDefense/Assets/Scripts/Soul.cs
  4. 22 0
      ActionTowerDefense/Assets/Scripts/SoulCollector.cs
  5. 11 0
      ActionTowerDefense/Assets/Scripts/SoulCollector.cs.meta
  6. 8 0
      ActionTowerDefense/Assets/Scripts/Tween.meta
  7. 491 0
      ActionTowerDefense/Assets/Scripts/Tween/EaseManager.cs
  8. 8 0
      ActionTowerDefense/Assets/Scripts/Tween/EaseManager.cs.meta
  9. 100 0
      ActionTowerDefense/Assets/Scripts/Tween/uButtonScale.cs
  10. 12 0
      ActionTowerDefense/Assets/Scripts/Tween/uButtonScale.cs.meta
  11. 19 0
      ActionTowerDefense/Assets/Scripts/Tween/uEnum.cs
  12. 12 0
      ActionTowerDefense/Assets/Scripts/Tween/uEnum.cs.meta
  13. 17 0
      ActionTowerDefense/Assets/Scripts/Tween/uIPointHandler.cs
  14. 8 0
      ActionTowerDefense/Assets/Scripts/Tween/uIPointHandler.cs.meta
  15. 48 0
      ActionTowerDefense/Assets/Scripts/Tween/uSliderColors.cs
  16. 8 0
      ActionTowerDefense/Assets/Scripts/Tween/uSliderColors.cs.meta
  17. 175 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenAlpha.cs
  18. 8 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenAlpha.cs.meta
  19. 28 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenAudioVolume.cs
  20. 12 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenAudioVolume.cs.meta
  21. 38 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenCameraView.cs
  22. 12 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenCameraView.cs.meta
  23. 52 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenCanvasGroupAlpha.cs
  24. 12 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenCanvasGroupAlpha.cs.meta
  25. 141 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenColor.cs
  26. 8 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenColor.cs.meta
  27. 497 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenController.cs
  28. 12 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenController.cs.meta
  29. 50 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenCountDown.cs
  30. 12 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenCountDown.cs.meta
  31. 38 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenFinishEventLua.cs
  32. 12 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenFinishEventLua.cs.meta
  33. 43 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenMaterialParam.cs
  34. 12 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenMaterialParam.cs.meta
  35. 51 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenPath.cs
  36. 8 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenPath.cs.meta
  37. 51 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenPathTrans.cs
  38. 12 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenPathTrans.cs.meta
  39. 73 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenPosition.cs
  40. 8 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenPosition.cs.meta
  41. 75 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenPositionTarget.cs
  42. 12 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenPositionTarget.cs.meta
  43. 152 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenPosition_Axis.cs
  44. 12 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenPosition_Axis.cs.meta
  45. 99 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenRotation.cs
  46. 8 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenRotation.cs.meta
  47. 51 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenScale.cs
  48. 8 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenScale.cs.meta
  49. 33 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenSize.cs
  50. 12 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenSize.cs.meta
  51. 55 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenSlider.cs
  52. 8 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenSlider.cs.meta
  53. 82 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenSprite.cs
  54. 12 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenSprite.cs.meta
  55. 52 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenText.cs
  56. 8 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenText.cs.meta
  57. 50 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenTextMeshAlpha.cs
  58. 12 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenTextMeshAlpha.cs.meta
  59. 63 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenTimer.cs
  60. 12 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenTimer.cs.meta
  61. 35 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenValue.cs
  62. 8 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenValue.cs.meta
  63. 64 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenWorldPosition.cs
  64. 8 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenWorldPosition.cs.meta
  65. 51 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenWorldPosition_Axis.cs
  66. 12 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweenWorldPosition_Axis.cs.meta
  67. 423 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweener.cs
  68. 8 0
      ActionTowerDefense/Assets/Scripts/Tween/uTweener.cs.meta
  69. 1 0
      ActionTowerDefense/ProjectSettings/TagManager.asset

+ 60 - 0
ActionTowerDefense/Assets/Resources/Prefab/Player.prefab

@@ -459,6 +459,7 @@ Transform:
   - {fileID: 1384034400187750894}
   - {fileID: 4278110667860756949}
   - {fileID: 8692792125260174174}
+  - {fileID: 5212359350877648398}
   m_Father: {fileID: 2788556811231999033}
   m_RootOrder: 1
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -526,6 +527,65 @@ Transform:
   m_Father: {fileID: 5205406772191310031}
   m_RootOrder: 5
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!1 &2890838050838839166
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 5212359350877648398}
+  - component: {fileID: 4682640749423133748}
+  - component: {fileID: 3739918129319493242}
+  m_Layer: 0
+  m_Name: SoulCollector
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!4 &5212359350877648398
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 2890838050838839166}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_ConstrainProportionsScale: 0
+  m_Children: []
+  m_Father: {fileID: 5205406772191310031}
+  m_RootOrder: 9
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!114 &4682640749423133748
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 2890838050838839166}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 02e8744abca6d3d459e26c639743ddb7, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  player: {fileID: 0}
+--- !u!65 &3739918129319493242
+BoxCollider:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 2890838050838839166}
+  m_Material: {fileID: 0}
+  m_IsTrigger: 1
+  m_Enabled: 1
+  serializedVersion: 2
+  m_Size: {x: 5, y: 4, z: 1}
+  m_Center: {x: 0, y: 1, z: 0}
 --- !u!1 &3571941038519084344
 GameObject:
   m_ObjectHideFlags: 0

+ 106 - 1
ActionTowerDefense/Assets/Resources/Prefab/soul.prefab

@@ -9793,9 +9793,10 @@ GameObject:
   - component: {fileID: 1723151111827507800}
   - component: {fileID: 1723151111827507801}
   - component: {fileID: 1723151111827507806}
+  - component: {fileID: -7697323034879839750}
   m_Layer: 11
   m_Name: Soul
-  m_TagString: Untagged
+  m_TagString: Soul
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
@@ -9813,6 +9814,7 @@ Transform:
   m_ConstrainProportionsScale: 0
   m_Children:
   - {fileID: 1723151111081767147}
+  - {fileID: 7526387050721720706}
   m_Father: {fileID: 0}
   m_RootOrder: 0
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -9829,6 +9831,11 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   rb: {fileID: 1723151111827507801}
+  collected: 0
+  lerpValue: 0.2
+  addMp: 10
+  tweenPos: {fileID: -7697323034879839750}
+  flySpeed: 10
 --- !u!54 &1723151111827507801
 Rigidbody:
   m_ObjectHideFlags: 0
@@ -9858,6 +9865,59 @@ BoxCollider:
   serializedVersion: 2
   m_Size: {x: 1, y: 1, z: 1}
   m_Center: {x: 0, y: 0, z: 0}
+--- !u!114 &-7697323034879839750
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1723151111827507807}
+  m_Enabled: 0
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 347d7720ca2646343801fd02910b81d9, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  updateStyle: 0
+  method: 22
+  style: 0
+  animationCurve:
+    serializedVersion: 2
+    m_Curve:
+    - serializedVersion: 3
+      time: 0
+      value: 0
+      inSlope: 0
+      outSlope: 1
+      tangentMode: 0
+      weightedMode: 0
+      inWeight: 0
+      outWeight: 0
+    - serializedVersion: 3
+      time: 1
+      value: 1
+      inSlope: 1
+      outSlope: 0
+      tangentMode: 0
+      weightedMode: 0
+      inWeight: 0
+      outWeight: 0
+    m_PreInfinity: 2
+    m_PostInfinity: 2
+    m_RotationOrder: 4
+  ignoreTimeScale: 0
+  delay: 0
+  duration: 1
+  steeperCurves: 0
+  tag: 
+  tweenGroup: 0
+  onFinished:
+    m_PersistentCalls:
+      m_Calls: []
+  eventReceiver: {fileID: 0}
+  callWhenFinished: 
+  startFactor: 0
+  from: {fileID: 0}
+  to: {fileID: 0}
 --- !u!1 &3466083475271790066
 GameObject:
   m_ObjectHideFlags: 0
@@ -29419,3 +29479,48 @@ ParticleSystemRenderer:
   m_MeshWeighting2: 1
   m_MeshWeighting3: 1
   m_MaskInteraction: 0
+--- !u!1 &7293676873242750977
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 7526387050721720706}
+  - component: {fileID: 5919614424193721880}
+  m_Layer: 0
+  m_Name: Trigger
+  m_TagString: Soul
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!4 &7526387050721720706
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 7293676873242750977}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_ConstrainProportionsScale: 0
+  m_Children: []
+  m_Father: {fileID: 1723151111827507803}
+  m_RootOrder: 1
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!65 &5919614424193721880
+BoxCollider:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 7293676873242750977}
+  m_Material: {fileID: 0}
+  m_IsTrigger: 1
+  m_Enabled: 1
+  serializedVersion: 2
+  m_Size: {x: 1, y: 1, z: 1}
+  m_Center: {x: 0, y: 0, z: 0}

+ 28 - 0
ActionTowerDefense/Assets/Scripts/Soul.cs

@@ -1,13 +1,41 @@
 using System.Collections;
 using System.Collections.Generic;
+using System.Threading.Tasks;
 using UnityEngine;
+using uTools;
 
 public class Soul : MonoBehaviour
 {
     public Rigidbody rb;
+    public bool collected = false;
+    public float lerpValue = 0.05f;
+    public int addMp = 10;
+    public uTweenPositionTarget tweenPos;
+    public float flySpeed = 10f;
 
     public void Burst(Vector3 velocity)
     {
+        rb.isKinematic = false;
         rb.velocity = velocity;
+        collected = false;
+    }
+
+    public async void BeCollect()
+    {
+        rb.isKinematic = true;
+        collected = true;
+        tweenPos.from = transform;
+        tweenPos.to = PlayerController.instance.transform;
+        tweenPos.duration = (tweenPos.from.position - tweenPos.to.position).magnitude / flySpeed;
+        tweenPos.ResetToBeginning();
+        tweenPos.PlayForward();
+        await Task.Delay((int)(tweenPos.duration * 1000));
+        BeGet();
+        gameObject.SetActive(false);
+    }
+
+    public void BeGet()
+    {
+        PlayerController.instance.mp += addMp;
     }
 }

+ 22 - 0
ActionTowerDefense/Assets/Scripts/SoulCollector.cs

@@ -0,0 +1,22 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class SoulCollector : MonoBehaviour
+{
+    public PlayerController player;
+
+    private void Awake()
+    {
+        player = GetComponentInParent<PlayerController>();
+    }
+
+    private void OnTriggerEnter(Collider other)
+    {
+        Soul soul = other.GetComponentInParent<Soul>();
+        if (soul)
+        {
+            soul.BeCollect();
+        }
+    }
+}

+ 11 - 0
ActionTowerDefense/Assets/Scripts/SoulCollector.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 02e8744abca6d3d459e26c639743ddb7
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
ActionTowerDefense/Assets/Scripts/Tween.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: acdacaec9e3590941845292c57da04c3
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 491 - 0
ActionTowerDefense/Assets/Scripts/Tween/EaseManager.cs

@@ -0,0 +1,491 @@
+using UnityEngine;
+using System.Collections;
+
+/// <summary>
+/// Ease type.
+/// </summary>
+
+namespace uTools {
+	public enum EaseType{
+		none,
+		easeInQuad,
+		easeOutQuad,
+		easeInOutQuad,
+		easeInCubic,
+		easeOutCubic,
+		easeInOutCubic,
+		easeInQuart,
+		easeOutQuart,
+		easeInOutQuart,
+		easeInQuint,
+		easeOutQuint,
+		easeInOutQuint,
+		easeInSine,
+		easeOutSine,
+		easeInOutSine,
+		easeInExpo,
+		easeOutExpo,
+		easeInOutExpo,
+		easeInCirc,
+		easeOutCirc,
+		easeInOutCirc,
+		linear,
+		spring,
+		/* GFX47 MOD START */
+		//bounce,
+		easeInBounce,
+		easeOutBounce,
+		easeInOutBounce,
+		/* GFX47 MOD END */
+		easeInBack,
+		easeOutBack,
+		easeInOutBack,
+		/* GFX47 MOD START */
+		//elastic,
+		easeInElastic,
+		easeOutElastic,
+		easeInOutElastic,
+		/* GFX47 MOD END */
+		punch
+	}
+
+
+	/// <summary>
+	/// Loop style.
+	/// </summary>
+	public enum LoopStyle {
+		Once,
+		Loop,
+		PingPong
+	}
+
+	/// <summary>
+	/// Ease manager.
+	/// </summary>
+	public class EaseManager {
+
+		public delegate float EaseDelegate(float start, float end, float t);
+
+		#region ease function	
+		private static float linear(float start, float end, float value){
+			return Mathf.Lerp(start, end, value);
+		}
+		
+		private static float clerp(float start, float end, float value){
+			float min = 0.0f;
+			float max = 360.0f;
+			float half = Mathf.Abs((max - min) / 2.0f);
+			float retval = 0.0f;
+			float diff = 0.0f;
+			if ((end - start) < -half){
+				diff = ((max - start) + end) * value;
+				retval = start + diff;
+			}else if ((end - start) > half){
+				diff = -((max - end) + start) * value;
+				retval = start + diff;
+			}else retval = start + (end - start) * value;
+			return retval;
+		}
+		
+		private static float spring(float start, float end, float value){
+			value = Mathf.Clamp01(value);
+			value = (Mathf.Sin(value * Mathf.PI * (0.2f + 2.5f * value * value * value)) * Mathf.Pow(1f - value, 2.2f) + value) * (1f + (1.2f * (1f - value)));
+			return start + (end - start) * value;
+		}
+		
+		private static float easeInQuad(float start, float end, float value){
+			end -= start;
+			return end * value * value + start;
+		}
+		
+		private static float easeOutQuad(float start, float end, float value){
+			end -= start;
+			return -end * value * (value - 2) + start;
+		}
+		
+		private static float easeInOutQuad(float start, float end, float value){
+			value /= .5f;
+			end -= start;
+			if (value < 1) return end / 2 * value * value + start;
+			value--;
+			return -end / 2 * (value * (value - 2) - 1) + start;
+		}
+		
+		private static float easeInCubic(float start, float end, float value){
+			end -= start;
+			return end * value * value * value + start;
+		}
+		
+		private static float easeOutCubic(float start, float end, float value){
+			value--;
+			end -= start;
+			return end * (value * value * value + 1) + start;
+		}
+		
+		private static float easeInOutCubic(float start, float end, float value){
+			value /= .5f;
+			end -= start;
+			if (value < 1) return end / 2 * value * value * value + start;
+			value -= 2;
+			return end / 2 * (value * value * value + 2) + start;
+		}
+		
+		private static float easeInQuart(float start, float end, float value){
+			end -= start;
+			return end * value * value * value * value + start;
+		}
+		
+		private static float easeOutQuart(float start, float end, float value){
+			value--;
+			end -= start;
+			return -end * (value * value * value * value - 1) + start;
+		}
+		
+		private static float easeInOutQuart(float start, float end, float value){
+			value /= .5f;
+			end -= start;
+			if (value < 1) return end / 2 * value * value * value * value + start;
+			value -= 2;
+			return -end / 2 * (value * value * value * value - 2) + start;
+		}
+		
+		private static float easeInQuint(float start, float end, float value){
+			end -= start;
+			return end * value * value * value * value * value + start;
+		}
+		
+		private static float easeOutQuint(float start, float end, float value){
+			value--;
+			end -= start;
+			return end * (value * value * value * value * value + 1) + start;
+		}
+		
+		private static float easeInOutQuint(float start, float end, float value){
+			value /= .5f;
+			end -= start;
+			if (value < 1) return end / 2 * value * value * value * value * value + start;
+			value -= 2;
+			return end / 2 * (value * value * value * value * value + 2) + start;
+		}
+		
+		private static float easeInSine(float start, float end, float value){
+			end -= start;
+			return -end * Mathf.Cos(value / 1 * (Mathf.PI / 2)) + end + start;
+		}
+		
+		private static float easeOutSine(float start, float end, float value){
+			end -= start;
+			return end * Mathf.Sin(value / 1 * (Mathf.PI / 2)) + start;
+		}
+		
+		private static float easeInOutSine(float start, float end, float value){
+			end -= start;
+			return -end / 2 * (Mathf.Cos(Mathf.PI * value / 1) - 1) + start;
+		}
+		
+		private static float easeInExpo(float start, float end, float value){
+			end -= start;
+			return end * Mathf.Pow(2, 10 * (value / 1 - 1)) + start;
+		}
+		
+		private static float easeOutExpo(float start, float end, float value){
+			end -= start;
+			return end * (-Mathf.Pow(2, -10 * value / 1) + 1) + start;
+		}
+		
+		private static float easeInOutExpo(float start, float end, float value){
+			value /= .5f;
+			end -= start;
+			if (value < 1) return end / 2 * Mathf.Pow(2, 10 * (value - 1)) + start;
+			value--;
+			return end / 2 * (-Mathf.Pow(2, -10 * value) + 2) + start;
+		}
+		
+		private static float easeInCirc(float start, float end, float value){
+			end -= start;
+			return -end * (Mathf.Sqrt(1 - value * value) - 1) + start;
+		}
+		
+		private static float easeOutCirc(float start, float end, float value){
+			value--;
+			end -= start;
+			return end * Mathf.Sqrt(1 - value * value) + start;
+		}
+		
+		private static float easeInOutCirc(float start, float end, float value){
+			value /= .5f;
+			end -= start;
+			if (value < 1) return -end / 2 * (Mathf.Sqrt(1 - value * value) - 1) + start;
+			value -= 2;
+			return end / 2 * (Mathf.Sqrt(1 - value * value) + 1) + start;
+		}
+		
+		/* GFX47 MOD START */
+		private static float easeInBounce(float start, float end, float value){
+			end -= start;
+			float d = 1f;
+			return end - easeOutBounce(0, end, d-value) + start;
+		}
+		/* GFX47 MOD END */
+		
+		/* GFX47 MOD START */
+		//private static float bounce(float start, float end, float value){
+		private static float easeOutBounce(float start, float end, float value){
+			value /= 1f;
+			end -= start;
+			if (value < (1 / 2.75f)){
+				return end * (7.5625f * value * value) + start;
+			}else if (value < (2 / 2.75f)){
+				value -= (1.5f / 2.75f);
+				return end * (7.5625f * (value) * value + .75f) + start;
+			}else if (value < (2.5 / 2.75)){
+				value -= (2.25f / 2.75f);
+				return end * (7.5625f * (value) * value + .9375f) + start;
+			}else{
+				value -= (2.625f / 2.75f);
+				return end * (7.5625f * (value) * value + .984375f) + start;
+			}
+		}
+		/* GFX47 MOD END */
+		
+		/* GFX47 MOD START */
+		private static float easeInOutBounce(float start, float end, float value){
+			end -= start;
+			float d = 1f;
+			if (value < d/2) return easeInBounce(0, end, value*2) * 0.5f + start;
+			else return easeOutBounce(0, end, value*2-d) * 0.5f + end*0.5f + start;
+		}
+		/* GFX47 MOD END */
+		
+		private static float easeInBack(float start, float end, float value){
+			end -= start;
+			value /= 1;
+			float s = 1.70158f;
+			return end * (value) * value * ((s + 1) * value - s) + start;
+		}
+		
+		private static float easeOutBack(float start, float end, float value){
+			float s = 1.70158f;
+			end -= start;
+			value = (value / 1) - 1;
+			return end * ((value) * value * ((s + 1) * value + s) + 1) + start;
+		}
+		
+		private static float easeInOutBack(float start, float end, float value){
+			float s = 1.70158f;
+			end -= start;
+			value /= .5f;
+			if ((value) < 1){
+				s *= (1.525f);
+				return end / 2 * (value * value * (((s) + 1) * value - s)) + start;
+			}
+			value -= 2;
+			s *= (1.525f);
+			return end / 2 * ((value) * value * (((s) + 1) * value + s) + 2) + start;
+		}
+		
+		private static float punch(float amplitude, float value){
+			float s = 9;
+			if (value == 0){
+				return 0;
+			}
+			if (value == 1){
+				return 0;
+			}
+			float period = 1 * 0.3f;
+			s = period / (2 * Mathf.PI) * Mathf.Asin(0);
+			return (amplitude * Mathf.Pow(2, -10 * value) * Mathf.Sin((value * 1 - s) * (2 * Mathf.PI) / period));
+		}
+		
+		/* GFX47 MOD START */
+		private static float easeInElastic(float start, float end, float value){
+			end -= start;
+			
+			float d = 1f;
+			float p = d * .3f;
+			float s = 0;
+			float a = 0;
+			
+			if (value == 0) return start;
+			
+			if ((value /= d) == 1) return start + end;
+			
+			if (a == 0f || a < Mathf.Abs(end)){
+				a = end;
+				s = p / 4;
+			}else{
+				s = p / (2 * Mathf.PI) * Mathf.Asin(end / a);
+			}
+			
+			return -(a * Mathf.Pow(2, 10 * (value-=1)) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p)) + start;
+		}		
+		/* GFX47 MOD END */
+		
+		/* GFX47 MOD START */
+		//private static float elastic(float start, float end, float value){
+		private static float easeOutElastic(float start, float end, float value){
+			/* GFX47 MOD END */
+			//Thank you to rafael.marteleto for fixing this as a port over from Pedro's UnityTween
+			end -= start;
+			
+			float d = 1f;
+			float p = d * .3f;
+			float s = 0;
+			float a = 0;
+			
+			if (value == 0) return start;
+			
+			if ((value /= d) == 1) return start + end;
+			
+			if (a == 0f || a < Mathf.Abs(end)){
+				a = end;
+				s = p / 4;
+			}else{
+				s = p / (2 * Mathf.PI) * Mathf.Asin(end / a);
+			}
+			
+			return (a * Mathf.Pow(2, -10 * value) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p) + end + start);
+		}		
+		
+		/* GFX47 MOD START */
+		private static float easeInOutElastic(float start, float end, float value){
+			end -= start;
+			
+			float d = 1f;
+			float p = d * .3f;
+			float s = 0;
+			float a = 0;
+			
+			if (value == 0) return start;
+			
+			if ((value /= d/2) == 2) return start + end;
+			
+			if (a == 0f || a < Mathf.Abs(end)){
+				a = end;
+				s = p / 4;
+			}else{
+				s = p / (2 * Mathf.PI) * Mathf.Asin(end / a);
+			}
+			
+			if (value < 1) return -0.5f * (a * Mathf.Pow(2, 10 * (value-=1)) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p)) + start;
+			return a * Mathf.Pow(2, -10 * (value-=1)) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p) * 0.5f + end + start;
+		}		
+		/* GFX47 MOD END */
+
+
+		public static float EasingFromType(float start, float end, float t, EaseType type){
+			switch (type){
+			case EaseType.easeInQuad:
+				return easeInQuad(start, end, t);
+				
+			case EaseType.easeOutQuad:
+				return easeOutQuad(start, end, t);
+				
+			case EaseType.easeInOutQuad:
+				return easeInOutQuad(start, end, t);
+				
+			case EaseType.easeInCubic:
+				return easeInCubic(start, end, t);
+				
+			case EaseType.easeOutCubic:
+				return easeOutCubic(start, end, t);
+				
+			case EaseType.easeInOutCubic:
+				return easeInOutCubic(start, end, t);
+				
+			case EaseType.easeInQuart:
+				return easeInQuart(start, end, t);
+				
+			case EaseType.easeOutQuart:
+				return easeOutQuart(start, end, t);
+				
+			case EaseType.easeInOutQuart:
+				return easeInOutQuart(start, end, t);
+				
+			case EaseType.easeInQuint:
+				return easeInQuint(start, end, t);
+				
+			case EaseType.easeOutQuint:
+				return easeOutQuint(start, end, t);
+				
+			case EaseType.easeInOutQuint:
+				return easeInOutQuint(start, end, t);
+				
+			case EaseType.easeInSine:
+				return easeInSine(start, end, t);
+				
+			case EaseType.easeOutSine:
+				return easeOutSine(start, end, t);
+				
+			case EaseType.easeInOutSine:
+				return easeInOutSine(start, end, t);
+				
+			case EaseType.easeInExpo:
+				return easeInExpo(start, end, t);
+				
+			case EaseType.easeOutExpo:
+				return easeOutExpo(start, end, t);
+				
+			case EaseType.easeInOutExpo:
+				return easeInOutExpo(start, end, t);
+				
+			case EaseType.easeInCirc:
+				return easeInCirc(start, end, t);
+				
+			case EaseType.easeOutCirc:
+				return easeOutCirc(start, end, t);
+				
+			case EaseType.easeInOutCirc:
+				return easeInOutCirc(start, end, t);
+				
+			case EaseType.linear:
+				return linear(start, end, t);
+				
+			case EaseType.spring:
+				return spring(start, end, t);
+				
+				/* GFX47 MOD START */
+				/*case EaseType.bounce:
+				return bounce(start, end, t);
+				*/
+			case EaseType.easeInBounce:
+				return easeInBounce(start, end, t);
+				
+			case EaseType.easeOutBounce:
+				return easeOutBounce(start, end, t);
+				
+			case EaseType.easeInOutBounce:
+				return easeInOutBounce(start, end, t);
+				
+				/* GFX47 MOD END */
+			case EaseType.easeInBack:
+				return easeInBack(start, end, t);
+				
+			case EaseType.easeOutBack:
+				return easeOutBack(start, end, t);
+				
+			case EaseType.easeInOutBack:
+				return easeInOutBack(start, end, t);
+				
+				/* GFX47 MOD START */
+				/*case EaseType.elastic:
+				return elastic(start, end, t);
+				*/
+			case EaseType.easeInElastic:
+				return easeInElastic(start, end, t);
+				
+			case EaseType.easeOutElastic:
+				return easeOutElastic(start, end, t);
+				
+			case EaseType.easeInOutElastic:
+				return easeInOutElastic(start, end, t);
+				
+				/* GFX47 MOD END */
+			}
+			return linear(start, end, t);
+		}
+
+		#endregion	
+
+	}
+}

+ 8 - 0
ActionTowerDefense/Assets/Scripts/Tween/EaseManager.cs.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 1afd555c1bfbed3458db53ad79173c67
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 

+ 100 - 0
ActionTowerDefense/Assets/Scripts/Tween/uButtonScale.cs

@@ -0,0 +1,100 @@
+using UnityEngine;
+using UnityEngine.UI;
+using UnityEngine.Events;
+using UnityEngine.EventSystems;
+using System.Collections;
+
+namespace uTools
+{
+    [RequireComponent(typeof(Button))]
+    [AddComponentMenu("uTools/Tween/Button Scale(uTools)")]
+    public class uButtonScale : MonoBehaviour, uIPointHandler
+    {
+        private Button button;
+        private Toggle toggle;
+
+        public RectTransform tweenTarget;
+        public Vector3 normalSize = Vector2.one;
+        public Vector3 down = new Vector2(0.9f, 0.9f);
+        public float downDuration = 0.2f;
+        public float upDuration = 0.05f;
+
+        public AnimationCurve downCurve = new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f));
+        public AnimationCurve upCurve = new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f));
+
+        public bool isUseToggle = false;
+        public bool ignoreTimeScale = false;
+        uTweenScale ts;
+        public UnityEvent onPointerDown;
+        public UnityEvent onPointerUp;
+
+        // Use this for initialization
+        void Start()
+        {
+            if (tweenTarget == null)
+            {
+                tweenTarget = GetComponent<RectTransform>();
+            }
+            if (null == ts)
+            {
+                ts = tweenTarget.gameObject.AddComponent<uTweenScale>();
+                ts.enabled = false;
+                ts.ignoreTimeScale = ignoreTimeScale;
+            }
+            if (isUseToggle)
+                toggle = GetComponent<Toggle>();
+            else
+                button = GetComponent<Button>();
+        }
+
+        void OnEnable()
+        {
+            if (null != ts)
+            {
+                ts.enabled = false;
+            }
+            if (null != tweenTarget)
+            {
+                tweenTarget.localScale = normalSize;
+            }
+        }
+
+        public void OnPointerDown(PointerEventData eventData)
+        {
+            if (!isUseToggle)
+            {
+                if (button.enabled == false || button.interactable == false)
+                    return;
+            }
+            else
+            {
+                if (toggle.enabled == false || toggle.interactable == false)
+                    return;
+            }
+            Scale(down, downDuration, downCurve);
+            onPointerDown.Invoke();
+        }
+
+        public void OnPointerUp(PointerEventData eventData)
+        {
+            Scale(normalSize, upDuration, upCurve);
+            onPointerUp.Invoke();
+        }
+
+        public void OnPointerClick(PointerEventData eventData)
+        {
+
+        }
+
+        void Scale(Vector3 to, float duration, AnimationCurve curve)
+        {
+            //ts = uTweenScale.Begin(tweenTarget.gameObject, tweenTarget.localScale, to, duration);
+            ts.from = tweenTarget.localScale;
+            ts.to = to;
+            ts.duration = duration;
+            ts.animationCurve = curve;
+            ts.ResetToBeginning();
+            ts.PlayForward();
+        }
+    }
+}

+ 12 - 0
ActionTowerDefense/Assets/Scripts/Tween/uButtonScale.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: d13540b644de15642be047a9b4c00d95
+timeCreated: 1468658991
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 19 - 0
ActionTowerDefense/Assets/Scripts/Tween/uEnum.cs

@@ -0,0 +1,19 @@
+using UnityEngine;
+using System.Collections;
+
+namespace uTools {
+    public enum Direction
+    {
+		Reverse = -1,
+		Toggle = 0,
+		Forward = 1
+	}
+
+	public enum Trigger {
+		OnPointerEnter,
+		OnPointerDown,
+		OnPointerClick,
+		OnPointerUp,
+		OnPointerExit,
+	}
+}

+ 12 - 0
ActionTowerDefense/Assets/Scripts/Tween/uEnum.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 303ea93426e34e748ab3a8d2f2416db5
+timeCreated: 1448261409
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 17 - 0
ActionTowerDefense/Assets/Scripts/Tween/uIPointHandler.cs

@@ -0,0 +1,17 @@
+using UnityEngine;
+using UnityEngine.EventSystems;
+using System.Collections;
+
+namespace uTools {
+	public interface uIPointHandler : 
+		IPointerDownHandler,
+		IPointerClickHandler,
+		IPointerUpHandler{
+
+        new void OnPointerDown(PointerEventData eventData);
+		new void OnPointerClick (PointerEventData eventData);
+		new void OnPointerUp (PointerEventData eventData);
+
+	}
+
+}

+ 8 - 0
ActionTowerDefense/Assets/Scripts/Tween/uIPointHandler.cs.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: fca88ba73ee80ee4da7917cb3f7763af
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 

+ 48 - 0
ActionTowerDefense/Assets/Scripts/Tween/uSliderColors.cs

@@ -0,0 +1,48 @@
+//
+// Copyright (c) 2015 Tomtc123
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+using UnityEngine;
+using UnityEngine.UI;
+using UnityEngine.Events;
+using System.Collections;
+using Base.Common;
+
+namespace uTools {
+	[AddComponentMenu("uTools/Tween/Slider Colors(uTools)")]
+	public class uSliderColors : MonoBehaviour {
+		public Image target;
+		public Color[] colors = new Color[]{Color.red, Color.yellow, Color.green};
+
+		Slider mSlider;
+
+		// Use this for initialization
+		void Start () {
+			mSlider = GetComponent<Slider>();
+			if (mSlider == null) {
+				return;
+			}
+			if (target == null) {
+				target = mSlider.GetComponentInChildren<Image>();
+			}
+			UnityAction<float> valueChange = new UnityAction<float>(OnValueChanged);
+			mSlider.onValueChanged.AddListener(valueChange);
+			OnValueChanged(mSlider.value);
+		}
+
+		public void OnValueChanged(float value) {
+			float val = value * (colors.Length - 1);
+			int startIndex = Mathf.FloorToInt(val);
+			Color c = colors[0];
+			if ( (startIndex + 1) < colors.Length) {
+				c = Color.Lerp(colors[startIndex], colors[startIndex+1], val - startIndex);
+			}
+			else if (startIndex < colors.Length) {
+				c = colors[startIndex];
+			}
+			target.color = c;
+		}
+
+	}
+}

+ 8 - 0
ActionTowerDefense/Assets/Scripts/Tween/uSliderColors.cs.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 5795400381c4b2f44aec335519805ec5
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 

+ 175 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenAlpha.cs

@@ -0,0 +1,175 @@
+using UnityEngine;
+using UnityEngine.UI;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace uTools
+{
+    public enum TweenTarget
+    {
+        SpriteRender,
+        UI,
+        TextMesh,
+        MeshRenderer,
+    }
+
+    [AddComponentMenu("uTools/Tween/Tween Alpha(uTools)")]
+    public class uTweenAlpha : uTweenValue
+    {
+        Transform mTransform;
+        public TweenTarget alphaType = TweenTarget.UI;
+
+        public bool includeChilds = false;
+
+        List<SpriteRenderer> spList = new List<SpriteRenderer>();
+        List<Graphic> gaList = new List<Graphic>();
+        List<TextMesh> textMeshList = new List<TextMesh>();
+        List<MeshRenderer> meshRendererList = new List<MeshRenderer>();
+
+        float mAlpha = 0f;
+
+        protected override void Awake()
+        {
+            GetTweenList();
+            base.Awake();
+        }
+
+        void GetTweenList()
+        {
+            spList.Clear();
+            gaList.Clear();
+            textMeshList.Clear();
+            meshRendererList.Clear();
+
+            Queue<Transform> childList = new Queue<Transform>();
+            childList.Enqueue(cachedTransform);
+
+            while (childList.Count > 0)
+            {
+                Transform t = childList.Dequeue();
+                if (alphaType == TweenTarget.SpriteRender)
+                {
+                    SpriteRenderer m_sp = t.GetComponent<SpriteRenderer>();
+                    if (null != m_sp) spList.Add(m_sp);
+                }
+                else if (alphaType == TweenTarget.UI)
+                {
+                    Graphic m_graphic = t.GetComponent<Graphic>();
+                    if (null != m_graphic) gaList.Add(m_graphic);
+                }
+                else if (alphaType == TweenTarget.TextMesh)
+                {
+                    TextMesh m_textMesh = t.GetComponent<TextMesh>();
+                    if (null != m_textMesh) textMeshList.Add(m_textMesh);
+                }
+                else if(alphaType == TweenTarget.MeshRenderer)
+                {
+                    MeshRenderer m_meshRender = t.GetComponent<MeshRenderer>();
+                    if (null != m_meshRender) meshRendererList.Add(m_meshRender);
+                }
+                if (includeChilds)
+                {
+                    for (int i = 0; i < t.childCount; i++)
+                    {
+                        childList.Enqueue(t.GetChild(i));
+                    }
+                }
+            }
+        }
+
+        public Transform cachedTransform { get { if (mTransform == null) mTransform = transform; return mTransform; } }
+
+        public float alpha
+        {
+            get
+            {
+                return mAlpha;
+            }
+            set
+            {
+                SetAlpha(value);
+                mAlpha = value;
+            }
+        }
+
+        protected override void ValueUpdate(float value, bool isFinished)
+        {
+            alpha = value;
+        }
+
+        void SetAlpha(float _alpha)
+        {
+            Color c = Color.white;
+            if (alphaType == TweenTarget.SpriteRender)
+            {
+                if (spList.Count == 0)
+                {
+                    GetTweenList();
+                }
+                for (int i = 0; i < spList.Count; i++)
+                {
+                    SpriteRenderer m_sp = spList[i];
+                    c = m_sp.color;
+                    c.a = _alpha;
+                    m_sp.color = c;
+                }
+            }
+            else if (alphaType == TweenTarget.UI)
+            {
+                if (gaList.Count == 0)
+                {
+                    GetTweenList();
+                }
+                for (int i = 0; i < gaList.Count; i++)
+                {
+                    Graphic m_ga = gaList[i];
+                    c = m_ga.color;
+                    c.a = _alpha;
+                    m_ga.color = c;
+                }
+            }
+            else if (alphaType == TweenTarget.TextMesh)
+            {
+                if (textMeshList.Count == 0)
+                {
+                    GetTweenList();
+                }
+                for (int i = 0; i < textMeshList.Count; i++)
+                {
+                    TextMesh m_textMesh = textMeshList[i];
+                    c = m_textMesh.color;
+                    c.a = _alpha;
+                    m_textMesh.color = c;
+                }
+            }
+            else if (alphaType == TweenTarget.MeshRenderer)
+            {
+                if(meshRendererList.Count == 0)
+                {
+                    GetTweenList();
+                }
+                for(int i = 0; i < meshRendererList.Count; i ++)
+                {
+                    c = meshRendererList[i].material.GetColor("_TintColor");
+                    if(null != c)
+                    {
+                        c.a = _alpha;
+                        meshRendererList[i].material.SetColor("_TintColor", c);
+                    }
+                }
+            }
+        }
+
+        public override void SetCurrentValueToEnd()
+        {
+            base.SetCurrentValueToEnd();
+            alpha = to;
+        }
+
+        public override void SetCurrentValueToStart()
+        {
+            base.SetCurrentValueToStart();
+            alpha = from;
+        }
+    }
+}

+ 8 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenAlpha.cs.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 7a35bb9224f51774997ad90c4f687e38
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 

+ 28 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenAudioVolume.cs

@@ -0,0 +1,28 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace uTools
+{
+    public class uTweenAudioVolume : uTweenValue
+    {
+        AudioSource audioSource;
+
+        public AudioSource AudioSource
+        {
+            get
+            {
+                if (null == audioSource)
+                {
+                    audioSource = GetComponent<AudioSource>();
+                }
+                return audioSource;
+            }
+        }
+
+        protected override void ValueUpdate(float value, bool isFinished)
+        {
+            AudioSource.volume = value;
+        }
+    }
+}

+ 12 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenAudioVolume.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 61f0b93da9516b047ad21615d9234c78
+timeCreated: 1528279042
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 38 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenCameraView.cs

@@ -0,0 +1,38 @@
+using UnityEngine;
+using System.Collections;
+
+namespace uTools
+{
+    [AddComponentMenu("uTools/Tween/Tween Camera View(uTools)")]
+    public class uTweenCameraView : uTweenValue
+    {
+        Camera Camera;
+
+        Camera m_camera
+        { 
+            get 
+            {
+                if (null == Camera)
+                    Camera = this.GetComponent<Camera>();
+                return Camera;
+            }
+        }
+
+        float cameraView
+        {
+            get
+            {
+                return m_camera.orthographicSize;
+            }
+            set
+            {
+                m_camera.orthographicSize = value;
+            }
+        }
+
+        protected override void ValueUpdate(float value, bool isFinished)
+        {
+            cameraView = value;
+        }
+    }
+}

+ 12 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenCameraView.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 61fd6394f1c6ec848aa1f482457a0b24
+timeCreated: 1452492653
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 52 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenCanvasGroupAlpha.cs

@@ -0,0 +1,52 @@
+using UnityEngine;
+using System.Collections;
+
+namespace uTools
+{
+    [RequireComponent(typeof(CanvasGroup))]
+    public class uTweenCanvasGroupAlpha : uTweenValue
+    {
+        Transform mTransform;
+
+        float mAlpha = 0f;
+
+        public Transform cachedTransform { get { if (mTransform == null) mTransform = transform; return mTransform; } }
+
+        CanvasGroup mCanvasGroup;
+
+        public CanvasGroup canvasGroup
+        {
+            get
+            {
+                if (null == mCanvasGroup)
+                {
+                    mCanvasGroup = GetComponent<CanvasGroup>();
+                }
+                return mCanvasGroup;
+            }
+        }
+
+        public float alpha
+        {
+            get
+            {
+                return mAlpha;
+            }
+            set
+            {
+                SetAlpha(value);
+                mAlpha = value;
+            }
+        }
+
+        protected override void ValueUpdate(float value, bool isFinished)
+        {
+            alpha = value;
+        }
+
+        void SetAlpha(float _alpha)
+        {
+            canvasGroup.alpha = _alpha;
+        }
+    }
+}

+ 12 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenCanvasGroupAlpha.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 77eedaa227e919f438166e523ed9d495
+timeCreated: 1477478727
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 141 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenColor.cs

@@ -0,0 +1,141 @@
+using UnityEngine;
+using UnityEngine.UI;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace uTools
+{
+    [AddComponentMenu("uTools/Tween/Tween Color(uTools)")]
+    public class uTweenColor : uTweener
+    {
+        Transform mTransform;
+        public TweenTarget colorType = TweenTarget.UI;
+        public Color from = Color.white;
+        public Color to = Color.white;
+        public bool includeChilds = false;
+
+        List<SpriteRenderer> spList = new List<SpriteRenderer>();
+        List<Graphic> gaList = new List<Graphic>();
+        List<TextMesh> textMeshList = new List<TextMesh>();
+
+        Color mColor = Color.white;
+
+        public Transform cachedTransform { get { if (mTransform == null) mTransform = transform; return mTransform; } }
+
+        protected override void Awake()
+        {
+            GetTweenList();
+            base.Awake();
+        }
+
+        void GetTweenList()
+        {
+            spList.Clear();
+            gaList.Clear();
+            textMeshList.Clear();
+
+            Queue<Transform> childList = new Queue<Transform>();
+            childList.Enqueue(cachedTransform);
+
+            while (childList.Count > 0)
+            {
+                Transform t = childList.Dequeue();
+                if (colorType == TweenTarget.SpriteRender)
+                {
+                    SpriteRenderer m_sp = t.GetComponent<SpriteRenderer>();
+                    if (null != m_sp) spList.Add(m_sp);
+                }
+                else if (colorType == TweenTarget.UI)
+                {
+                    Graphic m_graphic = t.GetComponent<Graphic>();
+                    if (null != m_graphic) gaList.Add(m_graphic);
+                }
+                else if (colorType == TweenTarget.TextMesh)
+                {
+                    TextMesh m_textMesh = t.GetComponent<TextMesh>();
+                    if (null != m_textMesh) textMeshList.Add(m_textMesh);
+                }
+                if (includeChilds)
+                {
+                    for (int i = 0; i < t.childCount; i++)
+                    {
+                        childList.Enqueue(t.GetChild(i));
+                    }
+                }
+            }
+        }
+
+        public Color colorValue
+        {
+            get
+            {
+                return mColor;
+            }
+            set
+            {
+                SetColor(transform, value);
+                mColor = value;
+            }
+        }
+
+        protected override void OnUpdate(float factor, bool isFinished)
+        {
+            colorValue = Color.Lerp(from, to, factor);
+        }
+
+        public static uTweenColor Begin(GameObject go, float duration, float delay, Color from, Color to)
+        {
+            uTweenColor comp = uTweener.Begin<uTweenColor>(go, duration);
+            comp.from = from;
+            comp.to = to;
+            comp.delay = delay;
+
+            if (duration <= 0)
+            {
+                comp.Sample(1, true);
+                comp.enabled = false;
+            }
+            return comp;
+        }
+
+        void SetColor(Transform _transform, Color _color)
+        {
+            if (colorType == TweenTarget.SpriteRender)
+            {
+                if (spList.Count == 0)
+                {
+                    GetTweenList();
+                }
+                for (int i = 0; i < spList.Count; i++)
+                {
+                    SpriteRenderer m_sp = spList[i];
+                    m_sp.color = _color;
+                }
+            }
+            else if (colorType == TweenTarget.UI)
+            {
+                if (gaList.Count == 0)
+                {
+                    GetTweenList();
+                }
+                for (int i = 0; i < gaList.Count; i++)
+                {
+                    Graphic m_ga = gaList[i];
+                    m_ga.color = _color;
+                }
+            }
+            else if (colorType == TweenTarget.TextMesh)
+            {
+                if (textMeshList.Count == 0)
+                {
+                    GetTweenList();
+                }
+                for (int i = 0; i < textMeshList.Count; i++)
+                {
+                    TextMesh m_textMesh = textMeshList[i];
+                    m_textMesh.color = _color;
+                }
+            }
+        }
+    }
+}

+ 8 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenColor.cs.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 7b8e8bc72a1bae24ca3aeb5fc44ea84c
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 

+ 497 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenController.cs

@@ -0,0 +1,497 @@
+using UnityEngine;
+using System.Collections;
+using System.Collections.Generic;
+using uTools;
+
+public class uTweenController : MonoBehaviour 
+{
+    public Transform[] targets;
+
+    Dictionary<string, List<uTweener>> tweenerDic = new Dictionary<string, List<uTweener>>();
+
+    List<uTweener> activeTweenerList = new List<uTweener>();
+
+    int activeTweenCount = 0;
+
+    [System.NonSerialized]
+    public float duration;
+
+    [SerializeField]
+    bool playOnAwake = false;
+
+    public void Awake()
+    {
+        duration = 0;
+        tweenerDic.Clear();
+        for (int i = 0; i < targets.Length; i++)
+        {
+            if (null != targets[i])
+            {
+                uTweener[] tweeners = targets[i].GetComponents<uTweener>();
+                for (int j = 0; j < tweeners.Length; j++)
+                {
+                    AddTweener(tweeners[j]);
+                    float totalTime = tweeners[j].duration + tweeners[j].delay;
+                    if (totalTime > duration) duration = totalTime;
+                }
+            }
+            else
+            {
+                UnityEngine.Debug.Log("<color=red>" + gameObject.name + "上面uTweenController的Targets里面有空的对象!</color>");
+            }
+        }
+    }
+
+    void OnEnable()
+    {
+        if (playOnAwake && Application.isPlaying)
+        {
+            Play();
+        }
+    }
+
+    void AddTweener(uTweener tweener)
+    {
+        string tag = tweener.tag;
+        if (!tweenerDic.ContainsKey(tag))
+        {
+            tweenerDic[tag] = new List<uTweener>();
+        }
+        tweenerDic[tag].Add(tweener);
+    }
+
+    /// <summary>
+    /// 播放所有动画
+    /// </summary>
+    /// <param name="delay">延迟</param>
+    public void Play(float delay)
+    {
+        activeTweenerList.Clear();
+        foreach (var tweeners in tweenerDic)
+        {
+            for (int i = 0; i < tweeners.Value.Count; i++)
+            {
+                uTweener tweener = tweeners.Value[i];
+                if (!tweener.gameObject.activeSelf)
+                {
+                    continue;
+                }
+                tweener.delay = delay;
+                tweener.ResetToBeginning();
+                tweener.PlayForward();
+                if (tweener.updateStyle == uTweener.UpdateStyle.Other)
+                {
+                    activeTweenerList.Add(tweener);
+                }
+            }
+        }
+        activeTweenCount = activeTweenerList.Count;
+    }
+
+    public void PlayForward(bool isNeedReset)
+    {
+        activeTweenerList.Clear();
+        foreach (var tweeners in tweenerDic)
+        {
+            for (int i = 0; i < tweeners.Value.Count; i++)
+            {
+                uTweener tweener = tweeners.Value[i];
+                if (!tweener.gameObject.activeSelf)
+                {
+                    continue;
+                }
+                if (isNeedReset)
+                {
+                    tweener.ResetToBeginning();
+                }
+                tweener.PlayForward();
+                if (tweener.updateStyle == uTweener.UpdateStyle.Other)
+                {
+                    activeTweenerList.Add(tweener);
+                }
+            }
+        }
+        activeTweenCount = activeTweenerList.Count;
+    }
+
+    /// <summary>
+    /// 播放所有动画
+    /// </summary>
+    public void Play()
+    {
+        activeTweenerList.Clear();
+        foreach (var tweeners in tweenerDic)
+        {
+            for (int i = 0; i < tweeners.Value.Count; i++)
+            {
+                uTweener tweener = tweeners.Value[i];
+                if (!tweener.gameObject.activeSelf)
+                {
+                    continue;
+                }
+                tweener.ResetToBeginning();
+                tweener.PlayForward();
+                if (tweener.updateStyle == uTweener.UpdateStyle.Other)
+                {
+                    activeTweenerList.Add(tweener);   
+                }                
+            }
+        }
+        activeTweenCount = activeTweenerList.Count;
+    }
+
+    public void PlayReverse()
+    {
+        PlayReverse(true);
+    }
+
+    public void PlayReverse(string tag)
+    {
+        activeTweenerList.Clear();
+        for (int i = 0, j = tweenerDic[tag].Count; i < j; i++)
+        {
+            uTweener tweener = tweenerDic[tag][i];
+            if (!tweener.gameObject.activeSelf)
+            {
+                continue;
+            }
+            tweener.PlayReverse();
+            if (tweener.updateStyle == uTweener.UpdateStyle.Other)
+            {
+                activeTweenerList.Add(tweener);
+            }
+        }
+        activeTweenCount = activeTweenerList.Count;
+    }
+
+    /// <summary>
+    /// 反向播放所有动画
+    /// </summary>
+    /// <param name="isNeedReset">是否需要重置到反向开始时的位置</param>
+    public void PlayReverse(bool isNeedReset)
+    {
+        activeTweenerList.Clear();
+        foreach (var tweeners in tweenerDic)
+        {
+            for (int i = 0; i < tweeners.Value.Count; i++)
+            {
+                uTweener tweener = tweeners.Value[i];
+                if (!tweener.gameObject.activeSelf)
+                {
+                    continue;
+                }
+                if (isNeedReset)
+                {
+                    tweener.ResetToEnd();
+                }
+                tweener.PlayReverse();
+                if (tweener.updateStyle == uTweener.UpdateStyle.Other)
+                {
+                    activeTweenerList.Add(tweener);
+                }                
+            }
+        }
+        activeTweenCount = activeTweenerList.Count;
+    }
+
+    [ContextMenu("ResetToBeginning")]
+	public void ResetToBeginning()
+	{
+		foreach (var tweeners in tweenerDic)
+		{
+			for (int i = 0; i < tweeners.Value.Count; i++)
+			{
+				uTweener tweener = tweeners.Value[i];
+				tweener.ResetToBeginning();
+			}
+		}
+	}
+
+	public void ResetToBeginning(string tag)
+	{
+		if (tweenerDic.ContainsKey(tag))
+		{
+			List<uTweener> list = tweenerDic[tag];
+			for (int i = 0; i < list.Count; i++)
+			{
+				uTweener tweener = list[i];
+				tweener.ResetToBeginning();
+			}
+		}
+	}
+
+    [ContextMenu("ResetToEnd")]
+	public void ResetToEnd()
+	{
+		foreach (var tweeners in tweenerDic)
+		{
+			for (int i = 0; i < tweeners.Value.Count; i++)
+			{
+				uTweener tweener = tweeners.Value[i];
+				tweener.ResetToEnd();
+			}
+		}
+	}
+
+	public void ResetToEnd(string tag)
+	{
+		if (tweenerDic.ContainsKey(tag))
+		{
+			List<uTweener> list = tweenerDic[tag];
+			for (int i = 0; i < list.Count; i++)
+			{
+				uTweener tweener = list[i];
+				tweener.ResetToEnd();
+			}
+		}
+	}
+
+    /// <summary>
+    /// 播放指定名字的动画
+    /// </summary>
+    /// <param name="tag"></param>
+    public void Play(string tag, float delay)
+    {
+        if (!tweenerDic.ContainsKey(tag))
+        {
+            UnityEngine.Debug.Log(string.Format("找不到{0}上的{1}动画!", gameObject.name, tag));
+            return;
+        }
+        else 
+        {
+            activeTweenerList.Clear();
+            for (int i = 0, j = tweenerDic[tag].Count; i < j; i++)
+            {
+                uTweener tweener = tweenerDic[tag][i];
+                if (!tweener.gameObject.activeSelf)
+                {
+                    continue;
+                }
+                tweener.delay = delay;
+                tweener.ResetToBeginning();
+                tweener.PlayForward();
+                if (tweener.updateStyle == uTweener.UpdateStyle.Other)
+                {
+                    activeTweenerList.Add(tweener);
+                }                
+            }
+            activeTweenCount = activeTweenerList.Count;
+        }
+    }
+
+    public void Play(string tag)
+    {
+        if (!tweenerDic.ContainsKey(tag))
+        {
+            UnityEngine.Debug.Log(string.Format("找不到{0}上的{1}动画!", gameObject.name, tag));
+            return;
+        }
+        else
+        {
+            activeTweenerList.Clear();
+            for (int i = 0, j = tweenerDic[tag].Count; i < j; i++)
+            {
+                uTweener tweener = tweenerDic[tag][i];
+                if (!tweener.gameObject.activeSelf)
+                {
+                    continue;
+                }
+                tweener.ResetToBeginning();
+                tweener.PlayForward();
+                if (tweener.updateStyle == uTweener.UpdateStyle.Other)
+                {
+                    activeTweenerList.Add(tweener);
+                }
+            }
+            activeTweenCount = activeTweenerList.Count;
+        }
+    }
+
+	public void PlayWithoutActive()
+	{
+		activeTweenerList.Clear();
+		foreach (var tweeners in tweenerDic)
+		{
+			for (int i = 0; i < tweeners.Value.Count; i++)
+			{
+				uTweener tweener = tweeners.Value[i];
+				tweener.ResetToBeginning();
+				tweener.PlayForward();
+				if (tweener.updateStyle == uTweener.UpdateStyle.Other)
+				{
+					activeTweenerList.Add(tweener);
+				}
+			}
+		}
+		activeTweenCount = activeTweenerList.Count;
+	}
+
+	public void PlayWithoutActive(string tag)
+	{
+		if (!tweenerDic.ContainsKey(tag))
+		{
+			UnityEngine.Debug.Log(string.Format("找不到{0}上的{1}动画!", gameObject.name, tag));
+			return;
+		}
+		else
+		{
+			activeTweenerList.Clear();
+			for (int i = 0, j = tweenerDic[tag].Count; i < j; i++)
+			{
+				uTweener tweener = tweenerDic[tag][i];
+				tweener.ResetToBeginning();
+				tweener.PlayForward();
+				if (tweener.updateStyle == uTweener.UpdateStyle.Other)
+				{
+					activeTweenerList.Add(tweener);
+				}
+			}
+			activeTweenCount = activeTweenerList.Count;
+		}
+	}
+
+    public void Stop()
+    {
+        activeTweenerList.Clear();
+        foreach (var item in tweenerDic)
+        {
+            for (int i = 0; i < item.Value.Count; i++)
+            {
+                item.Value[i].enabled = false;
+            }
+        }
+        activeTweenCount = 0;
+    }
+
+    public void Stop(string tag)
+    {
+        if (!tweenerDic.ContainsKey(tag))
+        {
+            UnityEngine.Debug.Log(string.Format("找不到{0}上的{1}动画!", gameObject.name, tag));
+            return;
+        }
+        else
+        {
+            activeTweenerList.Clear();
+            for (int i = 0, j = tweenerDic[tag].Count; i < j; i++)
+            {
+                uTweener tweener = tweenerDic[tag][i];
+                tweener.enabled = false;
+            }
+            activeTweenCount = 0;
+        }
+    }
+
+    public void SetTweenState(bool state)
+    {
+        foreach (var list in tweenerDic.Values)
+        {
+            foreach (var tween in list)
+            {
+                tween.enabled = state;
+            }
+        }
+    }
+
+
+    [System.NonSerialized]
+    public string animName;
+
+    [SerializeField]
+    float m_progress;
+
+    float currentTime;
+
+    [System.NonSerialized]
+    public string[] names;
+
+    [System.NonSerialized]
+    public int currentIndex = 0;
+
+    [System.NonSerialized]
+    public float playBackSpeed = 1;
+
+    public float Progress
+    {
+        get
+        {
+            return m_progress;
+        }
+        set
+        {
+            m_progress = value;
+            currentTime = duration * m_progress;
+            SetAnim();
+        }
+    }
+
+    void SetAnim()
+    {
+        if (null == animName) animName = allName;
+        if (animName != allName)
+        {
+            if(tweenerDic.ContainsKey(animName))
+            {
+                for (int i = 0; i < tweenerDic[animName].Count; i++)
+                {
+                    uTweener tweener = tweenerDic[animName][i];
+                    if (!tweener.gameObject.activeSelf)
+                    {
+                        continue;
+                    }
+                    float delay = tweener.delay;
+                    if (currentTime < delay) continue;
+                    float duration = tweener.duration;
+                    float factor = (currentTime - delay) / duration;
+                    if (factor > 1) continue;
+                    tweener.tweenFactor = factor;
+                    if (tweener.enabled)
+                    {
+                        tweener.gameObject.SetActive(false);
+                        tweener.gameObject.SetActive(true);
+                    }
+                }
+            }
+        }
+        else
+        {
+            foreach (var item in tweenerDic)
+            {
+                for (int i = 0; i < item.Value.Count; i++)
+                {
+                    uTweener tweener = item.Value[i];
+                    if (!tweener.gameObject.activeSelf)
+                    {
+                        continue;
+                    }
+                    float delay = tweener.delay;
+                    if (currentTime < delay) continue;
+                    float duration = tweener.duration;
+                    float factor = (currentTime - delay) / duration;
+                    if (factor > 1) continue;
+                    tweener.tweenFactor = factor;
+                    if (tweener.enabled)
+                    {
+                        tweener.gameObject.SetActive(false);
+                        tweener.gameObject.SetActive(true);
+                    }
+                }
+            }
+        }
+    }
+
+    const string allName = "All";
+
+    public string[] GetAnimNames()
+    {
+        string[] names = new string[tweenerDic.Count + 1];
+        names[0] = allName;
+        int currentIndex = 1;
+        foreach (var item in tweenerDic)
+        {
+            names[currentIndex] = item.Key;
+            currentIndex++;
+        }
+        return names;
+    }
+}

+ 12 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenController.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 661819a1ea1297e4c8982a311b3be747
+timeCreated: 1457399859
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 50 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenCountDown.cs

@@ -0,0 +1,50 @@
+using UnityEngine;
+using System.Collections;
+using UnityEngine.UI;
+using UnityEngine.Events;
+
+namespace uTools
+{
+    public class uTweenCountDown : uTweenValue
+    {
+        public int start;
+
+        public int end;
+
+        public UnityEvent onValueChange = new UnityEvent();
+
+        private Text mText;
+        public Text cacheText
+        {
+            get
+            {
+                if (mText == null)
+                {
+                    mText = GetComponent<Text>();
+                }
+                return mText;
+            }
+        }
+
+        int previousValue;
+
+        protected override void Awake()
+        {
+            base.Awake();
+            previousValue = int.MinValue;
+        }
+
+        protected override void ValueUpdate(float value, bool isFinished)
+        {            
+            int int_value = Mathf.FloorToInt(value);
+            if (int_value > start) int_value = start;
+            if (int_value < end) int_value = end;           
+            cacheText.text = int_value.ToString();
+            if (int_value != previousValue)
+            {
+                onValueChange.Invoke();
+                previousValue = int_value;
+            }
+        }
+    }
+}

+ 12 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenCountDown.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: df5f444e49a90594dadd0f58286fac77
+timeCreated: 1469182704
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 38 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenFinishEventLua.cs

@@ -0,0 +1,38 @@
+using UnityEngine;
+using System.Collections;
+using UnityEngine.Events;
+
+namespace uTools
+{
+    public class uTweenFinishEventLua : MonoBehaviour
+    {
+        string m_callBack = "";
+
+        uTweener tweener;
+
+        void Awake()
+        {
+            tweener = GetComponent<uTweener>();
+        }
+
+        public void SetOnFinishCallBack(string callBack)
+        {
+            m_callBack = callBack;
+            tweener.AddOnFinishEvent(OnFinish);
+        }
+
+        void OnFinish()
+        {
+            if (!string.IsNullOrEmpty(m_callBack))
+            {
+                //G.LuaManager.CallLuaFunction(m_callBack);
+            }
+        }
+
+        public void RemoveOnFinishCallBack()
+        {
+            m_callBack = string.Empty;
+            tweener.RemoveFinishEvent(OnFinish);
+        }
+    }
+}

+ 12 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenFinishEventLua.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: a121d5f12f093c54e9a75ec567d038f4
+timeCreated: 1498460978
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 43 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenMaterialParam.cs

@@ -0,0 +1,43 @@
+using UnityEngine;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace uTools
+{
+    [AddComponentMenu("uTools/Tween/Tween MaterialParam(uTools)")]
+    public class uTweenMaterialParam : uTweenValue
+    {
+        [SerializeField]
+        string paramName;
+        
+        [SerializeField]
+        List<Renderer> renders;
+
+        private bool _init = false;
+
+        private int m_nameID;
+
+        private MaterialPropertyBlock m_materialPropertyBlock;
+
+        protected override void Awake()
+        {
+            base.Awake();
+            m_materialPropertyBlock = new MaterialPropertyBlock();
+            m_nameID = Shader.PropertyToID(paramName);
+            _init = true;
+        }
+
+        protected override void ValueUpdate(float value, bool isFinished)
+        {
+            if (!_init)
+            {
+                Awake();
+            }
+            m_materialPropertyBlock.SetFloat(m_nameID, value);
+            for (int i = 0; i < renders.Count; i++)
+            {
+                renders[i].SetPropertyBlock(m_materialPropertyBlock);
+            }            
+        }
+    }
+}

+ 12 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenMaterialParam.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 01838512478e8c442b587d629a569b9f
+timeCreated: 1493188790
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 51 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenPath.cs

@@ -0,0 +1,51 @@
+using UnityEngine;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace uTools {
+	public class uTweenPath : uTweenValue {
+
+		public RectTransform target;
+		public List<Vector3> paths;
+
+		int mIndex = -1;
+		int mPathsCount = 0;
+		bool mCache = false;
+
+		void Cache () {
+			mCache = true;
+			if (paths.Count > 1) {
+				mPathsCount = paths.Count - 1;
+			}
+			if (target == null) {
+				target = GetComponent<RectTransform>();
+			}
+			from = 0;
+			to = mPathsCount;
+		}
+		
+		// Update is called once per frame
+		void Update () {
+		
+		}
+
+
+		protected override void ValueUpdate (float _factor, bool _isFinished)
+		{
+			if (!mCache) { Cache();}
+			pathIndex = Mathf.FloorToInt(_factor);
+			UnityEngine.Debug.Log(pathIndex);
+		}
+
+		int pathIndex {
+			get { return mIndex;}
+			set {
+				if (mIndex != value) {
+					mIndex = value;
+					UnityEngine.Debug.Log(target.localPosition);
+					uTweenPosition.Begin(target.gameObject, target.localPosition, paths[mIndex], duration/paths.Count).style = Style.Loop;
+				}
+			}
+		}
+	}
+}

+ 8 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenPath.cs.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: e89c203ccf0fb9742852c1423201fcd7
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 

+ 51 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenPathTrans.cs

@@ -0,0 +1,51 @@
+using UnityEngine;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace uTools {
+	public class uTweenPathTrans : uTweenValue {
+		
+		public Transform target;
+		public List<Vector3> paths;
+		
+		int mIndex = -1;
+		int mPathsCount = 0;
+		bool mCache = false;
+		
+		void Cache () {
+			mCache = true;
+			if (paths.Count > 1) {
+				mPathsCount = paths.Count - 1;
+			}
+			if (target == null) {
+				target = GetComponent<Transform>();
+			}
+			from = 0;
+			to = mPathsCount;
+		}
+		
+		protected override void ValueUpdate (float _factor, bool _isFinished)
+		{
+			if (!mCache) { Cache();}
+			pathIndex = Mathf.FloorToInt(_factor);
+		}
+		
+		int pathIndex {
+			get { return mIndex;}
+			set {
+				if (mIndex != value) {
+					mIndex = value;
+					uTweenPosition tw = uTweenPosition.Begin(target.gameObject, target.localPosition, paths[mIndex], duration/paths.Count);
+					tw.style = Style.Once;
+					tw.isRect = false;
+				}
+			}
+		}
+
+		public void ResetIndex()
+		{
+			value = 0f;
+			mIndex = -1;
+		}
+	}
+}

+ 12 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenPathTrans.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 4d612cdd214791443b6605e19d81ac6f
+timeCreated: 1465355484
+licenseType: Free
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 73 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenPosition.cs

@@ -0,0 +1,73 @@
+using UnityEngine;
+using UnityEngine.UI;
+using System.Collections;
+
+namespace uTools
+{
+    [AddComponentMenu("uTools/Tween/Tween Position(uTools)")]
+    public class uTweenPosition : uTweener
+    {
+        public Vector3 from;
+        public Vector3 to;
+
+        public bool isRect = true;
+
+        RectTransform mRectTransform;
+
+        Transform mTransform;
+
+        public RectTransform cachedRectTransform { get { if (mRectTransform == null) mRectTransform = GetComponent<RectTransform>(); return mRectTransform; } }
+
+        public Transform cachedTransform { get { if (mTransform == null) mTransform = GetComponent<Transform>(); return mTransform; } }
+        public Vector3 value
+        {
+            get
+            {
+                if (isRect)
+                    return cachedRectTransform.anchoredPosition;
+                else
+                    return cachedTransform.localPosition;
+            }
+            set
+            {
+                if (isRect)
+                    cachedRectTransform.anchoredPosition = value;
+                else
+                    cachedTransform.localPosition = value;
+            }
+        }
+
+        protected override void OnUpdate(float factor, bool isFinished)
+        {
+            value = from + factor * (to - from);
+        }
+
+        public static uTweenPosition Begin(GameObject go, Vector3 from, Vector3 to, float duration = 1f, float delay = 0f)
+        {
+            uTweenPosition comp = uTweener.Begin<uTweenPosition>(go, duration);
+            comp.from = from;
+            comp.to = to;
+            comp.duration = duration;
+            comp.delay = delay;
+            if (duration <= 0)
+            {
+                comp.Sample(1, true);
+                comp.enabled = false;
+            }
+            return comp;
+        }
+
+        [ContextMenu("Set 'From' to current value")]
+        public override void SetStartToCurrentValue() { from = value; }
+
+        [ContextMenu("Set 'To' to current value")]
+        public override void SetEndToCurrentValue() { to = value; }
+
+        [ContextMenu("Assume value of 'From'")]
+        public override void SetCurrentValueToStart() { value = from; }
+
+        [ContextMenu("Assume value of 'To'")]
+        public override void SetCurrentValueToEnd() { value = to; }
+
+    }
+}

+ 8 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenPosition.cs.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 99b92b0231913be47bf796fa6ad58777
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 

+ 75 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenPositionTarget.cs

@@ -0,0 +1,75 @@
+
+using UnityEngine;
+
+using System.Collections;
+using Base.Common;
+using uTools;
+
+public class uTweenPositionTarget : uTweener
+{
+	public Transform from;
+	public Transform to;
+
+	Transform mTransform;
+
+	private Vector3 from_pos;
+	private Vector3 to_pos;
+
+	public Transform cachedTransform { get { if (mTransform == null) mTransform = GetComponent<Transform>(); return mTransform; } }
+	public Vector3 value
+	{
+		get
+		{
+			return cachedTransform.position;
+		}
+		set
+		{
+			cachedTransform.position = value;
+		}
+	}
+
+	public void UpdateTargetPos()
+	{
+        if (from == null || to == null)
+        {
+            return;
+        }
+		from_pos = from.position;
+		to_pos = to.position;
+	}
+
+	protected override void OnUpdate(float factor, bool isFinished)
+	{
+		if (factor == 0)
+			UpdateTargetPos();
+		value = from_pos + factor * (to_pos - from_pos);
+	}
+
+	public static uTweenPositionTarget Begin(GameObject go, Transform from, Transform to, float duration = 1f, float delay = 0f)
+	{
+		uTweenPositionTarget comp = uTweener.Begin<uTweenPositionTarget>(go, duration);
+		comp.from = from;
+		comp.to = to;
+		comp.duration = duration;
+		comp.delay = delay;
+		if (duration <= 0)
+		{
+			comp.Sample(1, true);
+			comp.enabled = false;
+		}
+		return comp;
+	}
+
+	[ContextMenu("Set 'From' to current value")]
+	public override void SetStartToCurrentValue() { from_pos = value; }
+
+	[ContextMenu("Set 'To' to current value")]
+	public override void SetEndToCurrentValue() { to_pos = value; }
+
+	[ContextMenu("Assume value of 'From'")]
+	public override void SetCurrentValueToStart() { value = from_pos; }
+
+	[ContextMenu("Assume value of 'To'")]
+	public override void SetCurrentValueToEnd() { value = to_pos; }
+
+}

+ 12 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenPositionTarget.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 347d7720ca2646343801fd02910b81d9
+timeCreated: 1490692374
+licenseType: Free
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 152 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenPosition_Axis.cs

@@ -0,0 +1,152 @@
+using UnityEngine;
+using System.Collections;
+
+namespace uTools
+{
+    public class uTweenPosition_Axis : uTweenValue
+    {
+        public enum Axis
+        {
+            x,
+            y,
+            z,
+        }
+
+        public Axis axis;
+        public bool isRect = true;
+        public bool isWorldPos = false;
+        private Transform origin;
+        private Transform target;
+        public Transform Origin
+        {
+            get
+            {
+                return origin;
+            }
+            set
+            {
+                origin = value;
+                switch (axis)
+                {
+                    case Axis.x:
+                        from = origin.position.x;
+                        break;
+                    case Axis.y:
+                        from = origin.position.y;
+                        break;
+                    case Axis.z:
+                        from = origin.position.z;
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+        public Transform Target
+        {
+            get
+            {
+                return target;
+            }
+            set
+            {
+                target = value;
+                switch (axis)
+                {
+                    case Axis.x:
+                        to = target.position.x;
+                        break;
+                    case Axis.y:
+                        to = target.position.y;
+                        break;
+                    case Axis.z:
+                        to = target.position.z;
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+
+        RectTransform mRectTransform;
+
+        Transform mTransform;
+        public RectTransform cachedRectTransform { get { if (mRectTransform == null) mRectTransform = GetComponent<RectTransform>(); return mRectTransform; } }
+
+        public Transform cachedTransform { get { if (mTransform == null) mTransform = GetComponent<Transform>(); return mTransform; } }
+        public Vector3 value
+        {
+            get
+            {
+                if (isWorldPos)
+                    return cachedTransform.position;
+                else if (isRect)
+                    return cachedRectTransform.anchoredPosition;
+                else
+                    return cachedTransform.localPosition;
+            }
+            set
+            {
+                if (isWorldPos)
+                    cachedTransform.position = value;
+                else if (isRect)
+                    cachedRectTransform.anchoredPosition = value;
+                else
+                    cachedTransform.localPosition = value;
+            }
+        }
+
+        protected override void ValueUpdate(float value, bool isFinished)
+        {
+            base.ValueUpdate(value, isFinished);
+            if (origin)
+            {
+                switch (axis)
+                {
+                    case Axis.x:
+                        from = origin.position.x;
+                        break;
+                    case Axis.y:
+                        from = origin.position.y;
+                        break;
+                    case Axis.z:
+                        from = origin.position.z;
+                        break;
+                    default:
+                        break;
+                }
+            }
+            if (target)
+            {
+                switch (axis)
+                {
+                    case Axis.x:
+                        to = target.position.x;
+                        break;
+                    case Axis.y:
+                        to = target.position.y;
+                        break;
+                    case Axis.z:
+                        to = target.position.z;
+                        break;
+                    default:
+                        break;
+                }
+            }
+            switch (axis)
+            {
+                case Axis.x:
+                    this.value = new Vector3(value, this.value.y, this.value.z);
+                    break;
+                case Axis.y:
+                    this.value = new Vector3(this.value.x, value, this.value.z);
+                    break;
+                case Axis.z:
+                    this.value = new Vector3(this.value.x, this.value.y, value);
+                    break;
+                default:
+                    break;
+            }
+        }
+    }
+}

+ 12 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenPosition_Axis.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: e92d9c644300f10468b7b7713d182632
+timeCreated: 1468976855
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 99 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenRotation.cs

@@ -0,0 +1,99 @@
+using UnityEngine;
+using UnityEngine.UI;
+using System.Collections;
+
+namespace uTools
+{
+    [AddComponentMenu("uTools/Tween/Tween Rotation(uTools)")]
+    public class uTweenRotation : uTweener
+    {
+        public Vector3 from;
+        public Vector3 to;
+
+        public bool isLocalRotation = true;
+
+        Transform mTransfrom;
+
+        public Transform cacheTransfrom
+        {
+            get
+            {
+                if (mTransfrom == null)
+                {
+                    mTransfrom = transform;
+                }
+                return mTransfrom;
+            }
+        }
+
+        public Quaternion value
+        {
+            get
+            {
+                if (isLocalRotation)
+                {
+                    return cacheTransfrom.localRotation;
+                }
+                else
+                {
+                    return cacheTransfrom.rotation;
+                }
+            }
+            set
+            {
+                if (isLocalRotation)
+                {
+                    cacheTransfrom.localRotation = value;
+                }
+                else
+                {
+                    cacheTransfrom.rotation = value;
+                }
+            }
+        }
+
+        protected override void OnUpdate(float _factor, bool _isFinished)
+        {
+            value = Quaternion.Euler(Vector3.LerpUnclamped(from, to, _factor));
+        }
+
+        public static uTweenRotation Begin(GameObject go, Vector3 from, Vector3 to, float duration = 1f, float delay = 0f)
+        {
+            uTweenRotation comp = uTweener.Begin<uTweenRotation>(go, duration);
+            comp.from = from;
+            comp.to = to;
+            comp.duration = duration;
+            comp.delay = delay;
+            if (duration <= 0)
+            {
+                comp.Sample(1, true);
+                comp.enabled = false;
+            }
+            return comp;
+        }
+
+        [ContextMenu("Set 'From' to current value")]
+        public override void SetStartToCurrentValue()
+        {
+            from = value.eulerAngles;
+        }
+
+        [ContextMenu("Set 'To' to current value")]
+        public override void SetEndToCurrentValue()
+        {
+            to = value.eulerAngles;
+        }
+
+        [ContextMenu("Assume value of 'From'")]
+        public override void SetCurrentValueToEnd()
+        {
+            value = Quaternion.Euler(to);
+        }
+
+        [ContextMenu("Assume value of 'To'")]
+        public override void SetCurrentValueToStart()
+        {
+            value = Quaternion.Euler(from);
+        }
+    }
+}

+ 8 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenRotation.cs.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 7e0995f81183e6147b57bb9703f0b34f
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 

+ 51 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenScale.cs

@@ -0,0 +1,51 @@
+using UnityEngine;
+using UnityEngine.UI;
+using System.Collections;
+
+namespace uTools {
+	[AddComponentMenu("uTools/Tween/Tween Scale(uTools)")]
+	
+	public class uTweenScale : uTweener {
+
+		public Vector3 from = Vector3.zero;
+		public Vector3 to = Vector3.one;
+
+		Transform mTransform;
+
+        public Transform cachedTransform { get { if (mTransform == null) mTransform = GetComponent<Transform>(); return mTransform; } }
+		public Vector3 value {
+            get { return cachedTransform.localScale; }
+            set { cachedTransform.localScale = value; }
+		}
+
+		protected override void OnUpdate (float factor, bool isFinished)
+		{
+			value = from + factor * (to - from);
+		}
+
+		public static uTweenScale Begin(GameObject go, Vector3 from, Vector3 to, float duration = 1f, float delay = 0f) {
+			uTweenScale comp = uTweener.Begin<uTweenScale>(go, duration);
+			comp.from = from;
+			comp.to = to;
+			comp.duration = duration;
+			comp.delay = delay;
+			if (duration <= 0) {
+				comp.Sample(1, true);
+				comp.enabled = false;
+			}
+			return comp;
+		}
+
+        public override void SetCurrentValueToStart()
+        {
+            base.SetCurrentValueToStart();
+            value = from;
+        }
+
+        public override void SetCurrentValueToEnd()
+        {
+            base.SetCurrentValueToEnd();
+            value = to;
+        }
+	}
+}

+ 8 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenScale.cs.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 207c3eaacd40617469992a3f0e10c623
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 

+ 33 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenSize.cs

@@ -0,0 +1,33 @@
+using UnityEngine;
+using System.Collections;
+
+namespace uTools
+{
+    [AddComponentMenu("uTools/Tween/Tween Size(uTools)")]
+    public class uTweenSize : uTweener
+    {
+        public Vector2 from;
+        public Vector2 to;
+
+        RectTransform mRectTransform;
+
+        public RectTransform cachedRectTransform { get { if (mRectTransform == null) mRectTransform = GetComponent<RectTransform>(); return mRectTransform; } }
+
+        public Vector2 value
+        {
+            get
+            {
+                return cachedRectTransform.sizeDelta;
+            }
+            set
+            {
+                cachedRectTransform.sizeDelta = value;
+            }
+        }
+
+        protected override void OnUpdate(float factor, bool isFinished)
+        {
+            value = from + factor * (to - from);
+        }
+    }
+}

+ 12 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenSize.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: a4883e5ba79dca6479ee465ef067574f
+timeCreated: 1453704523
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 55 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenSlider.cs

@@ -0,0 +1,55 @@
+using UnityEngine;
+using UnityEngine.UI;
+using System.Collections;
+using Base.Common;
+
+namespace uTools {
+	[AddComponentMenu("uTools/Tween/Tween Slider(uTools)")]	
+	public class uTweenSlider : uTweenValue {
+
+		private Slider mSlider;
+		public Slider cacheSlider {
+			get {
+				mSlider = GetComponent<Slider>();
+				if (mSlider == null) {
+				}
+				return mSlider;
+			}
+		}
+
+		/// <summary>
+		/// The need carry.
+		/// when is true, value==1 equal value=0
+		/// </summary>
+		public bool NeedCarry = false;
+
+		public float sliderValue {
+			set {
+				if (NeedCarry) {
+					cacheSlider.value = (value>=1)?value - Mathf.Floor(value) : value;
+				}
+				else {
+					cacheSlider.value = (value>1)?value - Mathf.Floor(value) : value;
+				}
+			}
+		}
+
+		protected override void ValueUpdate (float value, bool isFinished)
+		{
+			this.sliderValue = value;
+		}
+
+		public static uTweenSlider Begin(Slider slider, float duration, float delay, float from, float to) {
+			uTweenSlider comp = uTweener.Begin<uTweenSlider>(slider.gameObject, duration);
+			comp.from = from;
+			comp.to = to;
+			comp.delay = delay;
+			
+			if (duration <=0) {
+				comp.Sample(1, true);
+				comp.enabled = false;
+			}
+			return comp;
+		}
+	}
+}

+ 8 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenSlider.cs.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 22d88c5d5d8021944b6e61b461ee6b78
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 

+ 82 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenSprite.cs

@@ -0,0 +1,82 @@
+using UnityEngine;
+using System.Collections;
+using UnityEngine.UI;
+
+namespace uTools
+{
+    public class uTweenSprite : uTweenValue
+    {
+        public enum SpriteType
+        {
+            SpriteRenderer,
+            Image,
+        }
+
+        public SpriteType spriteType;
+
+        public Sprite[] sprites;
+
+        SpriteRenderer m_spriteRenderer;
+
+        SpriteRenderer SpriteRenderer
+        {
+            get
+            {
+                if (null == m_spriteRenderer)
+                {
+                    m_spriteRenderer = GetComponent<SpriteRenderer>();
+                }
+                return m_spriteRenderer;
+            }
+        }
+
+        Image m_image;
+
+        Image Image
+        {
+            get
+            {
+                if (null == m_image)
+                {
+                    m_image = GetComponent<Image>();
+                }
+                return m_image;
+            }
+        }
+
+        void Awake()
+        {
+            if (spriteType == SpriteType.SpriteRenderer)
+            {
+                m_spriteRenderer = GetComponent<SpriteRenderer>();
+            }
+            else
+            {
+                m_image = GetComponent<Image>();
+            }            
+        }
+
+        int currentIndex = -1;
+
+        protected override void ValueUpdate(float value, bool isFinished)
+        {
+            int index = Mathf.FloorToInt(value);
+            int length = sprites.Length;
+            if (index >= length) index = length - 1;
+            if (index <= 0) index = 0;
+            if (currentIndex != index)
+            {
+                if (spriteType == SpriteType.SpriteRenderer)
+                {
+                    SpriteRenderer.sprite = sprites[index];
+                }
+                else
+                {
+                    Image.sprite = sprites[index];
+                    Image.SetNativeSize();
+                }
+                currentIndex = index;
+            }
+        }
+    }
+}

+ 12 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenSprite.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: cc843b37162947642b4e5a104cc046ea
+timeCreated: 1467961181
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 52 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenText.cs

@@ -0,0 +1,52 @@
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace uTools
+{
+    [AddComponentMenu("uTools/Tween/Tween Text(uTools)")]
+
+    public class uTweenText : uTweenValue
+    {
+        private Text mText;
+        public Text cacheText
+        {
+            get
+            {
+                if (mText == null)
+                {
+                    mText = GetComponent<Text>();
+                }
+                return mText;
+            }
+        }
+
+        System.Text.StringBuilder sb = new System.Text.StringBuilder(256);
+
+        /// <summary>
+        /// number after the digit point
+        /// </summary>
+        public int digits;
+
+        protected override void ValueUpdate(float value, bool isFinished)
+        {
+            sb.Length = 0;
+            sb.Append(System.Math.Round(value, digits));
+            cacheText.text = sb.ToString();
+        }
+
+        public static uTweenText Begin(Text label, float duration, float delay, float from, float to)
+        {
+            uTweenText comp = Begin<uTweenText>(label.gameObject, duration);
+            comp.from = from;
+            comp.to = to;
+            comp.delay = delay;
+
+            if (duration <= 0)
+            {
+                comp.Sample(1, true);
+                comp.enabled = false;
+            }
+            return comp;
+        }
+    }
+}

+ 8 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenText.cs.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: e82803334a828044ab4a384355801061
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 

+ 50 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenTextMeshAlpha.cs

@@ -0,0 +1,50 @@
+using UnityEngine;
+using System.Collections;
+
+namespace uTools
+{
+    public class uTweenTextMeshAlpha : uTweenValue
+    {
+        TextMesh m_textMesh;
+
+        TextMesh textMesh
+        {
+            get
+            {
+                if (null == m_textMesh)
+                {
+                    m_textMesh = GetComponent<TextMesh>();
+                }
+                return m_textMesh;
+            }
+        }
+
+        float m_alpha;
+
+        float alpha
+        {
+            get
+            {
+                return m_alpha;
+            }
+            set
+            {
+                SetAlpha(textMesh, value);
+                m_alpha = value;
+            }
+        }
+
+        protected override void ValueUpdate(float value, bool isFinished)
+        {
+            alpha = value;
+        }
+
+        void SetAlpha(TextMesh _text, float _alpha)
+        {
+            Color c = Color.white;
+            c = _text.color;
+            c.a = _alpha;
+            _text.color = c;
+        }
+    }
+}

+ 12 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenTextMeshAlpha.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 67fab5246cf2f16419ef9e1e7b346644
+timeCreated: 1467947431
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 63 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenTimer.cs

@@ -0,0 +1,63 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace uTools
+{
+    public class uTweenTimer : uTweenValue
+    {
+        private Text m_text;
+
+        public Text Text
+        {
+            get
+            {
+                if (null == m_text)
+                {
+                    m_text = GetComponent<Text>();
+                }
+                return m_text;
+            }
+        }
+
+        [SerializeField]
+        string format;
+
+        [SerializeField]
+        int digitSize;
+
+        System.Text.StringBuilder sb = new System.Text.StringBuilder(256);
+
+        const string size1 = ":<size=";
+
+        const string size2 = ">";
+
+        const string size3 = "</size>";
+
+        const string zero = "0";
+
+        protected override void ValueUpdate(float value, bool isFinished)
+        {
+            string[] result = value.ToString(format).Split('.');
+            sb.Length = 0;
+            if (value < 10)
+            {
+                sb.Append(zero);
+            }
+            sb.Append(result[0]);
+            sb.Append(size1);
+            sb.Append(digitSize);
+            sb.Append(size2);
+            sb.Append(result[1]);
+            sb.Append(size3);            
+            Text.text = sb.ToString();
+        }
+
+        public void SetValue(float value)
+        {
+            this.value = value;
+            ValueUpdate(value, false);
+        }
+    }
+}

+ 12 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenTimer.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 3c8d5c97d9356234197ab220ee96e261
+timeCreated: 1522474065
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 35 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenValue.cs

@@ -0,0 +1,35 @@
+namespace uTools
+{
+    public class uTweenValue : uTweener
+    {
+
+        public float from;
+        public float to;
+
+        float mValue;
+
+        public float value
+        {
+            get
+            {
+                return mValue;
+            }
+            set
+            {
+                mValue = value;
+            }
+        }
+
+        virtual protected void ValueUpdate(float value, bool isFinished)
+        {
+
+        }
+
+        protected override void OnUpdate(float factor, bool isFinished)
+        {
+            value = from + factor * (to - from);
+            ValueUpdate(value, isFinished);
+            //UnityEngine.Debug.Log("factor" + factor + " value" + value + " time" + Time.realtimeSinceStartup);
+        }
+    }
+}

+ 8 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenValue.cs.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 746399a9ab3868c46bd20251e338346a
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 

+ 64 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenWorldPosition.cs

@@ -0,0 +1,64 @@
+using UnityEngine;
+using UnityEngine.UI;
+using System.Collections;
+
+namespace uTools
+{
+    public class uTweenWorldPosition : uTweener
+    {
+        public Vector3 from;
+        public Vector3 to;
+        
+        RectTransform mRectTransform;
+
+        Transform mTransform;
+
+        public RectTransform cachedRectTransform { get { if (mRectTransform == null) mRectTransform = GetComponent<RectTransform>(); return mRectTransform; } }
+
+        public Transform cachedTransform { get { if (mTransform == null) mTransform = GetComponent<Transform>(); return mTransform; } }
+        public Vector3 value
+        {
+            get
+            {
+                return cachedTransform.position;
+            }
+            set
+            {
+                cachedTransform.position = value;
+            }
+        }
+
+        protected override void OnUpdate(float factor, bool isFinished)
+        {
+            value = from + factor * (to - from);
+        }
+
+        public static uTweenPosition Begin(GameObject go, Vector3 from, Vector3 to, float duration = 1f, float delay = 0f)
+        {
+            uTweenPosition comp = uTweener.Begin<uTweenPosition>(go, duration);
+            comp.from = from;
+            comp.to = to;
+            comp.duration = duration;
+            comp.delay = delay;
+            if (duration <= 0)
+            {
+                comp.Sample(1, true);
+                comp.enabled = false;
+            }
+            return comp;
+        }
+
+        [ContextMenu("Set 'From' to current value")]
+        public override void SetStartToCurrentValue() { from = value; }
+
+        [ContextMenu("Set 'To' to current value")]
+        public override void SetEndToCurrentValue() { to = value; }
+
+        [ContextMenu("Assume value of 'From'")]
+        public override void SetCurrentValueToStart() { value = from; }
+
+        [ContextMenu("Assume value of 'To'")]
+        public override void SetCurrentValueToEnd() { value = to; }
+
+    }
+}

+ 8 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenWorldPosition.cs.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 7627e69825bcbd143995a3e996dfce6f
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 

+ 51 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenWorldPosition_Axis.cs

@@ -0,0 +1,51 @@
+using UnityEngine;
+using System.Collections;
+
+namespace uTools
+{
+    public class uTweenWorldPosition_Axis : uTweenValue
+    {
+        public enum Axis
+        {
+            x,
+            y,
+            z,
+        }
+
+        public Axis axis;
+        
+        Transform mTransform;
+
+        public Transform cachedTransform { get { if (mTransform == null) mTransform = GetComponent<Transform>(); return mTransform; } }
+        public Vector3 value
+        {
+            get
+            {
+                return cachedTransform.position;
+            }
+            set
+            {
+                cachedTransform.position = value;
+            }
+        }
+
+        protected override void ValueUpdate(float value, bool isFinished)
+        {
+            base.ValueUpdate(value, isFinished);
+            switch (axis)
+            {
+                case Axis.x:
+                    this.value = new Vector3(value, this.value.y, this.value.z);
+                    break;
+                case Axis.y:
+                    this.value = new Vector3(this.value.x, value, this.value.z);
+                    break;
+                case Axis.z:
+                    this.value = new Vector3(this.value.x, this.value.y, value);
+                    break;
+                default:
+                    break;
+            }
+        }
+    }
+}

+ 12 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweenWorldPosition_Axis.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: f725511cd23f9774a8589e95f559f0a2
+timeCreated: 1468976855
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 423 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweener.cs

@@ -0,0 +1,423 @@
+using UnityEngine;
+using System.Collections;
+using System.Collections.Generic;
+using Base.Common;
+using UnityEngine.Events;
+using UnityEngine.EventSystems;
+
+/// <summary>
+/// Base of tween.
+/// </summary>
+
+namespace uTools
+{
+    public abstract class uTweener : MonoBehaviour
+    {
+        static public uTweener current;
+
+        public enum Style
+        {
+            Once,
+            Loop,
+            PingPong,
+        }
+
+        public enum UpdateStyle
+        {
+            Update,
+            FixedUpdate,
+            Other,
+        }
+
+        public UpdateStyle updateStyle = UpdateStyle.Update;
+
+        public EaseType method = EaseType.linear;
+        public Style style = Style.Once;
+        public AnimationCurve animationCurve = new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f));
+        public bool ignoreTimeScale = false;
+        public float delay = 0f;
+        public float duration = 1f;
+
+        [HideInInspector]
+        public bool steeperCurves = false;
+
+        public new string tag = "";
+        public int tweenGroup = 0;
+        public UnityEvent onFinished = new UnityEvent();
+
+        [HideInInspector]
+        public GameObject eventReceiver;
+        [HideInInspector]
+        public string callWhenFinished;
+
+        [Range(0, 1)]
+        public float startFactor;
+
+        bool mStarted = false;
+        float mStartTime = 0f;
+        float mDuration = 0f;
+        float mAmountPerDelta = 1000f;
+        float mFactor = 0f;
+
+        /// <summary>
+        /// Amount advanced per delta time.
+        /// </summary>
+
+        public float amountPerDelta
+        {
+            get
+            {
+                if (mDuration != duration)
+                {
+                    mDuration = duration;
+                    mAmountPerDelta = Mathf.Abs((duration > 0f) ? 1f / duration : 1000f) * Mathf.Sign(mAmountPerDelta);
+                }
+                return mAmountPerDelta;
+            }
+        }
+
+        public float tweenFactor
+        {
+            get
+            {
+                return mFactor;
+            }
+            set
+            {
+                mFactor = Mathf.Clamp01(value);
+                Sample(mFactor, false);
+            }
+        }
+
+        public Direction direction { get { return amountPerDelta < 0f ? Direction.Reverse : Direction.Forward; } }
+
+        void ResetTweener()
+        {
+            if (!mStarted)
+            {
+                SetStartToCurrentValue();
+                SetEndToCurrentValue();
+            }
+        }
+
+        protected virtual void Awake()
+        {
+            mFactor = startFactor;
+        }
+
+        void Update()
+        {
+            if (updateStyle != UpdateStyle.Update) return;
+
+            float delta = ignoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime;
+            float time = ignoreTimeScale ? Time.unscaledTime : Time.time;
+
+            if (!mStarted)
+            {
+                mStarted = true;
+                mStartTime = time + delay;
+            }
+
+            if (time < mStartTime) return;
+
+            // Advance the sampling factor
+            mFactor += amountPerDelta * delta;
+
+            // Loop style simply resets the play factor after it exceeds 1.
+            if (style == Style.Loop)
+            {
+                if (mFactor > 1f)
+                {
+                    mFactor -= Mathf.Floor(mFactor);
+                }
+            }
+            else if (style == Style.PingPong)
+            {
+                // Ping-pong style reverses the direction
+                if (mFactor > 1f)
+                {
+                    mFactor = 1f - (mFactor - Mathf.Floor(mFactor));
+                    mAmountPerDelta = -mAmountPerDelta;
+                }
+                else if (mFactor < 0f)
+                {
+                    mFactor = -mFactor;
+                    mFactor -= Mathf.Floor(mFactor);
+                    mAmountPerDelta = -mAmountPerDelta;
+                }
+            }
+
+            // If the factor goes out of range and this is a one-time tweening operation, disable the script
+            if ((style == Style.Once) && (duration == 0f || mFactor > 1f || mFactor < 0f))
+            {
+                mFactor = Mathf.Clamp01(mFactor);
+                Sample(mFactor, true);
+                enabled = false;
+
+                if (current != this)
+                {
+                    uTweener before = current;
+                    current = this;
+
+                    if (onFinished != null)
+                    {
+                        onFinished.Invoke();
+                    }
+
+                    // Deprecated legacy functionality support
+                    if (eventReceiver != null && !string.IsNullOrEmpty(callWhenFinished))
+                        eventReceiver.SendMessage(callWhenFinished, this, SendMessageOptions.DontRequireReceiver);
+
+                    current = before;
+                }
+            }
+            else Sample(mFactor, false);
+        }
+
+        void FixedUpdate()
+        {
+            if (updateStyle != UpdateStyle.FixedUpdate) return;
+
+            float delta = ignoreTimeScale ? Time.deltaTime / Time.timeScale : Time.fixedDeltaTime;
+            float time = 0;
+            if (ignoreTimeScale)
+            {
+                time = Time.unscaledTime;
+            }
+            else
+            {
+                time = Time.fixedTime;
+            }
+            //ignoreTimeScale ? Time.unscaledTime : Time.fixedTime;
+
+            if (!mStarted)
+            {
+                mStarted = true;
+                mStartTime = time + delay;
+            }
+
+            if (time < mStartTime) return;
+
+            // Advance the sampling factor
+            mFactor += amountPerDelta * delta;
+
+            // Loop style simply resets the play factor after it exceeds 1.
+            if (style == Style.Loop)
+            {
+                if (mFactor > 1f)
+                {
+                    mFactor -= Mathf.Floor(mFactor);
+                }
+            }
+            else if (style == Style.PingPong)
+            {
+                // Ping-pong style reverses the direction
+                if (mFactor > 1f)
+                {
+                    mFactor = 1f - (mFactor - Mathf.Floor(mFactor));
+                    mAmountPerDelta = -mAmountPerDelta;
+                }
+                else if (mFactor < 0f)
+                {
+                    mFactor = -mFactor;
+                    mFactor -= Mathf.Floor(mFactor);
+                    mAmountPerDelta = -mAmountPerDelta;
+                }
+            }
+
+            // If the factor goes out of range and this is a one-time tweening operation, disable the script
+            if ((style == Style.Once) && (duration == 0f || mFactor > 1f || mFactor < 0f))
+            {
+                mFactor = Mathf.Clamp01(mFactor);
+                Sample(mFactor, true);
+                enabled = false;
+
+                if (current != this)
+                {
+                    uTweener before = current;
+                    current = this;
+
+                    if (onFinished != null)
+                    {
+                        onFinished.Invoke();
+                    }
+
+                    // Deprecated legacy functionality support
+                    if (eventReceiver != null && !string.IsNullOrEmpty(callWhenFinished))
+                        eventReceiver.SendMessage(callWhenFinished, this, SendMessageOptions.DontRequireReceiver);
+
+                    current = before;
+                }
+            }
+            else Sample(mFactor, false);
+        }
+
+        public void SetOnFinished(UnityEvent finishedCallBack)
+        { 
+            onFinished = finishedCallBack; 
+        }                
+
+        public void AddOnFinishEvent(UnityAction finishEvent)
+        {
+            onFinished.AddListener(finishEvent);
+        }
+
+        public void RemoveFinishEvent(UnityAction finishEvent)
+        {
+            onFinished.RemoveListener(finishEvent);
+        }
+
+        public void RemoveAllFinishEvent()
+        {
+            onFinished.RemoveAllListeners();
+        }
+
+        void OnDisable() { mStarted = false; }
+
+        /// <summary>
+        /// Sample the tween at the specified factor.
+        /// </summary>
+
+        public virtual void Sample(float factor, bool isFinished)
+        {
+            // Calculate the sampling value
+            float val = Mathf.Clamp01(factor);
+
+            val = (method == EaseType.none) ? animationCurve.Evaluate(val) : EaseManager.EasingFromType(0, 1, val, method);
+
+            // Call the virtual update
+            OnUpdate((animationCurve != null) ? animationCurve.Evaluate(val) : val, isFinished);
+        }
+
+        /// <summary>
+        /// Play the tween forward.
+        /// </summary>
+
+        public void PlayForward() { Play(true); }
+
+        /// <summary>
+        /// Play the tween in reverse.
+        /// </summary>
+
+        public void PlayReverse() { Play(false); }
+
+        /// <summary>
+        /// Manually activate the tweening process, reversing it if necessary.
+        /// </summary>
+
+        public void Play(bool forward)
+        {
+            mAmountPerDelta = Mathf.Abs(amountPerDelta);
+            if (!forward) mAmountPerDelta = -mAmountPerDelta;
+            if (updateStyle == UpdateStyle.Update)
+            {
+                Update();
+                enabled = true;
+            }
+            else if (updateStyle == UpdateStyle.FixedUpdate && Time.timeScale > 0)//防止timescale等于0的时候出现错误//
+            {
+                FixedUpdate();
+                enabled = true;
+            }
+            else if (updateStyle == UpdateStyle.Other && Time.timeScale > 0)
+            {
+                //MyFixedUpdate();
+                // MySetActive(true);
+            }
+        }
+
+        /// <summary>
+        /// Manually reset the tweener's state to the beginning.
+        /// If the tween is playing forward, this means the tween's start.
+        /// If the tween is playing in reverse, this means the tween's end.
+        /// </summary>
+
+        public void ResetToBeginning()
+        {
+            mStarted = false;
+            mFactor = 0f;//(amountPerDelta < 0f) ? 1f : 0f;
+            Sample(mFactor, false);
+        }
+
+        public void ResetToEnd()
+        {
+            mStarted = false;
+            mFactor = 1f;
+            Sample(mFactor, false);
+        }
+
+        /// <summary>
+        /// Manually start the tweening process, reversing its direction.
+        /// </summary>
+
+        public void Toggle()
+        {
+            if (mFactor > 0f)
+            {
+                mAmountPerDelta = -amountPerDelta;
+            }
+            else
+            {
+                mAmountPerDelta = Mathf.Abs(amountPerDelta);
+            }
+            enabled = true;
+        }
+
+        /// <summary>
+        /// Actual tweening logic should go here.
+        /// </summary>
+
+        abstract protected void OnUpdate(float factor, bool isFinished);
+
+        /// <summary>
+        /// Starts the tweening operation.
+        /// </summary>
+
+        static public T Begin<T>(GameObject go, float duration) where T : uTweener
+        {
+            T comp = go.GetComponent<T>();
+#if UNITY_FLASH
+		if ((object)comp == null) comp = (T)go.AddComponent<T>();
+#else
+            // Find the tween with an unset group ID (group ID of 0).
+            if (comp != null && comp.tweenGroup != 0)
+            {
+                comp = null;
+                T[] comps = go.GetComponents<T>();
+                for (int i = 0, imax = comps.Length; i < imax; ++i)
+                {
+                    comp = comps[i];
+                    if (comp != null && comp.tweenGroup == 0) break;
+                    comp = null;
+                }
+            }
+
+            if (comp == null)
+            {
+                comp = go.AddComponent<T>();
+
+                if (comp == null)
+                {
+                    return null;
+                }
+            }
+#endif
+            comp.mStarted = false;
+            comp.duration = duration;
+            comp.mFactor = 0f;
+            comp.mAmountPerDelta = Mathf.Abs(comp.amountPerDelta);
+            comp.style = Style.Once;
+            comp.animationCurve = new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f));
+            comp.eventReceiver = null;
+            comp.callWhenFinished = null;
+            comp.enabled = true;
+            return comp;
+        }
+
+        public virtual void SetStartToCurrentValue() { }
+        public virtual void SetEndToCurrentValue() { }
+        public virtual void SetCurrentValueToStart() { }
+        public virtual void SetCurrentValueToEnd() { }
+    }
+
+}

+ 8 - 0
ActionTowerDefense/Assets/Scripts/Tween/uTweener.cs.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: d6da9593fc6827d46aba0ffcdc5189cc
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 

+ 1 - 0
ActionTowerDefense/ProjectSettings/TagManager.asset

@@ -9,6 +9,7 @@ TagManager:
   - Enemy
   - Tower
   - EnemyTower
+  - Soul
   layers:
   - Default
   - TransparentFX