From adf4e32c75f0886b330c6ad449f6a2a46b3d3771 Mon Sep 17 00:00:00 2001 From: liuzhiwei <liuzhiwei@qq.com> Date: Fri, 13 Nov 2020 15:25:48 +0800 Subject: [PATCH] Merge branch 'master' of http://172.16.1.52:8090/r/GemBattle into master --- Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs | 95 +++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 86 insertions(+), 9 deletions(-) diff --git a/Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs b/Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs index d3b37f9..64bf996 100644 --- a/Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs +++ b/Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs @@ -179,9 +179,11 @@ /// </summary> TowerPlacementGhost m_CurrentTower; - public bool HasTower{ - get{ - return m_CurrentTower!=null; + public bool HasTower + { + get + { + return m_CurrentTower != null; } } @@ -253,6 +255,14 @@ /// </summary> public GameObject TowerAppearEffectPrefab; + //首次购买宝石特效 + public GameObject fireAppearEffect1; + public GameObject fireAppearEffect2; + + public GameObject waterAppearEffect1; + public GameObject waterAppearEffect2; + public GameObject woodAppearEffect1; + public GameObject woodAppearEffect2; /// <summary> /// 保存所有生成或合成的塔的最小等级,索引0 -> 火木水塔 索引1 -> 技能塔 /// </summary> @@ -1590,7 +1600,7 @@ /// <exception cref="InvalidOperationException"> /// Throws exception if not in Build State or <see cref="m_CurrentTower"/> is not at a valid position /// </exception> - public void PlaceTower(int lvl = 0, bool isUpgrade = false, bool opponent = false) + public void PlaceTower(int lvl = 0, bool isUpgrade = false, bool opponent = false, bool isFirstAppear = false) { if (!isBuilding) throw new InvalidOperationException("Trying to place tower when not in a Build Mode"); @@ -1611,16 +1621,70 @@ // River: 内部缓存数据,用于后期容易找到数据. addTower(createdTower); CancelGhostPlacement(); - if (!isUpgrade) + if (isFirstAppear) + { + PlayFirstAppearEffect(createdTower.towerName, createdTower.transform.position); + } + else if (!isUpgrade) + { PlayAppearEffect(createdTower.transform.position); + } else + { PlayUpgradeEffect(createdTower); + } // 处理成长骰子,复制骰子等等功能. if (lvl == 0) { ProcessFeatureTower(createdTower); } + } + + /// <summary> + /// 播放首次宝石出现特效 + /// </summary> + public void PlayFirstAppearEffect(string towerName, Vector3 worldPos) + { + if (towerName.StartsWith("GrowUpTower")) + { + //火元素 + PlayAppearEffect(worldPos, fireAppearEffect1); + PlayAppearEffect(worldPos, fireAppearEffect2); + if (Application.platform == RuntimePlatform.WindowsEditor) + { + //UnityEditor.EditorApplication.isPaused = true; + } + } + else if (towerName.StartsWith("BlinkTower")) + { + //木元素 + PlayAppearEffect(worldPos, woodAppearEffect1); + PlayAppearEffect(worldPos, woodAppearEffect2); + + } + else if (towerName.StartsWith("CopyCatTower")) + { + //水元素 + PlayAppearEffect(worldPos, waterAppearEffect1); + PlayAppearEffect(worldPos, waterAppearEffect2); + } + } + void PlayAppearEffect(Vector3 worldPos, GameObject prefab) + { + GameObject obj = Instantiate(prefab); + 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> @@ -1789,7 +1853,7 @@ if (placeObj != null) { m_CurrentArea = placeObj.GetComponent<IPlacementArea>(); - dragTowerPlacement = placeObj.GetComponent<IPlacementArea>() as TowerPlacementGridEndless; + dragTowerPlacement = placeObj.GetComponent<IPlacementArea>() as TowerPlacementGridEndless; } placeObj = GameObject.FindGameObjectWithTag("PlaceTowerOpponent"); EventCenter.Ins.Add((int)KTGMGemClient.EventType.EndlessHeartAllLose, AllHeartLose); @@ -1834,7 +1898,7 @@ /// 直接在IPlaceArea上随机放置一个Tower。这是随机放置塔防的入口类。这是入口的塔防类。 /// </summary> /// <param name="tow"></param> - public bool RandomPlaceTower(Tower tow, int posx = -1, int posy = -1, int lvl = 0, int forceCost = -1, bool isUpgrade = false) + public bool RandomPlaceTower(Tower tow, int posx = -1, int posy = -1, int lvl = 0, int forceCost = -1, bool isUpgrade = false, bool isFirstAppear = false) { // 获取IPlaceArea. if (m_CurrentArea == null) @@ -1898,7 +1962,7 @@ OnSuccessBuyTower(); SetState(State.Building); - PlaceTower(lvl, isUpgrade); + PlaceTower(lvl, isUpgrade, false, isFirstAppear); } return true; @@ -2295,7 +2359,20 @@ /// <param name="worldPos">世界坐标</param> public void PlayToAttackEffect(int attributeId, Vector3 worldPos) { - string path = $"UI/ToBattle_{attributeId}"; + string path = ""; + if (attributeId == 101) + { + path = "UI/Effect_Elf_Huo_DengChang_101"; + } + else if (attributeId == 105) + { + path = "UI/Effect_Elf_Shui_DengChang_105"; + } + else if (attributeId == 109) + { + path = "UI/Effect_Elf_Mu_DengChang_109"; + } + GameObject prefab = Resources.Load<GameObject>(path); GameObject obj = Instantiate(prefab); obj.transform.position = worldPos; -- Gitblit v1.9.1