From 452c75675679c44cc39b04bdb7d330d7c5c14d5c Mon Sep 17 00:00:00 2001 From: wangguan <wangguan@kt007.com> Date: Tue, 29 Dec 2020 10:48:06 +0800 Subject: [PATCH] 增加多SDK支持。常规使用SDKChannel.KTGM 偶哈游的是空SDK --- Assets/Scripts/TowerDefense/Level/EndlessWaveLineManager.cs | 94 +++++++++++++++++++++++++++++------------------ 1 files changed, 58 insertions(+), 36 deletions(-) diff --git a/Assets/Scripts/TowerDefense/Level/EndlessWaveLineManager.cs b/Assets/Scripts/TowerDefense/Level/EndlessWaveLineManager.cs index f0735f7..9e78060 100644 --- a/Assets/Scripts/TowerDefense/Level/EndlessWaveLineManager.cs +++ b/Assets/Scripts/TowerDefense/Level/EndlessWaveLineManager.cs @@ -19,17 +19,17 @@ /// <summary> /// 火攻击效果 /// </summary> - public ParticleSystem skillFirePrefab; + public GameObject skillFirePrefab; /// <summary> /// 炸弹攻击效果 /// </summary> - public ParticleSystem skillBombPrefab; + public GameObject skillBombPrefab; /// <summary> /// 停止移动的Buff特效. /// </summary> - public ParticleSystem bufStopMovePrefab; + public GameObject bufStopMovePrefab; protected bool zeroState = true; @@ -53,10 +53,36 @@ { if (id >= waveLineList.Count || waveLineList[id] == null) return; - ParticleSystem playParticle = Instantiate(skillFirePrefab); - playParticle.transform.position = EndlessLevelManager.instance.WaveManager.GetWaveEndPos(id); - playParticle.Play(); - Destroy(playParticle.gameObject, playParticle.main.duration); + GameObject obj = Instantiate(skillFirePrefab); + ParticleSystem ps = obj.GetComponent<ParticleSystem>(); + + if (ps == null) + ps = obj.transform.GetChild(0).GetComponent<ParticleSystem>(); + ps.transform.position = EndlessLevelManager.instance.WaveManager.GetWaveEndPos(id); + ps.Play(); + AudioSourceManager.Ins.Play(AudioEnum.FireSkill); + + Destroy(obj, 5f); + } + + /// <summary> + /// 在所有兵线上播放特效 + /// </summary> + public void PlayAllWaveLineEffect() + { + for (int i = 0; i < waveLineList.Count; i++) + { + GameObject obj = Instantiate(skillFirePrefab); + ParticleSystem ps = obj.GetComponent<ParticleSystem>(); + + if (ps == null) + ps = obj.transform.GetChild(0).GetComponent<ParticleSystem>(); + ps.transform.position = EndlessLevelManager.instance.WaveManager.GetWaveEndPos(i); + ps.Play(); + + Destroy(obj, 5f); + } + AudioSourceManager.Ins.Play(AudioEnum.FireSkill); } /// <summary> @@ -66,10 +92,17 @@ public void PlayBattleAreaBombEffect(Vector3 pos) { if (skillBombPrefab == null) return; - ParticleSystem playParticle = Instantiate(skillBombPrefab); - playParticle.transform.position = pos; - playParticle.Play(); - Destroy(playParticle.gameObject, playParticle.main.duration); + + GameObject obj = Instantiate(skillBombPrefab); + ParticleSystem ps = obj.GetComponent<ParticleSystem>(); + + if (ps == null) + ps = obj.transform.GetChild(0).GetComponent<ParticleSystem>(); + ps.transform.position = pos; + ps.Play(); + AudioSourceManager.Ins.Play(AudioEnum.LightningSkill); + + Destroy(obj, 5f); } /// <summary> @@ -94,40 +127,29 @@ } /// <summary> - /// 对某一条兵线显示选中效果 + /// 设置某条兵线选中效果 /// </summary> - /// <param name="id"></param> - public void FadeWaveline(int id, bool fadeOut, float ftime = 0.3f) + /// <param name="waveIndex">兵线索引 从0开始</param> + /// <param name="show">是否显示</param> + public void SetWaveLineShow(int waveIndex, bool show) { - if (id >= waveLineList.Count || waveLineList[id] == null) return; - Material tmat = waveLineList[id].GetComponent<MeshRenderer>().material; - if (fadeOut) - tmat.DOColor(new Color(1.0f, 1.0f, 1.0f, 1.0f), ftime); - else - tmat.DOColor(new Color(1.0f, 1.0f, 1.0f, 0.0f), ftime); + if (waveIndex >= waveLineList.Count || waveLineList[waveIndex] == null) return; + + Material tmat = waveLineList[waveIndex].GetComponent<MeshRenderer>().material; + + float targetAlpha = show ? 1f : 0f; + tmat.color = new Color(1f, 1f, 1f, targetAlpha); } /// <summary> /// 某一个位置攻击塔位放下。 /// </summary> /// <param name="pos"></param> - public void AttackTowerFixed(int pos) + public void AttackTowerFixed(int pos, bool playEffect = true) { - if (pos >= waveLineList.Count || waveLineList[pos] == null) return; + if (pos >= waveLineList.Count || waveLineList[pos] == null || !playEffect) return; - int subone = pos - 1; - int addone = pos + 1; - - if (subone >= 0) - WaveLineFlash(subone); + // 无尽模式改为只有一条兵线 WaveLineFlash(pos); - if (addone < waveLineList.Count) - WaveLineFlash(addone); } - - // Update is called once per frame - void Update() - { - - } -} +} \ No newline at end of file -- Gitblit v1.9.1