using Core.Utilities;
|
using TowerDefense.Nodes;
|
using UnityEngine;
|
|
namespace TowerDefense.Level
|
{
|
/// <summary>
|
/// A wave implementation that triggers the waveCompleted event after an elapsed amount of time
|
/// </summary>
|
public class TimedWave : Wave
|
{
|
/// <summary>
|
/// The time until the next wave is started
|
/// </summary>
|
[Tooltip("The time until the next wave is started")]
|
public float timeToNextWave = 10f;
|
|
/// <summary>
|
/// The timer used to start the next wave
|
/// </summary>
|
protected Timer m_WaveTimer;
|
|
/// <summary>
|
/// 重新实现初始化刷怪指令
|
/// </summary>
|
protected override void initAgentInstructionList()
|
{
|
base.initAgentInstructionList();
|
this.timeToNextWave = this.totalWaveTime;
|
}
|
|
/// <summary>
|
/// Initializes the Wave
|
/// </summary>
|
public override void Init( Node snode,int waveLine )
|
{
|
base.Init( snode,waveLine );
|
|
if (spawnInstructions.Count > 0)
|
{
|
m_WaveTimer = new Timer(timeToNextWave, SafelyBroadcastWaveCompletedEvent);
|
StartTimer(m_WaveTimer);
|
}
|
}
|
|
/// <summary>
|
/// Handles spawning the current agent and sets up the next agent for spawning
|
/// </summary>
|
protected override void SpawnCurrent()
|
{
|
Spawn();
|
if (!TrySetupNextSpawn())
|
{
|
StopTimer(m_SpawnTimer);
|
}
|
}
|
}
|
}
|