Esempio n. 1
0
    void Update()
    {
        SpawnRate = 1 / SpawnPerSecond;
        T        += Time.deltaTime;
        if (T > SpawnRate && EnemiesSpawnedThisWave < WaveNumber * EnemiesPerWave)
        {
            EnemiesSpawnedThisWave++;
            SpawnZones.SpawnEnemy();
            T          = 0;
            RoundTimer = 0;
        }

        WaveProgress = EnemiesDead / (WaveNumber * EnemiesPerWave);
        WaveBar.SetSize(WaveProgress);
        if (WaveProgress == 1)
        {
            WaveText.text = "Wave Complete! New wave starting soon.";
            RoundTimer   += Time.deltaTime;
            if (RoundTimer > 2.5f)
            {
                WaveNumber++;
                SpawnPerSecond        += SpawnRateIncrease;
                EnemiesDead            = 0;
                EnemiesSpawnedThisWave = 0;
                WaveText.text          = "Wave: " + WaveNumber.ToString();
            }
        }
    }
Esempio n. 2
0
 private void Update()
 {
     lastSpawn += Time.deltaTime * spawnRate;
     while (lastSpawn >= 1)
     {
         lastSpawn -= 1f;
         if (unitSpawn > 0 || !haswaves)
         {
             unitSpawn--;
             zone.SpawnEnemy();
         }
         else
         {
             break;
         }
     }
     if (Input.GetKeyDown(KeyCode.K))
     {
         zone.SpawnEnemy();
     }
 }