void Update()
    {
        if (numberEnemiesDead >= sumEnemies && ship.health.value > 0)
        {
            timer2 += Time.deltaTime;
            if (timer2 <= 0.4f) // So that originalVolume2 captured before the fade starts
            {
                timer2 = 0.5f;
                musicManager.CaptureVolume();
                //Debug.Log("Music Volume -----------------------------------------------------------------" + musicManager.originalVolume2);
            }

            timer3 += Time.deltaTime;
            if (timer3 > 0.5f)
            {
                musicManager.FadeMusicOut(5f); // this is being run every frame after enemies all die. not good.
                DestroyEnemiesLeft();          // safety catch all left behind enemies
            }

            timer += Time.deltaTime;
            if (timer > 4f)
            {
                timer = 0f;
                //Debug.Log("You Win**************************************** " + (numberEnemiesKilled).ToString());
                soundEffectsManager.audioSource.PlayOneShot(winLevelAudio, soundEffectsManager.audioSource.volume);
                levelManager.WinLevel();
                modalManager.RestartQuitNext();
                Destroy(gameObject); // This is why it is on its own GameObject
            }
        }
    }
Beispiel #2
0
    void OnShipDeath()
    {
        // When the level is lost
        musicManager.CaptureVolume();
        musicManager.StopMusicAltogether();
        soundEffectsManager.audioSource.PlayOneShot(loseLevelAudio, soundEffectsManager.audioSource.volume);

        modalManager.RestartQuit();
    }