From d2bc86161bf01b9ac01ba7b4b6ee7e341778c0c2 Mon Sep 17 00:00:00 2001
From: River Jiang <546213258@qq.com>
Date: Wed, 28 Oct 2020 14:34:36 +0800
Subject: [PATCH] 充能进度动画平滑加强

---
 Assets/Scripts/TowerDefense/UI/EnergyUICtl.cs |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/Assets/Scripts/TowerDefense/UI/EnergyUICtl.cs b/Assets/Scripts/TowerDefense/UI/EnergyUICtl.cs
index 2f5ab5c..04d3c08 100644
--- a/Assets/Scripts/TowerDefense/UI/EnergyUICtl.cs
+++ b/Assets/Scripts/TowerDefense/UI/EnergyUICtl.cs
@@ -12,9 +12,16 @@
     public Image energyScaleMask;
 
     /// <summary>
-    /// 当前的能量条进度.
+    /// 充能条满后,在场景内播放的特效
     /// </summary>
-    protected float currentProgress;
+    public GameObject energyEffPrefab;
+
+    /// <summary>
+    /// 当前的能量条进度.10份进度.
+    /// </summary>
+    protected int currentProgress;
+
+    protected Vector3 vec3EffectPlay;
 
     // Start is called before the first frame update
     void Start()
@@ -24,15 +31,58 @@
     }
 
     /// <summary>
+    /// 设置要播放特效的位置信息.
+    /// </summary>
+    /// <param name="vec"></param>
+    public void SetEffectPlayPos( Vector3 vec)
+    {
+        vec3EffectPlay.x = vec.x;
+        vec3EffectPlay.y = vec.y;
+        vec3EffectPlay.z = vec.z;
+    }
+
+    /// <summary>
+    /// 获取进度条进度.
+    /// </summary>
+    /// <returns></returns>
+    public int GetCtlProgress()
+    {
+        return currentProgress;
+    }
+
+    /// <summary>
+    /// 设置进度.
+    /// </summary>
+    /// <param name="pro"></param>
+    public void SetCtlProcess(int pro)
+    {
+        if (pro == 10)
+            pro = 0;
+        energyScaleMask.rectTransform.DOKill();
+        this.SetEnergyProgress(pro,false);
+    }
+
+    /// <summary>
     /// 显示并更新能量条进度.
     /// </summary>
     /// <param name="pro"></param>
-    public void SetEnergyProgress(float pro)
+    public void SetEnergyProgress(int pro,bool ani = true)
     {
-        energyScaleMask.rectTransform.DOScaleY( pro, 0.3f );
+        if (pro == currentProgress) return;
+
+        if( ani )
+            energyScaleMask.rectTransform.DOScaleY( pro / 10.0f, 0.3f );
+        else
+            energyScaleMask.rectTransform.DOScaleY(pro / 10.0f, 0.0f);
         currentProgress = pro;
     }
 
+    public void SetEnergyProcessFloat( float fpro)
+    {
+        energyScaleMask.rectTransform.DOScaleY(fpro / 10.0f, 0.0f);
+        currentProgress = (int)Mathf.Floor(fpro);
+    }
+
     // Update is called once per frame
     void Update()
     {

--
Gitblit v1.9.1