Ejemplo n.º 1
0
    void Update()
    {
        timer += Time.deltaTime;

        if (startWaveTimer)
        {
            waveTimer += Time.deltaTime;
        }

        if (timer >= spawnRate && spawnedEnemies < enemiesToSpawn && enableSpawning)
        {
            SpawnEnemy();
        }

        if (enemiesLeft > 0)
        {
            enemiesLeftCounter.text = "Enemies Left: " + enemiesLeft.ToString();
        }
        else
        {
            if (!hasCompletedWave)
            {
                hasCompletedWave = true;
                startWaveTimer   = true;
            }

            if (waveTimer >= restTime)
            {
                StartNewWave();
            }

            nextWaveTimer           = Mathf.RoundToInt(restTime - waveTimer);
            enemiesLeftCounter.text = "Next Wave Starts In: " + DarkRef.GetTimerFormat(nextWaveTimer);
        }
    }