From 56f231f1f6523d7920cf32f033f9bb6f0015550f Mon Sep 17 00:00:00 2001 From: chenxin <chenxin6991@163.com> Date: Wed, 28 Oct 2020 18:05:11 +0800 Subject: [PATCH] Merge commit '8380b3c000a04bd9bf6dfc11fd8337c1563ad265' into master --- Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs | 69 ++++++++++++++++++++++++++++++++++ 1 files changed, 68 insertions(+), 1 deletions(-) diff --git a/Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs b/Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs index 8eb8e77..0a94bfc 100644 --- a/Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs +++ b/Assets/Scripts/TowerDefense/UI/HUD/EndlessGameUI.cs @@ -236,6 +236,16 @@ public event Action GameOverEvent; + /// <summary> + /// 塔升级特效预制体 + /// </summary> + public GameObject TowerUpgradeEffectPrefab; + + /// <summary> + /// 宝石出现特效预制体 + /// </summary> + public GameObject TowerAppearEffectPrefab; + public IPlacementArea selfTowerPlaceArea { get @@ -1188,6 +1198,18 @@ SetState(State.Normal); // 新的代码,合并升级为随机塔防类型. randomUpgradeTower(); + // 在sTower的位置播放升级特效 + GameObject obj = Instantiate(TowerUpgradeEffectPrefab); + obj.transform.position = sTower.transform.position; + 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); } } else @@ -1307,14 +1329,34 @@ // River: 内部缓存数据,用于后期容易找到数据. addTower(createdTower); - CancelGhostPlacement(); + PlayAppearEffect(createdTower.transform.position); // 处理成长骰子,复制骰子等等功能. if (lvl == 0) { ProcessFeatureTower(createdTower); } + } + + /// <summary> + /// 播放宝石出现特效 + /// </summary> + public void PlayAppearEffect(Vector3 worldPos) + { + GameObject obj = Instantiate(TowerAppearEffectPrefab); + 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); } protected void ProcessFeatureTower(Tower ctower) @@ -1914,6 +1956,7 @@ // ATTENTION TO FIX:是否应该加入List: addTower(createdTower); + PlayToAttackEffect(createdTower.attributeId, createdTower.transform.position); dragTowerLevel = 0; CancelGhostPlacement(); } @@ -1921,6 +1964,30 @@ } /// <summary> + /// 播放宝石上阵特效 + /// </summary> + /// <param name="attributeId">101 火,105 水,109 木</param> + /// <param name="worldPos">世界坐标</param> + public void PlayToAttackEffect(int attributeId, Vector3 worldPos) + { + string path = $"UI/ToBattle_{attributeId}"; + GameObject prefab = Resources.Load<GameObject>(path); + 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> /// Raycast onto tower placement areas /// </summary> /// <param name="pointer">The pointer we're testing</param> -- Gitblit v1.9.1