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;
        }