wangguan
2020-11-06 fc40dea934140005aeb62ac1e4ec1e613cc44a0c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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);
            }
        }
    }
}