public void KillGameAndBringBackMainMenu() { gameRoot.pilotCamera.FadeOut(1f, () => { gameRoot.pilotCamera.gameObject.SetActive(false); uiCamera.gameObject.SetActive(true); //MusicManager.instance.FadeToMusic(Music.MenuMusic, 1f); Destroy(gameRoot.gameObject); gameRoot = null; FadeInMainMenu(); PauseManager.instance.GameKilled(); }); }
private IEnumerator StartGameCoroutine() { //MusicManager.instance.FadeOut(1f); UICursorManager.instance.HideCursor(); UIMainMenuWindow.instance.FadeOut(); var sequence = DOTween.Sequence(); sequence.Insert(0, gameLogoSmall.DOFade(0f, 1f)); sequence.Insert(0, copyrightText.DOFade(0f, 1f)); sequence.OnComplete(() => { gameLogoSmall.gameObject.SetActive(false); copyrightText.gameObject.SetActive(false); }); var loadTask = Application.LoadLevelAdditiveAsync("AlphaGameScene"); while (!loadTask.isDone) yield return null; uiCamera.gameObject.SetActive(false); // Unity requires one frame to initialize loaded scene objects. yield return null; gameRoot = FindObjectOfType<GameRoot>(); if (gameRoot == null) throw new Exception("Game root object not found after loading."); gameRoot.pilotCamera.gameObject.SetActive(true); matchManager = FindObjectOfType<SurvivalMatchManager>(); if (matchManager == null) throw new Exception("Match manager not found after loading."); // Do an extra interval, just to be dramatic. yield return new WaitForSeconds(1); AudioManager.instance.Play(AudioBank.MUS_NONE, this.gameObject); AudioManager.instance.Play(AudioBank.GAME_MUSIC, this.gameObject); //MusicManager.instance.PlayIntroThenLooped(Music.InGameMusicIntro, Music.InGameMusic); gameRoot.pilotCamera.FadeIn(1f, () => { gameRoot.playerShipController.lockControls = false; state = States.Game; }); }