void Update()
 {
     if (checkWinCondition)
     {
         CheckWinCondition();
     }
     if (!levelInProgress)
     {
         return;
     }
     currentTime += Time.deltaTime;
     if (waitForNextWave)
     {
         if (currentTime > spawnWaves[currentWave].waveDelay)
         {
             UICanvas.Instance.UpdateWaveText(currentWave + 1);
             waitForNextWave = false;
             currentTime     = 0;
         }
         return;
     }
     if (currentTime > spawnWaves[currentWave].spawnChunks[currentChunk].spawnDelay + timeShift)
     {
         SpawnChunk chunk = spawnWaves[currentWave].spawnChunks[currentChunk];
         for (int i = 0; i < chunk.spawnAmount; i++)
         {
             chunk.spawnAt.SpawnEnemy(spawnWaves[currentWave].spawnChunks[currentChunk].spawnEnemy);
         }
         timeShift += chunk.spawnDelay;
         currentChunk++;
         if (currentChunk >= spawnWaves[currentWave].spawnChunks.Count)
         {
             waitForNextWave = true;
             currentWave++;
             currentTime  = 0;
             timeShift    = 0;
             currentChunk = 0;
             if (currentWave >= spawnWaves.Count)
             {
                 checkWinCondition = true;
                 levelInProgress   = false;
                 currentWave       = 0;
             }
         }
     }
 }
Esempio n. 2
0
 private void Start()
 {
     _spawnChunk  = GameObject.FindWithTag("ChunkSpawner").GetComponent <SpawnChunk>();
     _player      = GameObject.FindWithTag("Player");
     _normalSpeed = speed;
 }