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