Beispiel #1
0
    public void MainMenuButtonClick()
    {
        // Reset the game and start over
        GameManagerScript.gameManager.Reset();

        AudioManager.instance.Play("Sparkle1");

        // Change scenes back to main menu
        _menu = gameObject.GetComponent <ConsentMenuScript>();

        _menu.GoToNextScene(0);
    }
    // Update is called once per frame
    void Update()
    {
        // Android back button should go back to main menu
        if (Application.platform == RuntimePlatform.Android)
        {
            if (Input.GetKey(KeyCode.Escape))
            {
                if (audioSettingsPanel.activeInHierarchy)
                {
                    Logger.LogAudioSettings();
                    audioSettingsPanel.SetActive(false);
                }
                else
                {
                    // Change scenes back to main menu
                    menuScript.GoToNextScene(0);
                    return;
                }
            }
        }

        // if submit prompt panel is open, update the timer
        if (submitPromptOn)
        {
            submitPromptTimer += Time.deltaTime;
        }

        // Every 1/5 of a second, update the timer progress bar
        if (gameHasBegun)
        {
            timer += Time.deltaTime;
        }

        if (timer >= waitTime)
        {
            // adjust remaining time
            remainingTime -= timer;

            float scale = remainingTime / maxTime;
            if (scale < 0)
            {
                scale = 0;
            }

            // update progress bar
            progressBarFg.transform.localScale = new Vector3(scale, 1.0f, 1.0f);

            // reset timer
            timer -= waitTime;

            // Countdown timer displays seconds remaining near the end.
            if (counter > 0 && remainingTime > counter - 1 && remainingTime <= counter)
            {
                TextFaderScript textFader = GameObject.Find("CountdownMessage").GetComponent <TextFaderScript>();
                textFader.FadeText(0.1f, counter.ToString());
                counter--;
            }

            // check to see if it's time to start playing the timer bomb audio
            // FEATURE: ONLY IF JUICINESS IS ON
            if ((juiceProductive || juiceUnproductive) &&
                remainingTime <= 5.275f &&
                !isBombAudioPlaying)
            {
                isBombAudioPlaying = true;
                AudioManager.instance.Play("TimeBomb");
            }

            // check if game is over
            if (remainingTime <= 0.0f)
            {
                GameOver();
            }
        }

        //=============FEATURE: Random Pew Pew effects=========================
        // Unproductive Juice: every once in a while, do a random particle
        //                     animation along with pew pew sfx.
        //=====================================================================
        if (juiceUnproductive)
        {
            if (gameHasBegun)
            {
                juicyTimer += Time.deltaTime;
            }

            if (juicyTimer >= juicyWaitTime)
            {
                juicyRemainingTime -= juicyTimer;

                // reset timer
                juicyTimer -= juicyWaitTime;

                // check if it's time to do juicy effects
                if (juicyRemainingTime <= 0.0f)
                {
                    PlayJuicyEffects();

                    // reset
                    juicyRemainingTime = UnityEngine.Random.Range(10f, 30f);
                }
            }
        }

        // Log the keyframe (game state) after all the boxes have stopped falling
        if (areBoxesFalling)
        {
            if (!CheckIfBoxesAreFalling())
            {
                areBoxesFalling = false;

                if (!initialLog)
                {
                    // enable input again after all boxes have fallen
                    TouchInputHandler.inputEnabled = true;

                    Logger.LogKeyFrame("post");
                }
                else
                {
                    Logger.LogKeyFrame("gameStart");

                    // display the instructions/start game panel
                    instructionsPanel.SetActive(true);

                    initialLog = false;
                }
            }
        }
        else if (CheckIfBoxesAreFalling())
        {
            areBoxesFalling = true;
        }
    }
 public void ClickPlayGameButton()
 {
     // enable clicking in the next main game scene since the instructions text box will be skipped
     TouchInputHandler.touchEnabled = true;
     _menu.GoToNextScene(nextScene);
 }