void OnGameOver(GameOverEvent evt) { if (m_GameState == GameState.Play) { // Stop colliding the camera. var cinemachineCollider = m_FreeLookCamera.GetComponent <CinemachineCollider>(); if (cinemachineCollider) { cinemachineCollider.enabled = false; } // Set game state and handle the camera accordingly. if (evt.Win) { m_GameOverSceneTime = Time.time + m_GameOverWinSceneDelay; SetGameState(GameState.Win); // Zoom in on the player. StartCoroutine(ZoomInOnPlayer()); } else { m_GameOverSceneTime = Time.time + m_GameOverLoseSceneDelay; SetGameState(GameState.Lose); // Stop following the player. m_FreeLookCamera.Follow = null; } } }
void OnGameOver(GameOverEvent evt) { if (!GameIsEnding) { GameIsEnding = true; // Remember the scene to load and handle the camera accordingly. if (evt.Win) { m_GameOverSceneToLoad = m_WinScene; m_GameOverSceneTime = Time.time + m_WinSceneDelay; // Zoom in on the player. StartCoroutine(ZoomInOnPlayer()); } else { m_GameOverSceneToLoad = m_LoseScene; m_GameOverSceneTime = Time.time + m_LoseSceneDelay; // Stop following the player. if (m_FreeLookCamera) { m_FreeLookCamera.Follow = null; } } } }
void OnGameOver(GameOverEvent evt) { if (!GameIsEnding) { GameIsEnding = true; // Remember the scene to load and handle the camera accordingly. if (evt.Win) { m_GameOverSceneToLoad = m_WinScene; m_GameOverSceneTime = Time.time + m_WinSceneDelay; // play a sound on win var audioSource = gameObject.AddComponent<AudioSource>(); audioSource.clip = victorySound; audioSource.playOnAwake = false; audioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.HUDVictory); audioSource.PlayScheduled(AudioSettings.dspTime + delayBeforeWinMessage); // create a game message var message = Instantiate(WinGameMessagePrefab).GetComponent<DisplayMessage>(); if (message) { message.delayBeforeShowing = delayBeforeWinMessage; message.GetComponent<Transform>().SetAsLastSibling(); } // Zoom in on the player. StartCoroutine(ZoomInOnPlayer()); } else { m_GameOverSceneToLoad = m_LoseScene; m_GameOverSceneTime = Time.time + m_LoseSceneDelay; // play a sound on win var audioSource = gameObject.AddComponent<AudioSource>(); audioSource.clip = loseSound; audioSource.playOnAwake = false; audioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.HUDVictory); audioSource.PlayScheduled(AudioSettings.dspTime + delayBeforeWinMessage); // Stop following the player. if (m_FreeLookCamera) { m_FreeLookCamera.Follow = null; } } } }