From 6f16dfb8bcebe67aeb95ded0d8b644af4932e690 Mon Sep 17 00:00:00 2001
From: chenxin <chenxin6991@163.com>
Date: Mon, 26 Oct 2020 21:00:32 +0800
Subject: [PATCH] 无尽模式新手步骤到水元素放置塔位完成

---
 Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGridEndless.cs |   66 ++++++++++++++++++++++++++++++--
 1 files changed, 61 insertions(+), 5 deletions(-)

diff --git a/Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGridEndless.cs b/Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGridEndless.cs
index 2376cf0..c2fed45 100644
--- a/Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGridEndless.cs
+++ b/Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGridEndless.cs
@@ -106,6 +106,26 @@
         public int AttackRowNumbers { get; } = 2;
 
         /// <summary>
+        /// 攻击塔位对应的子弹UI位置信息.
+        /// </summary>
+        private Vector2[,] m_arrTowerBulletUIPos;
+
+        private BulletUICtl[,] arrTowerBulletUi;
+
+        private EnergyUICtl[,] arrTowerEnergyUi;
+
+        /// <summary>
+        /// 此位置上塔对应的子弹充能Prefab.塔放置到当前的塔位后,如果是对应的塔防类型,需要把
+        /// 相应的界面指针传到塔防的数据结构内。
+        /// </summary>
+        public GameObject towerBulletUIPrefab;
+
+        /// <summary>
+        /// 充能条对应的界面
+        /// </summary>
+        public GameObject towerEnergyUIPrefab;
+
+        /// <summary>
         /// Converts a location in world space into local grid coordinates.
         /// </summary>
         /// <param name="worldLocation"><see cref="Vector3"/> indicating world space coordinates to convert.</param>
@@ -147,9 +167,9 @@
 		/// </summary>
 		/// <param name="x"></param>
 		/// <returns></returns>
-		public BulletUICtl GetBulletUICtl(int x)
+		public BulletUICtl GetBulletUICtl(int x, int y)
         {
-            return null;
+            return arrTowerBulletUi[x, 3 - y];
         }
 
         /// <summary>
@@ -157,9 +177,9 @@
         /// </summary>
         /// <param name="x"></param>
         /// <returns></returns>
-        public EnergyUICtl GetEnergyUICtl(int x)
+        public EnergyUICtl GetEnergyUICtl(int x, int y)
         {
-            return null;
+            return arrTowerEnergyUi[x, 3 - y];
         }
 
 
@@ -618,12 +638,19 @@
             arrTowerBloodUi = new TowerBloodVis[dimensions.x, AttackRowNumbers];
             int dy = dimensions.y - 1;
 
+            // 处理攻击塔位对应的血条
+            m_arrTowerBulletUIPos = new Vector2[dimensions.x, AttackRowNumbers];
+            arrTowerBulletUi = new BulletUICtl[dimensions.x, AttackRowNumbers];
+            arrTowerEnergyUi = new EnergyUICtl[dimensions.x, AttackRowNumbers];
+
             for (int x = 0; x < dimensions.x; x++)
             {
                 for (int y = 0; y < AttackRowNumbers; ++y)
                 {
                     m_arrTowerBloodUIPos[x, y].x = arrGridCentPos[x, dy - y].x;
                     m_arrTowerBloodUIPos[x, y].y = arrGridCentPos[x, dy - y].y;
+                    m_arrTowerBulletUIPos[x, y].x = arrGridCentPos[x, dy - y].x;
+                    m_arrTowerBulletUIPos[x, y].y = arrGridCentPos[x, dy - y].y;
 
                     GameObject img = Instantiate(towerBloodUIPrefab);
                     GameObject container = GameObject.Find("BuyButtonContainer");
@@ -631,7 +658,7 @@
                     Vector3 tpos = img.transform.position;
                     tpos.x = m_arrTowerBloodUIPos[x, y].x;
                     tpos.z = m_arrTowerBloodUIPos[x, y].y + 4.2f - y * 1.66f;
-                    tpos.y = 30;
+                    tpos.y = 30f;
                     img.transform.position = tpos;
                     img.transform.localScale = Vector3.one;
                     img.transform.localRotation = Quaternion.identity;
@@ -639,6 +666,35 @@
                     TowerBloodVis tbv = img.GetComponent<TowerBloodVis>();
                     arrTowerBloodUi[x, y] = tbv;
                     tbv.gameObject.SetActive(false);
+
+                    img = Instantiate(towerBulletUIPrefab);
+                    img.transform.SetParent(container.transform, true);
+                    tpos = img.transform.position;
+                    tpos.x = m_arrTowerBulletUIPos[x, y].x + 4.2f;
+                    tpos.z = m_arrTowerBulletUIPos[x, y].y + 1.1f -  y * 1.66f;
+                    tpos.y = 30f;
+                    img.transform.position = tpos;
+                    img.transform.localScale = Vector3.one;
+                    img.transform.localRotation = Quaternion.identity;
+
+                    BulletUICtl buc = img.GetComponent<BulletUICtl>();
+                    arrTowerBulletUi[x, y] = buc;
+                    buc.gameObject.SetActive(false);
+
+                    // 把充能条也创建出来了.
+                    img = Instantiate(towerEnergyUIPrefab);
+                    img.transform.SetParent(container.transform);
+                    tpos = img.transform.position;
+                    tpos.x = m_arrTowerBulletUIPos[x, y].x + 4.2f;
+                    tpos.z = m_arrTowerBulletUIPos[x, y].y + 1.1f - y * 1.66f;
+                    tpos.y = 30f;
+                    img.transform.position = tpos;
+                    img.transform.localScale = Vector3.one;
+                    img.transform.localRotation = Quaternion.identity;
+
+                    EnergyUICtl euc = img.GetComponent<EnergyUICtl>();
+                    arrTowerEnergyUi[x, y] = euc;
+                    euc.gameObject.SetActive(false);
                 }
             }
         }

--
Gitblit v1.9.1