From 74daf5509be4fc140fd1bdb6d4df5f1c1002e368 Mon Sep 17 00:00:00 2001 From: wangguan <wangguan@kt007.com> Date: Thu, 22 Oct 2020 17:28:08 +0800 Subject: [PATCH] Merge branch 'master' of ssh://172.16.1.52:8091/GemBattle --- Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGrid.cs | 40 +++++++++++++++++++++++++++++++++++++++- 1 files changed, 39 insertions(+), 1 deletions(-) diff --git a/Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGrid.cs b/Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGrid.cs index e1c4b1c..3e75b17 100644 --- a/Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGrid.cs +++ b/Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGrid.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using Core.Utilities; using KTGMGemClient; using Microsoft.VisualBasic; @@ -43,6 +44,10 @@ /// 相应的界面指针传到塔防的数据结构内。 /// </summary> public GameObject towerBulletUIPrefab; + /// <summary> + /// 充能条对应的界面 + /// </summary> + public GameObject towerEnergyUIPrefab; /// <summary> /// 等待购买开启对应按钮. @@ -115,6 +120,7 @@ /// </summary> Vector2[] m_arrTowerBulletUIPos; BulletUICtl[] arrTowerBulletUi; + EnergyUICtl[] arrTowerEnergyUi; /// <summary> @@ -173,6 +179,16 @@ public BulletUICtl GetBulletUICtl(int x) { return this.arrTowerBulletUi[x]; + } + + /// <summary> + /// 获取对应位置的能量条界面指针. + /// </summary> + /// <param name="x"></param> + /// <returns></returns> + public EnergyUICtl GetEnergyUICtl(int x) + { + return this.arrTowerEnergyUi[x]; } /// <summary> @@ -402,6 +418,9 @@ if (arrTowerBulletUi[x] != null) arrTowerBulletUi[x].gameObject.SetActive(false); + + if (arrTowerEnergyUi[x] != null) + arrTowerEnergyUi[x].gameObject.SetActive(false); m_Tiles[x, y].SetTileType(PlacementGridType.EGridDestroyed); @@ -711,15 +730,21 @@ // 处理攻击塔位对应的血条 m_arrTowerBulletUIPos = new Vector2[dimensions.x]; arrTowerBulletUi = new BulletUICtl[dimensions.x]; + arrTowerEnergyUi = new EnergyUICtl[dimensions.x]; + for (int x = 0; x < dimensions.x; x++) { m_arrTowerBulletUIPos[x].x = m_arrGridCentUIPos[x, dy].x + m_fGridUISize/2.0f - 10; m_arrTowerBulletUIPos[x].y = m_arrGridCentUIPos[x, dy].y; - GameObject img = Instantiate(towerBulletUIPrefab); + GameObject go = GameObject.Find("BattleMainUI"); if (!go) continue; Transform tp = go.GetComponent<Transform>(); + + GameObject img; + + img = Instantiate(towerBulletUIPrefab); img.GetComponent<Transform>().SetParent(tp, true); Vector3 tpos = img.transform.position; tpos.x = m_arrTowerBulletUIPos[x].x; @@ -731,6 +756,19 @@ BulletUICtl buc = img.GetComponent<BulletUICtl>(); arrTowerBulletUi[x] = buc; buc.gameObject.SetActive(false); + + // 把充能条也创建出来了. + img = Instantiate(towerEnergyUIPrefab); + img.GetComponent<Transform>().SetParent(tp, true); + tpos = img.transform.position; + tpos.x = m_arrTowerBulletUIPos[x].x; + tpos.y = m_arrTowerBulletUIPos[x].y; + img.transform.position = tpos; + + img.transform.SetAsFirstSibling(); + EnergyUICtl euc = img.GetComponent<EnergyUICtl>(); + arrTowerEnergyUi[x] = euc; + euc.gameObject.SetActive(false); } return; -- Gitblit v1.9.1