Exemple #1
0
    public IEnumerator GremlinArrival(float lengthOfLaugh)
    {
        /////////Stop timer

        //Find the fading object
        var fader = GameObject.Find("FadingImage").GetComponent <FadeToBlack>();

        //Activate the fader's fade, check FadeToBlack script for more information
        fader.Fade(true, 3);

        //Play Thunder Sound
        soundEffects.PlayThunderClap();

        //Wait the same time as the fade
        yield return(new WaitForSeconds(3));

        //Play Gremlin Laugh sound
        soundEffects.PlayGremlinLaugh();

        //Wait for length of the sound
        yield return(new WaitForSeconds(lengthOfLaugh));

        //Activate the randomise function for randomising the variables
        RandomiseVariables();
        //Turns off lights
        variables.lights = false;
        //Changes scene to the front desk
        SceneManager.LoadScene(sceneName: "03_FrontDesk");
        //Enables the Text box, then waits 4 seconds then destroys it
        yield return(new WaitForSeconds(0.4f));

        var textBox = GameObject.Find("TextboxCanvas");

        textBox.transform.GetChild(0).gameObject.SetActive(true);
        textBox.transform.GetChild(1).gameObject.SetActive(true);
        yield return(new WaitForSeconds(4));

        textBox.transform.GetChild(0).gameObject.SetActive(false);
        textBox.transform.GetChild(1).gameObject.SetActive(false);
        //Finishes coroutine
        yield return(null);
    }