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 GameObject skillFirePrefab; /// /// 炸弹攻击效果 /// public GameObject skillBombPrefab; /// /// 停止移动的Buff特效. /// public GameObject 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; GameObject obj = Instantiate(skillFirePrefab); ParticleSystem ps = obj.GetComponent(); if (ps == null) ps = obj.transform.GetChild(0).GetComponent(); ps.transform.position = EndlessLevelManager.instance.WaveManager.GetWaveEndPos(id); ps.Play(); Destroy(obj, ps.main.duration); } /// /// 在战场内某一个位置播放特效 /// /// public void PlayBattleAreaBombEffect(Vector3 pos) { if (skillBombPrefab == null) return; GameObject obj = Instantiate(skillBombPrefab); ParticleSystem ps = obj.GetComponent(); if (ps == null) ps = obj.transform.GetChild(0).GetComponent(); ps.transform.position = pos; ps.Play(); Destroy(obj, ps.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; // 无尽模式改为只有一条兵线 WaveLineFlash(pos); } }