Example #1
0
    IEnumerator Transition()
    {
        transitioning = true;

        if (transitionReason == TransitionReason.levelSuccess)
        {
            // Tells LoadLevel a level has been completed, and returns whether that was the last level
            // gameCompleted = LoadLevel.LevelCompleted();
            levelManager.LevelCompleted();
            gameCompleted = levelManager.CheckForGameOver();
        }

        if (transitionReason == TransitionReason.levelLoad)
        {
            // Tells LoadLevel a level has been completed, and returns whether that was the last level
            // gameCompleted = LoadLevel.LevelCompleted();
            // levelManager.LevelCompleted();
            gameReset = levelManager.CheckForGameOver();

            if (gameReset == true)
            {
                // statsManager.ClearModeStats(modeManager.GetMode());
                levelManager.ResetModeLevels();
            }

            if (modeManager.GetMode() == Mode.Time && timeChallengeManager.CheckResetNeed() == true)
            {
                levelManager.ResetModeLevels();
            }

            if (modeManager.GetMode() == Mode.Lives && livesChallengeManager.CheckResetNeed() == true)
            {
                levelManager.ResetModeLevels();
            }
        }

        if (transitionReason == TransitionReason.levelFailure)
        {
            if (modeManager.GetMode() == Mode.OneShot)
            {
                gameOver = true;
            }

            if (modeManager.GetMode() == Mode.Time && timeChallengeManager.GetTime() <= 0)
            {
                gameOver = true;
            }

            if (modeManager.GetMode() == Mode.Lives && livesChallengeManager.GetLives() <= 0)
            {
                gameOver = true;
            }
        }

        // if (transitionReason == TransitionReason.levelSuccess)
        // {
        // // Reset Game if you start to play and levels are all complete
        // if (LoadLevel.CheckComplete())
        // {
        // LoadLevel.Reset();
        // // Debug.Log("R");
        // }
        // }

        // Debug.Log("About To Start Phase One");
        // Debug.Break();

        // HANGS AFTER HERE

        yield return(transitionScreen.StartPhaseOne());

        // Debug.Log("Just After Phase One");
        // Debug.Break();

        transitionText.UpdateText();
        string text = transitionText.GetText();

        // string text = "Hello There";


        MinMax waitTime     = new MinMax(0.25f, 1f);
        MinMax stringLength = new MinMax(8, 30);

        float lerpValue = Mathf.InverseLerp(stringLength.min, stringLength.max, text.Length);

        float actualWaitTime = Mathf.Lerp(waitTime.min, waitTime.max, lerpValue);

        // Debug.Log("Wait Time: " + actualWaitTime);

        // yield return transitionScreen.StartPhaseOne();

        // BUT BEFORE HERE

        // Debug.Log("About To Start Phase Two");
        // Debug.Break();

        yield return(transitionScreen.StartPhaseTwo(actualWaitTime));

        // if (gameCompleted)
        // {
        // levelManager.ClearLevel();
        // }

        yield return(transitionScreen.StartPhaseThree());

        if (gameCompleted == false && gameOver == false)
        {
            GameStates.ChangeState("Playing");
        }
        else
        {
            GameStates.ChangeState("Complete");
        }

        Messenger.Broadcast("StopConstantShake");
        // Debug.Log("Transition Done");

        // Debug.Log("T Still running y'all");

        transitioning = false;

        yield return(null);
    }