using Core.Utilities; using DG.Tweening; using System.Collections.Generic; using TowerDefense.Level; using UnityEngine; public class EndlessWaveLineManager : Singleton { /// /// 兵线对应的选中效果 /// public List waveLineList; /// /// 标注战场区域的Object. /// public GameObject battleAreaObject; /// /// 火攻击效果 /// public ParticleSystem skillFirePrefab; /// /// 炸弹攻击效果 /// public ParticleSystem skillBombPrefab; /// /// 停止移动的Buff特效. /// public ParticleSystem bufStopMovePrefab; protected bool zeroState = true; // Start is called before the first frame update void Start() { for (int ti = 0; ti < waveLineList.Count; ti++) { if (waveLineList[ti]) { Material tmat = waveLineList[ti].GetComponent().material; tmat.color = new Color(1.0f, 1.0f, 1.0f, 0.0f); } } } /// /// 在某一兵线上播放技能特效 /// public void PlayWaveLineEffect(int id) { 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); } /// /// 在战场内某一个位置播放特效 /// /// 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); } /// /// 对应兵线发亮. /// /// public void WaveLineFlash(int id) { if (id >= waveLineList.Count || waveLineList[id] == null) return; //设置一个DOTween队列 Sequence flashSeq = DOTween.Sequence(); Material tmat = waveLineList[id].GetComponent().material; flashSeq.Append(tmat.DOColor(new Color(1.0f, 1.0f, 1.0f, 1.0f), 0.1f)); flashSeq.Append(tmat.DOColor(new Color(1.0f, 1.0f, 1.0f, 0.2f), 0.08f)); flashSeq.Append(tmat.DOColor(new Color(1.0f, 1.0f, 1.0f, 1.0f), 0.08f)); flashSeq.AppendInterval(0.05f); flashSeq.Append(tmat.DOColor(new Color(1.0f, 1.0f, 1.0f, 0.2f), 0.08f)); flashSeq.Append(tmat.DOColor(new Color(1.0f, 1.0f, 1.0f, 1.0f), 0.08f)); flashSeq.AppendInterval(0.05f); flashSeq.Append(tmat.DOColor(new Color(1.0f, 1.0f, 1.0f, 0.0f), 0.25f)); } /// /// 对某一条兵线显示选中效果 /// /// public void FadeWaveline(int id, bool fadeOut, float ftime = 0.3f) { if (id >= waveLineList.Count || waveLineList[id] == null) return; Material tmat = waveLineList[id].GetComponent().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); } /// /// 某一个位置攻击塔位放下。 /// /// public void AttackTowerFixed(int pos) { if (pos >= waveLineList.Count || waveLineList[pos] == null) return; int subone = pos - 1; int addone = pos + 1; if (subone >= 0) WaveLineFlash(subone); WaveLineFlash(pos); if (addone < waveLineList.Count) WaveLineFlash(addone); } }