using Core.Utilities;
|
using DG.Tweening;
|
using System.Collections.Generic;
|
using TowerDefense.Level;
|
using UnityEngine;
|
|
public class EndlessWaveLineManager : Singleton<EndlessWaveLineManager>
|
{
|
/// <summary>
|
/// 兵线对应的选中效果
|
/// </summary>
|
public List<GameObject> waveLineList;
|
|
/// <summary>
|
/// 标注战场区域的Object.
|
/// </summary>
|
public GameObject battleAreaObject;
|
|
/// <summary>
|
/// 火攻击效果
|
/// </summary>
|
public GameObject skillFirePrefab;
|
|
/// <summary>
|
/// 炸弹攻击效果
|
/// </summary>
|
public GameObject skillBombPrefab;
|
|
/// <summary>
|
/// 停止移动的Buff特效.
|
/// </summary>
|
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<MeshRenderer>().material;
|
tmat.color = new Color(1.0f, 1.0f, 1.0f, 0.0f);
|
}
|
}
|
}
|
|
/// <summary>
|
/// 在某一兵线上播放技能特效
|
/// </summary>
|
public void PlayWaveLineEffect(int id)
|
{
|
if (id >= waveLineList.Count || waveLineList[id] == null) return;
|
|
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();
|
Destroy(obj, ps.main.duration);
|
}
|
|
/// <summary>
|
/// 在战场内某一个位置播放特效
|
/// </summary>
|
/// <param name="pos"></param>
|
public void PlayBattleAreaBombEffect(Vector3 pos)
|
{
|
if (skillBombPrefab == null) return;
|
|
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();
|
Destroy(obj, ps.main.duration);
|
}
|
|
/// <summary>
|
/// 对应兵线发亮.
|
/// </summary>
|
/// <param name="id"></param>
|
public void WaveLineFlash(int id)
|
{
|
if (id >= waveLineList.Count || waveLineList[id] == null) return;
|
|
//设置一个DOTween队列
|
Sequence flashSeq = DOTween.Sequence();
|
Material tmat = waveLineList[id].GetComponent<MeshRenderer>().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));
|
}
|
|
/// <summary>
|
/// 对某一条兵线显示选中效果
|
/// </summary>
|
/// <param name="id"></param>
|
public void FadeWaveline(int id, bool fadeOut, float ftime = 0.3f)
|
{
|
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);
|
}
|
|
/// <summary>
|
/// 某一个位置攻击塔位放下。
|
/// </summary>
|
/// <param name="pos"></param>
|
public void AttackTowerFixed(int pos)
|
{
|
if (pos >= waveLineList.Count || waveLineList[pos] == null) return;
|
|
// 无尽模式改为只有一条兵线
|
WaveLineFlash(pos);
|
}
|
}
|