wangguan
2020-12-16 fe59d1a97e80284315bcdfa18a49059b38dfd137
Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs
@@ -350,6 +350,25 @@
            return null;
        }
        /// <summary>
        /// 根据塔位索引位置,查找位置上是否有对应的塔防数据。
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public int GetTowerNum()
        {
            int num = 0;
            foreach (Tower lt in m_listTower)
            {
                if (lt.gridPosition.y == 0 || lt.gridPosition.y == 1)
                {
                    num++;
                }
            }
            return num;
        }
        public bool towerInList(Tower t)
        {
            return m_listTower.Contains(t);
@@ -643,7 +662,7 @@
            if ((m_GridPosition.x >= 0) && (m_GridPosition.y >= 0))
            {
                if (m_CurrentArea.isFreeAtackPos(m_GridPosition.x, m_GridPosition.y))
                if ((m_CurrentArea as TowerPlacementGridEndless).isFreeAtackPos(m_GridPosition.x, m_GridPosition.y))
                {
                    return true;
                }
@@ -793,7 +812,9 @@
                    PlayUpgradeEffect(m_listTower[i]);
                }
            }
            GameConfig.IsUpgradeTowerLevel = true;
            UpdateMinLevelArr();
            EndlessRandomTower.instance.UpdateDescDisplay();
        }
        /// <summary>
@@ -1119,7 +1140,7 @@
                {
                    if (m_GridPosition.y == 0 || m_GridPosition.y == 1)
                    {
                        Debug.Log("未上阵区域,不管有没有塔,都强行吸附");
                        //Debug.Log("未上阵区域,不管有没有塔,都强行吸附");
                        (m_CurrentArea as TowerPlacementGridEndless).CheckCanPlaceUpdate(m_GridPosition.x, m_GridPosition.y, true, "");
                        m_CurrentTower.transform.position = (m_CurrentArea as TowerPlacementGridEndless).GridToWorld(m_GridPosition, m_CurrentTower.controller.dimensions);
@@ -1133,7 +1154,7 @@
                        if (checkTowerPlaceTower != null)
                        {
                            Debug.Log(checkTowerPlaceTower.name);
                            //Debug.Log(checkTowerPlaceTower.name);
                            if (m_CurrentTower.controller.towerFeature == EFeatureTower.NULL)
                            {
@@ -1301,11 +1322,14 @@
            // 判断目标位置是否有Tower且类型和等级一致,如果没有,则GhostTower删除,原Tower显示。
            if (isValidateCombineTarget(pointerInfo))
            {
                //Debug.Log("isValidateCombineTarget");
                TryPlaceTower(pointerInfo);
                EndlessRandomTower.instance.UpdateDescDisplay();
            }
            else if (isFreeAttackGrid(pointerInfo))
            {
                //Debug.Log("isFreeAttackGrid:" + m_GridPosition);
                if (!TryPlaceTower(pointerInfo, false))
                {
                    CancelPlaceTower(pointerInfo);
@@ -1326,6 +1350,8 @@
            }
            else if (EndlessLevelManager.instanceExists && IsSubstitute(pointerInfo))
            {
                //Debug.Log("IsSubstitute");
                CheckCanChangePos(pointerInfo);
            }
            else
@@ -1731,6 +1757,7 @@
        {
            if (!isBuilding) return false;
            //Debug.Log("开始造塔" + m_GridPosition);
            // 判断是否格子上重复放置塔防
            if (!m_CurrentTower || !IsGhostAtValidPosition())
            {
@@ -1763,6 +1790,7 @@
                        CancelGhostPlacement();
                        return false;
                    }
                    PlaceGhost(pointer);
                }
                return true;
@@ -2273,7 +2301,6 @@
            bool successfulPurchase = EndlessLevelManager.instance.Currency.TryPurchase(cost);
            if (!successfulPurchase) return false;
            EndlessRandomTower.instance.UpdateDescDisplay();
            SetUpGhostTower(tow);
            //Debug.Log("设置影子塔防.");
            m_CurrentTower.Show();
@@ -2625,6 +2652,7 @@
                return;
            }
            m_GridPosition = m_CurrentArea.WorldToGrid(raycast.point, m_CurrentTower.controller.dimensions);
            //Debug.Log("修改了m_GridPosition:" + m_GridPosition);
            TowerFitStatus fits = m_CurrentArea.Fits(m_GridPosition, m_CurrentTower.controller.dimensions);
            m_CurrentTower.Show();
@@ -2675,10 +2703,12 @@
        /// <exception cref="InvalidOperationException">If we're not in the correct state</exception>
        protected void PlaceGhost(UIPointer pointer)
        {
            MoveGhost(pointer);
            //MoveGhost(pointer);
            if (m_CurrentArea != null)
            {
                //Debug.Log("开始检测PlaceGhost:" + m_GridPosition);
                TowerFitStatus fits = m_CurrentArea.Fits(m_GridPosition, m_CurrentTower.controller.dimensions);
                if (fits == TowerFitStatus.Fits)
@@ -2841,10 +2871,6 @@
            m_CurrentTower = Instantiate(towerToBuild.towerGhostPrefab);
            m_CurrentTower.Initialize(towerToBuild);
            Debug.Log("SetUpGhostTower:" + towerToBuild.gridPosition);
            Debug.Log("SetUpGhostTower:" + m_CurrentTower.controller.gridPosition);
        }
        /// <summary>