chenxin
2020-10-27 e33d0e85cf5d01e953d95197488eeffc67835f3a
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);
                }
            }
        }
@@ -728,6 +784,7 @@
            }
            // 设置塔位默认开启,后面需要根据配置来
            m_arrGridType[2, 3] = PlacementGridType.EGridOpen;
            ++GameConfig.EndlessOpenAttackTowerCount;
        }
        /// <summary>