private void Awake()
    {
        Instance       = this;
        scoreText.text = score.ToString();
        playerMotor    = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMotor>();
        cameraMotor    = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraMotor>();
        compMotor      = GameObject.FindGameObjectWithTag("Companion").GetComponent <CompanionMotor>();

        isEndless = SceneController.getIsEndless();

        if (Settings.isMusicOn.Value)
        {
            AudioSource[] audios = FindObjectsOfType <AudioSource>();
            foreach (AudioSource audio in audios)
            {
                if (audio.CompareTag("Music"))
                {
                    musicPlayer = audio;
                }
            }

            StartCoroutine(AudioController.FadeOut(musicPlayer, 0.5f));
        }

        if (!isEndless)
        {
            startCutscene.Begin();
        }
        else
        {
            informationText.text = "Touch to start";
        }
    }
예제 #2
0
    public void StopGameIfNotEndless(GameObject endSegment)
    {
        if (!isEndless)
        {
            //set the dialogue animator to open true
            DialogueAnimator.SetBool("isOpen", true);

            done       = true;
            isGameOver = true;

            //find the gorillaposition and use it to start the end 3D cutscene
            Transform gorillaPosition = endSegment.transform.Find("GorillaPosition");
            compMotor.DoEndSequence(gorillaPosition);

            isGameStarted = false;
            cameraMotor.MoveToCutscenePos(endSegment.transform.Find("CameraPosition"));
            endCutscene.Begin();
            StartCoroutine(AudioController.FadeOut(musicPlayer, 0.5f));
        }
    }
예제 #3
0
    private void Awake()
    {
        Instance = this;
        //initialise fields
        playerMotor        = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMotor>();
        cameraMotor        = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraMotor>();
        compMotor          = GameObject.FindGameObjectWithTag("Companion").GetComponent <GorillaMotor>();
        scoreText.text     = score.ToString("0");
        seedCountText.text = seeds.ToString();

        isEndless = SceneController.getIsEndless();

        if (Settings.isMusicOn.Value)
        {//checking for music
            AudioSource[] audios = FindObjectsOfType <AudioSource>();
            foreach (AudioSource audio in audios)
            {
                if (audio.CompareTag("Music"))
                {
                    musicPlayer = audio;
                }
            }

            StartCoroutine(AudioController.FadeOut(musicPlayer, 0.5f));
        }

        heart1.gameObject.SetActive(true);
        heart2.gameObject.SetActive(true);
        heart3.gameObject.SetActive(true);

        if (!isEndless)//if not endless
        {
            informationText.text = "";
            startCutscene.Begin(); //start the cutscene
        }
        else
        {
            informationText.text = "Tap Anywhere To Begin!"; //or start directly
        }
    }
예제 #4
0
    /* This method is run before the first frame update, it intialises all necessary variables */
    private void Awake()
    {
        Instance             = this;
        pollutionSlide.value = TrashSpawner.garbageMultiplier;
        playerMotor          = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMotor>();
        cameraMotor          = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraMotor>();
        compMotor            = GameObject.FindGameObjectWithTag("Companion").GetComponent <CompanionMotor>();
        scoreText.text       = score.ToString("0");
        garbageText.text     = garbage.ToString();

        isEndless = SceneController.getIsEndless();

        // Initialise music
        if (Settings.isMusicOn.Value)
        {
            AudioSource[] audios = FindObjectsOfType <AudioSource>();
            foreach (AudioSource audio in audios)
            {
                if (audio.CompareTag("Music"))
                {
                    musicPlayer = audio;
                }
            }

            StartCoroutine(AudioController.FadeOut(musicPlayer, 0.5f));
        }

        heart1.gameObject.SetActive(true);
        heart2.gameObject.SetActive(true);
        heart3.gameObject.SetActive(true);

        // If its endless you skip all cutscenes
        if (!isEndless)
        {
            startCutscene.Begin();
        }
    }
    private void Update()
    {
        if (!isGameStarted && !DialogueAnimator.GetBool("isOpen") && score > scoreOnFinish && !isEndless)
        {
            isGameOver = true;
            SceneManager.LoadScene("Beach");
            return;
        }

        if (!isGameOver)
        {
            if (Input.anyKey && !isGameStarted && !DialogueAnimator.GetBool("isOpen"))
            {
                isGameStarted = true;
                playerMotor.StartRunning();
                cameraMotor.StartFollowing();
                compMotor.StartRunning();

                if (Settings.isMusicOn.Value)
                {
                    audioPlayer = GameObject.FindGameObjectWithTag("SoundController");
                    Music music = audioPlayer.GetComponent <Music>();
                    music.changeMusic(SceneManager.GetActiveScene());
                }
            }
        }



        if (isGameStarted)
        {
            score         += Time.deltaTime;
            scoreText.text = score.ToString("0");

            if (!isEndless)
            {
                if (score > scoreOnFinish)
                {
                    isGameStarted = false;
                    isGameOver    = true;
                    playerMotor.StopRunning();
                    cameraMotor.StopFollowing();
                    compMotor.StopRunning();
                    DialogueAnimator.SetBool("isOpen", true);
                    endCutscene.Begin();
                    if (Settings.isMusicOn.Value)
                    {
                        StartCoroutine(AudioController.FadeOut(musicPlayer, 0.5f));
                    }
                }
                else if (score > 40)
                {
                    informationText.text = "The ice has all melted away!";
                }
                else if (score > 30)
                {
                    informationText.text = "The mountains are collapsing!";
                }
                else if (score > 12)
                {
                    informationText.text = "Careful! The water is toxic.";
                }
                else if (score > 8)
                {
                    informationText.text = "Swipe up to jump";
                }
                else if (score > 3)
                {
                    informationText.text = "Swipe down to slide";
                }
                else if (score > 0)
                {
                    informationText.text = "Swipe to move";
                }
            }
            else
            {
                informationText.text = null;
            }
        }
    }
예제 #6
0
    /* This method is run every frame */
    private void Update()
    {
        // Goes to the next level in the story if the user has met the conditions
        if (!isGameStarted && !DialogueAnimator.GetBool("isOpen") && score > 120 && !isEndless)
        {
            isGameOver = true;
            SceneManager.LoadScene("Forest");
            return;
        }

        // Starts the game after the user has run through the initial text.
        if (!isGameOver)
        {
            if (Input.anyKey && !isGameStarted && !DialogueAnimator.GetBool("isOpen"))
            {
                isGameStarted = true;
                playerMotor.StartRunning();
                cameraMotor.StartFollowing();
                compMotor.StartRunning();

                if (Settings.isMusicOn.Value)
                {
                    audioPlayer = GameObject.FindGameObjectWithTag("SoundController");
                    Music music = audioPlayer.GetComponent <Music>();
                    music.changeMusic(SceneManager.GetActiveScene());
                }
                FindObjectOfType <CameraMotor>().isFollowing = true;
            }

            // Updates score and other variables if the game is running
            if (isGameStarted)
            {
                score                     += (Time.deltaTime * modifier);
                scoreText.text             = score.ToString("0");
                timeSinceGarbageCollected += Time.deltaTime;
                if (timeSinceGarbageCollected > 3.5f)
                {
                    garbageCollected          = false;
                    timeSinceGarbageCollected = 0.0f;
                }

                // Ends the game when the user has reached the end.
                if (!isEndless)
                {
                    if (score > 100 && !isFinished)
                    {
                        isGameStarted = false;
                        playerMotor.StopRunning();
                        compMotor.StopRunning();
                        cameraMotor.StopFollowing();
                        DialogueAnimator.SetBool("isOpen", true);
                        isFinished = true;
                        isGameOver = true;
                        if (TrashSpawner.garbageMultiplier <= 0.5f)
                        {
                            endCutscene.Begin();
                        }
                        else
                        {
                            lostGame = true;
                            lossCutscene.Begin();
                        }

                        if (Settings.isMusicOn.Value)
                        {
                            StartCoroutine(AudioController.FadeOut(musicPlayer, 0.5f));
                        }
                    }
                }
            }
        }

        if (lostGame && !DialogueAnimator.GetBool("isOpen") && !openedDeathMenu)
        {
            openedDeathMenu = true;
            OnDeath();
        }

        if (!lostGame && !DialogueAnimator.GetBool("isOpen") && isFinished)
        {
            isGameOver = true;
            SceneManager.LoadScene("Forest");
        }
    }