private float ProgressWave(float deltaTime)
 {
     wave      = scenario.waves[waveIndex];
     deltaTime = ProgressSequence(deltaTime);
     while (deltaTime >= 0f)
     {
         if (++sequenceIndex >= wave.spawnSequences.Length)
         {
             sequenceIndex = 0;
             return(deltaTime);
         }
         sequence  = wave.spawnSequences[sequenceIndex];
         deltaTime = ProgressSequence(deltaTime);
     }
     return(-1f);
 }
 private float ProgressSequence(float deltaTime)
 {
     sequence  = wave.spawnSequences[sequenceIndex];
     cooldown += deltaTime;
     while (cooldown >= sequence.cooldown)
     {
         cooldown -= sequence.cooldown;
         if (count >= sequence.amount)
         {
             count = 0;
             return(cooldown);
         }
         count += 1;
         SpawnEnemy(sequence.factory, sequence.type);
     }
     return(-1f);
 }
 public State(EnemySpawnSequence sequence)
 {
     this.sequence = sequence;
     count         = 0;
     cooldown      = sequence.cooldown;
 }
 void Awake()
 {
     wave           = scenario.waves[0];
     sequence       = wave.spawnSequences[0];
     gameObject.tag = "Spawn";
 }