From 43b531f76be6e12c775a1135f6895e8fdc389a59 Mon Sep 17 00:00:00 2001
From: chenxin <chenxin6991@163.com>
Date: Tue, 27 Oct 2020 17:39:23 +0800
Subject: [PATCH] Merge branch 'master' of http://172.16.1.52:8090/r/GemBattle into master

---
 Assets/Scripts/TowerDefense/UI/BulletUICtl.cs           |   20 ++++++
 Assets/Scripts/TowerDefense/Affectors/AttackAffector.cs |    3 +
 Assets/Scripts/TowerDefense/Towers/Tower.cs             |   78 ++++++++++++++++++++++++++
 Assets/Scripts/TowerDefense/UI/EnergyUICtl.cs           |   28 ++++++++
 Assets/Scripts/TowerDefense/UI/HUD/GameUI.cs            |   29 +++++++++
 5 files changed, 156 insertions(+), 2 deletions(-)

diff --git a/Assets/Scripts/TowerDefense/Affectors/AttackAffector.cs b/Assets/Scripts/TowerDefense/Affectors/AttackAffector.cs
index 762e8f6..09c6b11 100644
--- a/Assets/Scripts/TowerDefense/Affectors/AttackAffector.cs
+++ b/Assets/Scripts/TowerDefense/Affectors/AttackAffector.cs
@@ -259,6 +259,7 @@
 					this.energyCalTime += Time.deltaTime;
 					float process = energyCalTime % 11.0f;
 					int proint = (int)Math.Floor(process);
+					proint += towerPtr.uiProOffset;
 					towerPtr.energyCtl.SetEnergyProgress(proint);
 					if (proint == 10)
 					{
@@ -267,6 +268,8 @@
 						// 设置多倍攻击速度
 						fBackupTimer = m_FireTimer;
 						m_FireTimer = m_FireTimer / 3.0f;
+
+						towerPtr.uiProOffset = 0;
 					}
                 }
                 else
diff --git a/Assets/Scripts/TowerDefense/Towers/Tower.cs b/Assets/Scripts/TowerDefense/Towers/Tower.cs
index b5a661a..6d7bfe8 100644
--- a/Assets/Scripts/TowerDefense/Towers/Tower.cs
+++ b/Assets/Scripts/TowerDefense/Towers/Tower.cs
@@ -119,6 +119,10 @@
         /// </summary>
         public float attackRise { get; set; }
 
+        /// <summary>
+        /// 用于界面部分的数据位移
+        /// </summary>
+        protected int progressOffset = 0;
 
         /// <summary>
         /// 塔防数据的局内升级
@@ -127,6 +131,13 @@
         {
             get; set;
         }
+
+        public int uiProOffset
+        {
+            get { return this.progressOffset; } 
+            set { this.progressOffset = value; }
+        }
+
 
         /// <summary>
         /// Gets whether the tower can level up anymore
@@ -223,6 +234,73 @@
         }
 
         /// <summary>
+        /// 去掉当前Tower对应的界面数据.
+        /// </summary>
+        public void DisableTowerUICtrl()
+        {
+            // 根据是否是子弹塔防来决定是否显示相应的界面
+            BulletUICtl buc = this.placementArea.GetBulletUICtl(gridPosition.x, gridPosition.y);
+
+            if ((this.eTowerFuntion == ETowerFuntion.BULLET) && (buc != null))
+            {
+                buc.gameObject.SetActive(false);
+                this.bulletCtl = null;
+            }
+
+            EnergyUICtl euc = placementArea.GetEnergyUICtl(gridPosition.x, gridPosition.y);
+            if ((eTowerFuntion == ETowerFuntion.ENERGY) && (euc != null))
+            {
+                // 设置数据
+                euc.gameObject.SetActive(false);
+                this.energyCtl = null;
+            }
+
+            return;
+       }
+
+        public int GetTowerUICtrlProgress()
+        {
+            // 根据是否是子弹塔防来决定是否显示相应的界面
+            BulletUICtl buc = this.placementArea.GetBulletUICtl(gridPosition.x, gridPosition.y);
+
+            if ((this.eTowerFuntion == ETowerFuntion.BULLET) && (buc != null))
+                return buc.GetCtlProgress();
+
+            EnergyUICtl euc = placementArea.GetEnergyUICtl(gridPosition.x, gridPosition.y);
+            if ((eTowerFuntion == ETowerFuntion.ENERGY) && (euc != null))
+                return euc.GetCtlProgress();
+
+            return 0;
+        }
+
+        public void SetTowerUICtlProcess( int pro)
+        {
+            // 根据是否是子弹塔防来决定是否显示相应的界面
+            BulletUICtl buc = this.placementArea.GetBulletUICtl(gridPosition.x, gridPosition.y);
+
+            if ((this.eTowerFuntion == ETowerFuntion.BULLET) && (buc != null))
+            {
+                buc.SetCtlProcess(pro);
+                progressOffset = pro;
+            }
+
+                EnergyUICtl euc = placementArea.GetEnergyUICtl(gridPosition.x, gridPosition.y);
+            if ((eTowerFuntion == ETowerFuntion.ENERGY) && (euc != null))
+            {
+                euc.SetCtlProcess(pro);
+                progressOffset = pro;
+                if (progressOffset == 10)
+                    progressOffset = 0;
+            }
+
+
+
+                return;
+        }
+
+
+
+        /// <summary>
         /// 充能技能相关的代码开关。包括子弹充能和时间充能
         /// </summary>
         protected void OnTowerUICtrl()
diff --git a/Assets/Scripts/TowerDefense/UI/BulletUICtl.cs b/Assets/Scripts/TowerDefense/UI/BulletUICtl.cs
index 0424684..f44d3aa 100644
--- a/Assets/Scripts/TowerDefense/UI/BulletUICtl.cs
+++ b/Assets/Scripts/TowerDefense/UI/BulletUICtl.cs
@@ -27,6 +27,26 @@
         resetToMaxBullet();
     }
 
+
+    /// <summary>
+    /// 获取进度条进度.
+    /// </summary>
+    /// <returns></returns>
+    public int GetCtlProgress()
+    {
+        return this.curBulletNum;
+    }
+
+    /// <summary>
+    /// 设置进度.
+    /// </summary>
+    /// <param name="pro"></param>
+    public void SetCtlProcess( int pro)
+    {
+        this.curBulletNum = pro;
+        this.updateBulletUI(pro, maxBulletNum);
+    }
+
     /// <summary>
     /// 重设子弹数目到最大.
     /// </summary>
diff --git a/Assets/Scripts/TowerDefense/UI/EnergyUICtl.cs b/Assets/Scripts/TowerDefense/UI/EnergyUICtl.cs
index f8a25c7..5b4f9cb 100644
--- a/Assets/Scripts/TowerDefense/UI/EnergyUICtl.cs
+++ b/Assets/Scripts/TowerDefense/UI/EnergyUICtl.cs
@@ -24,14 +24,38 @@
     }
 
     /// <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(int pro)
+    public void SetEnergyProgress(int pro,bool ani = true)
     {
         if (pro == currentProgress) return;
 
-        energyScaleMask.rectTransform.DOScaleY( pro / 10.0f, 0.3f );
+        if( ani )
+            energyScaleMask.rectTransform.DOScaleY( pro / 10.0f, 0.3f );
+        else
+            energyScaleMask.rectTransform.DOScaleY(pro / 10.0f, 0.0f);
         currentProgress = pro;
     }
 
diff --git a/Assets/Scripts/TowerDefense/UI/HUD/GameUI.cs b/Assets/Scripts/TowerDefense/UI/HUD/GameUI.cs
index af04ff7..d8db3e8 100644
--- a/Assets/Scripts/TowerDefense/UI/HUD/GameUI.cs
+++ b/Assets/Scripts/TowerDefense/UI/HUD/GameUI.cs
@@ -192,6 +192,12 @@
         protected Tower towerToMove = null;
 
         /// <summary>
+        /// UI界面对应的进度
+        /// </summary>
+        protected int uiCtlProgresss = 0;
+
+
+        /// <summary>
         /// Fires when the <see cref="State"/> changes
         /// should only allow firing when TouchUI is used
         /// </summary>
@@ -342,6 +348,10 @@
 
         public void delTower(Tower t)
         {
+            // 删除Tower之前去掉充能条数据.
+            if( t.bInAttackMode)
+                t.DisableTowerUICtrl();
+
             // 删除Tower有可能对应的Timer.
             foreach (var tdata in towerTimeDic)
             {
@@ -580,12 +590,21 @@
                 break;
             }
 
+            //
+            // 重设界面数据
+            uiCtlProgresss = 0;
 
             // 从列表中删除Tower.并破坏Tower的外形。
             dragTowerLevel = towerOld.currentLevel;
             // 尝试不再删除原来的Tower,而是尝试在合成成功后再删除原来的Tower
             towerOld.showTower(false);
             towerToMove = towerOld;
+
+            if( towerOld.bInAttackMode)
+            {
+                int pro = towerOld.GetTowerUICtrlProgress();
+                uiCtlProgresss = pro;
+            }
 
             // 先删除,再设置移动相关。
             SetToDragMode(newT);
@@ -835,7 +854,17 @@
                 // 开启相应的兵线:
                 Tower tw = FindTowerWithGridIdx(m_GridPosition.x, m_GridPosition.y);
                 if (tw != null)
+                {
                     LevelManager.instance.startWaveLine(m_GridPosition.x, false, tw.attributeId);
+                    
+                    // 顺便设置界面的进展
+                    if (uiCtlProgresss > 0)
+                    {
+                        tw.SetTowerUICtlProcess(uiCtlProgresss);
+                        Debug.Log("设置当前的进度:" + uiCtlProgresss);
+                        uiCtlProgresss = 0;
+                    }
+                }
             }
             // 当前是Skill塔位的状态.
             else if (bSkill)

--
Gitblit v1.9.1