Exemple #1
0
        IEnumerator PreNextLevel()
        {
            // * 1 - pause all gameObjects
            yield return(StartCoroutine(WaitForPause()));

            ToggleGamePaused();
            LockPause();
            yield return(null);

            // * 2 is this GameOver ?
            if (currentHandle is MadnessHandle)
            {
                MadnessHandle handle = (MadnessHandle)currentHandle;
                yield return(StartCoroutine(saveManager.CheckIsGameOver(handle.checkpoint)));

                if (saveManager.GetIsGameOver())
                {
                    yield return(StartCoroutine(GameOver()));
                }
                else
                {
                    yield return(StartCoroutine(NextLevel()));
                }
            }
            else
            {
                yield return(StartCoroutine(NextLevel()));
            }

            // * 8 resume all gameObjects
            UnLockPause();
            ToggleGamePaused();
            yield return(null);


            // * 9 set some UI stuff
            HudScript.hud.UpdateKeyStatus(false);

            // * 10 freeze player and reset controls for 10 frames
            PlayerInstanciationScript.clipManager.Freeze();
            for (int _ = 0; _ < 10; _++)
            {
                KeyMapper.ResetAll();
                yield return(null);
            }
            PlayerInstanciationScript.clipManager.UnFreeze();
            if (currentHandle.buildIndex == 0)
            {
                PlayerInstanciationScript.player.Sleep();
            }
            PlayerInstanciationScript.movementModifier.ResetSensors();
            PlayerInstanciationScript.hpManager.ResetImmunity();
            PlayerInstanciationScript.hpManager.SetMadness(false);
            isLoading = false;
        }
Exemple #2
0
        IEnumerator HubReturn(bool fromMenu)
        {
            // * 1 - pause all gameObjects
            yield return(StartCoroutine(WaitForPause()));

            ToggleGamePaused();
            LockPause();
            yield return(null);

            // * 2 - play first part of the loading animation (hides the screen)
            LoadingOverlay.overlay.Play(LoadingOverlay.ANIMATIONS.DEATH);
            while (!LoadingOverlay.overlay.isIdle)
            {
                yield return(null);
            }

            if (!fromMenu)
            {
                LoadingOverlay.overlay.DisplayGameOver();
            }

            // * 2b pause audio
            PlayerInstanciationScript.playerAudio.Pause();

            // * 3 - wait for scene to load
            AsyncOperation levelLoad = SceneManager.LoadSceneAsync(0, LoadSceneMode.Single);

            while (!levelLoad.isDone)
            {
                yield return(null);
            }

            // * 4 - query new scene handle
            currentHandle = FindObjectOfType <LevelHandle>();
            yield return(null);

            // * 5 - put player in spawnpoint
            PlayerInstanciationScript.playerTransform.position = currentHandle.spawnpoint.position;
            PlayerInstanciationScript.movementModifier.ResetSensors();
            yield return(null);

            // * 5b - reset player HP
            PlayerInstanciationScript.hpManager.ResetHP();

            // * reset collectibles
            collectiblesInRun = 0;

            // * 5c - delay
            if (!fromMenu)
            {
                yield return(new WaitForSeconds(4f));
            }
            LoadingOverlay.overlay.RemoveIndicators();
            // * 6 - play second part of loading animation (shows screen)
            LoadingOverlay.overlay.Resume();
            while (!LoadingOverlay.overlay.isDone)
            {
                yield return(null);
            }
            LoadingOverlay.overlay.Reset();

            // * 7 - resume all gameObjects
            UnLockPause();
            ToggleGamePaused();
            yield return(null);



            // * 8 - freeze player and reset controls for 10 frames
            PlayerInstanciationScript.clipManager.Freeze();
            for (int _ = 0; _ < 10; _++)
            {
                KeyMapper.ResetAll();
                yield return(null);
            }
            PlayerInstanciationScript.clipManager.UnFreeze();
            PlayerInstanciationScript.player.Sleep();
            // FindObjectOfType<CinemachineVirtualCamera>().Follow = PlayerInstanciationScript.playerTransform;
            // // * stop timer (we don't need it in hubworld)
            // timer.StopTimer();
            PlayerInstanciationScript.movementModifier.ResetSensors();
            PlayerInstanciationScript.hpManager.ResetImmunity();
            PlayerInstanciationScript.hpManager.SetMadness(false);
            isLoading = false;
        }
Exemple #3
0
        IEnumerator LevelRestart()
        {
            // * 1 - pause all gameObjects
            yield return(StartCoroutine(WaitForPause()));

            ToggleGamePaused();
            LockPause();
            yield return(null);

            // * 2 - play first part of the loading animation (hides the screen)
            LoadingOverlay.overlay.Play(LoadingOverlay.ANIMATIONS.RESTART);
            while (!LoadingOverlay.overlay.isIdle)
            {
                yield return(null);
            }

            PlayerInstanciationScript.playerTransform.position = currentHandle.spawnpoint.position;

            // * 3 - wait for scene to load
            AsyncOperation levelLoad = SceneManager.LoadSceneAsync(currentHandle.buildIndex, LoadSceneMode.Single);

            while (!levelLoad.isDone)
            {
                yield return(null);
            }

            // * 4 - query new scene handle
            currentHandle = FindObjectOfType <LevelHandle>();
            yield return(null);

            // * 5 - put player in spawnpoint and reset collisions
            PlayerInstanciationScript.movementModifier.ResetSensors();
            yield return(null);


            // * 6 - play second part of loading animation (shows screen)
            LoadingOverlay.overlay.Resume();
            while (!LoadingOverlay.overlay.isDone)
            {
                yield return(null);
            }
            LoadingOverlay.overlay.Reset();

            // * 7 - resume all gameObjects
            UnLockPause();
            ToggleGamePaused();
            yield return(null);

            // * 7b set some UI stuff
            HudScript.hud.UpdateKeyStatus(false);
            PlayerInstanciationScript.hpManager.ResetHud();

            // * 8 - freeze player and reset controls for 10 frames
            PlayerInstanciationScript.clipManager.Freeze();
            for (int _ = 0; _ < 10; _++)
            {
                KeyMapper.ResetAll();
                yield return(null);
            }
            PlayerInstanciationScript.clipManager.UnFreeze();
            PlayerInstanciationScript.movementModifier.ResetSensors();
            PlayerInstanciationScript.hpManager.ResetImmunity();
            isLoading = false;
        }
Exemple #4
0
        IEnumerator EnterLevel(int index, bool mansion)
        {
            // * 1 - pause all gameObjects
            yield return(StartCoroutine(WaitForPause()));

            ToggleGamePaused();
            LockPause();
            yield return(null);

            // * 2 - play first part of the loading animation (hides the screen)
            LoadingOverlay.overlay.Play(LoadingOverlay.ANIMATIONS.LEVEL_ENTRY);
            while (!LoadingOverlay.overlay.isIdle)
            {
                yield return(null);
            }

            // * 3 - wait for scene to load
            AsyncOperation levelLoad = SceneManager.LoadSceneAsync(index, LoadSceneMode.Single);

            while (!levelLoad.isDone)
            {
                yield return(null);
            }

            // * 4 - query new scene handle
            currentHandle = FindObjectOfType <LevelHandle>();
            yield return(null);

            // * 5 - put player in spawnpoint and reset sensors
            PlayerInstanciationScript.playerTransform.position = currentHandle.spawnpoint.position;
            PlayerInstanciationScript.movementModifier.ResetSensors();
            yield return(null);

            // * 6 - play second part of loading animation (shows screen)
            LoadingOverlay.overlay.Resume();
            while (!LoadingOverlay.overlay.isDone)
            {
                yield return(null);
            }
            LoadingOverlay.overlay.Reset();

            // * 7 - resume all gameObjects
            UnLockPause();
            ToggleGamePaused();
            yield return(null);

            // * 7b - play audio
            if (mansion)
            {
                PlayerInstanciationScript.playerAudio.SetClip(PlayerAudioSource.CLIP.MADNESS);
            }
            else
            {
                PlayerInstanciationScript.playerAudio.SetClip(PlayerAudioSource.CLIP.MANSION);
            }
            PlayerInstanciationScript.playerAudio.Play();

            // * 8 - freeze player and reset controls for 10 frames
            PlayerInstanciationScript.clipManager.Freeze();
            for (int _ = 0; _ < 10; _++)
            {
                KeyMapper.ResetAll();
                yield return(null);
            }
            PlayerInstanciationScript.clipManager.UnFreeze();

            // * 9 - set HUD to levelMode
            HudScript.hud.ExitHub();
            timer.StartTimer();
            PlayerInstanciationScript.movementModifier.ResetSensors();
            PlayerInstanciationScript.hpManager.ResetImmunity();
            PlayerInstanciationScript.hpManager.SetMadness(mansion);
            isLoading = false;
        }