Example #1
0
    IEnumerator CrashingOccuring()
    {
        yield return(new WaitForSeconds(.5f)); // a slight delay

        //Grab all the information needed for the game to feign crashing and play those animations
        GlobalVars.isCrashing = true;
        player.GetComponent <BoxCollider2D>().enabled = false;
        GameObject panel = GameObject.FindGameObjectWithTag("ConvoPanel");

        panel.GetComponent <Animator>().Play("crashingText");
        player.transform.Find("Up").GetComponent <Animator>().Play("crashingUp");
        player.transform.Find("Left").GetComponent <Animator>().Play("crashingLeft");
        player.transform.Find("Right").GetComponent <Animator>().Play("crashingRight");
        player.transform.Find("Down").GetComponent <Animator>().Play("crashingDown");

        SoundMixer mixer = Camera.main.GetComponent <SoundMixer>(); //start scrambling the sound as well

        if (mixer != null)
        {
            mixer.changeChance = 1;
            mixer.ActivateScramble();
        }


        yield return(new WaitForSeconds(7.0f)); //wait for the animations to play out

        //Set up the rest of the vars so that the game is now Scrambled
        GlobalVars.isTutorial = false;
        GlobalVars.isCrashing = false;
        GoalTimes.ChangeScene();
        SceneManager.LoadScene(0);
    }