Пример #1
0
    //count the time and displays it until
    //the next wave starts
    public void CountingForNextWave()
    {
        //If countdown is over, we play the new wave music and start the monster spawns
        if (waveCountdown <= 0)
        {
            //the player is healed at the end of the wave
            GameObject.FindGameObjectWithTag("Hud").GetComponent <PlayerHealth>().RestoreHealth();

            GameObject.FindGameObjectWithTag("MainCamera").GetComponent <SoundManagerGlobal>().NewWaveMusic();
            nextWaveStart = false;
            StartCoroutine(GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraFlashAndShake>().FlashAndShake(1.5f, 2.0f));
            StartCoroutine(SpawnWave(waves[nextWave]));
        }
        else
        {
            waveCountdown = Mathf.Max(waveCountdown - Time.deltaTime, 0f);

            if (m_chrono)
            {
                if (waveCountdown > timeBetweenWaves && !nextWaveStart && !EnemyIsAlive())
                {
                    waveCountdown = timeBetweenWaves;
                    nextWaveStart = true;
                }
                else
                {
                    m_chrono.setTimeText(waveCountdown);
                }

                //when the chrono is close to 0
                if (waveCountdown < 5f)
                {
                    m_chrono.AlertMode();
                }
            }
        }
    }