chenxin
2020-11-17 344267a8edb7bc6eaa67a0493292f438d31ca20e
Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs
@@ -109,6 +109,8 @@
        /// </summary>
        public Button randomTowerBtn;
        public Button SkillTowerBtn;
        /// <summary>
        /// 飘血数字对应的prefab.
        /// </summary>
@@ -128,6 +130,8 @@
        /// 购买塔防按钮上的Text.
        /// </summary>
        protected TextMeshProUGUI towerPriceText;
        protected TextMeshProUGUI towerPriceText1;
        protected bool tdBuyDisable = false;
@@ -254,6 +258,10 @@
        /// 宝石出现特效预制体
        /// </summary>
        public GameObject TowerAppearEffectPrefab;
        public GameObject TowerUpgradeEffectPrefabGuide;//新手导航特效Layer是UI
        public GameObject TowerAppearEffectPrefabGuide;//新手导航特效Layer是UI
        //首次购买宝石特效
        public GameObject fireAppearEffect1;
@@ -731,13 +739,13 @@
        /// <param name="tower"></param>
        protected void growUpTower(Tower tower)
        {
            Tower newTower = EndlessRandomTower.instance.GetRandomTower(false);
            Tower newTower = EndlessRandomTower.instance.GetRandomTower(EFeatureTower.NULL, true);
            // 所有的Tower不能升级成为FeatureTower.
            int maxLoop = 20;
            while (newTower.towerFeature != EFeatureTower.NULL)
            {
                newTower = EndlessRandomTower.instance.GetRandomTower(false);
                newTower = EndlessRandomTower.instance.GetRandomTower(EFeatureTower.NULL, true);
                maxLoop--;
                if (maxLoop <= 0)
                {
@@ -891,9 +899,13 @@
                            allTowerP.Add(m_listTower[i].gridPosition);
                        }
                    }
                    if (m_CurrentArea != null)
                    {
                        (m_CurrentArea as TowerPlacementGridEndless).CheckAllCanPlace(allTowerP);
                        //(m_CurrentArea as TowerPlacementGridEndless).PlayPS(allPSTowerP);
                    }
                (m_CurrentArea as TowerPlacementGridEndless).CheckAllCanPlace(allTowerP);
                    (m_CurrentArea as TowerPlacementGridEndless).PlayPS(allPSTowerP);
                }
                else if (m_CurrentTower.controller.towerFeature == EFeatureTower.Skill_Fire || m_CurrentTower.controller.towerFeature == EFeatureTower.Skill_Bomb)
                {
@@ -1024,7 +1036,13 @@
                TryPlaceTower(pointerInfo);
            else if (isFreeAttackGrid(pointerInfo) && !bSkill)
            {
                if (!TryPlaceTower(pointerInfo, false, true)) return;
                if (!TryPlaceTower(pointerInfo, false, true))
                {
                    CancelPlaceTower(pointerInfo);
                    Debug.Log("这里需要返回原位");
                    return;
                }
                // 删除towerToMove,确保塔防数据不再出现多个
                if (towerToMove != null)
@@ -1688,6 +1706,25 @@
            Destroy(obj, ps.main.duration);
        }
        public void PlayAppearEffectGuide(Vector3 worldPos)
        {
            GameObject obj = Instantiate(TowerAppearEffectPrefabGuide);
            obj.transform.position = worldPos;
            Vector3 pos = obj.transform.position;
            pos.y += 5f;
            obj.transform.position = pos;
            ParticleSystem ps = obj.GetComponent<ParticleSystem>();
            if (ps == null)
                ps = obj.transform.GetChild(0).GetComponent<ParticleSystem>();
            ps.Play();
            Destroy(obj, ps.main.duration);
        }
        /// <summary>
        /// 播放宝石出现特效
        /// </summary>
@@ -1708,17 +1745,17 @@
            Destroy(obj, ps.main.duration);
        }
        /// <summary>
        /// 播放升级特效
        /// </summary>
        /// <param name="worldPos"></param>
        public void GuidePlayUpgradeEffect(Vector3 position)
        {
            GameObject effect = TowerUpgradeEffectPrefab;
            // 在sTower的位置播放升级特效
            GameObject obj = Instantiate(effect);
            GameObject obj = Instantiate(TowerUpgradeEffectPrefabGuide);
            obj.transform.position = position;
            Vector3 pos = obj.transform.position;
            pos.y += 5f;
            obj.transform.position = pos;
@@ -1726,6 +1763,7 @@
            if (ps == null)
                ps = obj.transform.GetChild(0).GetComponent<ParticleSystem>();
            ps.Play();
            Destroy(obj, ps.main.duration);
        }
@@ -1760,12 +1798,16 @@
            if (!towerPriceText)
            {
                towerPriceText = randomTowerBtn.transform.Find("cashText").GetComponent<TextMeshProUGUI>();
                towerPriceText1 = SkillTowerBtn.transform.Find("cashText").GetComponent<TextMeshProUGUI>();
                if (towerPriceText)
                    towerPriceText.text = tpMgr.currentTowerPrice.ToString();
                if (towerPriceText1)
                    towerPriceText1.text = tpMgr.currentTowerPrice.ToString();
            }
            else
            {
                towerPriceText.text = tpMgr.currentTowerPrice.ToString();
                towerPriceText1.text = tpMgr.currentTowerPrice.ToString();
            }
            // 无法支付新的塔防价格,按钮变灰.
@@ -1785,6 +1827,7 @@
            if (towerPriceText)
            {
                towerPriceText.color = new Color(0.5f, 0.5f, 0.5f);
                towerPriceText1.color = new Color(0.5f, 0.5f, 0.5f);
            }
            tdBuyDisable = true;
        }
@@ -1800,7 +1843,10 @@
                return;
            if (towerPriceText)
            {
                towerPriceText.color = new Color(1.0f, 1.0f, 1.0f);
                towerPriceText1.color = new Color(1.0f, 1.0f, 1.0f);
            }
            if (randomTowerBtn)
            {
@@ -2093,10 +2139,12 @@
        {
            base.Awake();
            randomTowerBtn = transform.Find("BottomCanvas/Panel/TowerBuyBtn").GetComponent<Button>();
            DOTween.Init(true, true, LogBehaviour.Verbose).SetCapacity(200, 10);
            state = State.Normal;
            m_Camera = GameObject.Find("SceneCamera3D").GetComponent<Camera>();
            //m_Camera = GetComponent<Camera>();
            TowerDestroyArr = new bool[5, AttackRowNumbers];
        }