chenxin
2020-11-17 344267a8edb7bc6eaa67a0493292f438d31ca20e
Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGridEndless.cs
@@ -37,7 +37,7 @@
        /// <summary>
        /// 等待购买开启对应按钮.
        /// </summary>
        public Button waitBuyBtnPrefab;
        public GameObject waitBuyBtnPrefab;
        /// <summary>
        /// 最后一行格子与前一行格子之间的空位长度.
@@ -589,12 +589,25 @@
            // Precalculate inverted grid size, to save a division every time we translate coords
            m_InvGridSize = 1 / gridSize;
            SetUpGrid();
            // 初始化格子对应的屏幕坐标数据 延迟执行
            Invoke("preCalculateGridUIPos", 0.3f);
            //preCalculateGridUIPos();
            EventCenter.Ins.Add<int>((int)KTGMGemClient.EventType.EndlessCritBulletNumChange, OnCritBulletNumChange);
        }
        /// <summary>
        /// 木属性暴击子弹数量改变
        /// </summary>
        /// <param name="count"></param>
        private void OnCritBulletNumChange(int count)
        {
            for (int i = 0; i < dimensions.x; ++i)
            {
                for (int j = 0; j < AttackRowNumbers; ++j)
                {
                    arrTowerBulletUi[i, j].CritBulletNum = count;
                }
            }
        }
        /// <summary>
@@ -629,27 +642,30 @@
            m_arrTGO = new EndlessTowerGridOpen[dimensions.x, dimensions.y];
            GameObject container = GameObject.Find("BuyButtonContainer");
            float[] xup = { -0.6f, -0.3f, 0, 0.3f, 0.6f };
            TowerPlacementGridEndless.GRID_OPENCASH = 100;
            //Debug.Log("修改了数值:" + TowerPlacementGridEndless.GRID_OPENCASH);
            //float[] xup = { -0.6f, -0.3f, 0, 0.3f, 0.6f };
            for (int x = 0; x < dimensions.x; ++x)
            {
                for (int y = dimensions.y - AttackRowNumbers; y < dimensions.y; ++y)
                {
                    if (m_arrGridType[x, y] != PlacementGridType.EGridWaitBuy) continue;
                    Button buyButton = Instantiate(waitBuyBtnPrefab);
                    GameObject buyButton = Instantiate(waitBuyBtnPrefab);
                    buyButton.transform.SetParent(container.transform);
                    Vector3 pos = buyButton.transform.position;
                    pos.x = arrGridCentPos[x, y].x + (x - 2) * gapArr[3 - y] + xup[x];
                    if (y == 2)
                    {
                        pos.z = arrGridCentPos[x, y].y + 9f;
                    }
                    else if (y == 3)
                    {
                        pos.z = arrGridCentPos[x, y].y + 7f;
                    }
                    //pos.x = arrGridCentPos[x, y].x + (x - 2) * gapArr[3 - y] + xup[x];
                    pos.x = arrGridCentPos[x, y].x + (x - 2) * gapArr[3 - y];
                    pos.z = arrGridCentPos[x, y].y + 6f;
                    // if (y == 2)
                    // {
                    //     pos.z = arrGridCentPos[x, y].y + 9f;
                    // }
                    // else if (y == 3)
                    // {
                    //     pos.z = arrGridCentPos[x, y].y + 7f;
                    // }
                    pos.y = 30;
                    buyButton.transform.position = pos;
                    buyButton.transform.localRotation = Quaternion.identity;
@@ -774,7 +790,7 @@
                    arrTowerEnergyEffect[x, y] = Instantiate(energyEffectPrefab);
                    arrTowerEnergyEffect[x, y].transform.position = vpos;
                    // 创建水精灵充能条
                    img = Instantiate(FreezeBreathChargePrefab);
                    img.transform.SetParent(container.transform);