void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            PostGame(0);
        }

        switch (gameState)
        {
        case GameStates.prePlay:
            guiCtrl.OpenBlinker();
            gameState = GameStates.idle;
            break;

        case GameStates.idle:
            if (guiCtrl.CheckBlinkerOpen())
            {
                if (player.OnPlay())
                {
                    gameState = GameStates.play;
                    music.Play();
                }
            }
            break;

        case GameStates.play:
            // update backgrounds
            bgCtrl.OnFrame(speed);

            // Returns table flip
            tbCtrl.OnFrame(speed);

            if (tbCtrl.CheckFlip())
            {
                OnFlip(player.GetFlipAccuracy());
            }

            player.OnPlay();
            gameState = player.AffectGameState();
            if (gameState == GameStates.gameover)
            {
                StartCoroutine(camCtrl.Shake());
            }
            break;

        case GameStates.gameover:
            tbCtrl.CleanupFlippingTables();
            // This will allow the player to see the exit menu after just a short time, or if the tap right away,
            // without necessarily having to wait for the player to fall to a certain point.
            if (player.EarlyExit())
            {
                bool newHighReached = false;
                // Track high scores for overall game
                if (flips > highFlips)
                {
                    highFlips      = flips;
                    newHighReached = true;
                }
                if (score > highScore)
                {
                    highScore      = score;
                    newHighReached = true;
                }
                if (highComboThisRound > highComboOverall)
                {
                    highComboOverall = highComboThisRound;
                    newHighReached   = true;
                }

                guiCtrl.UpdateEndGameResults(flips, highFlips, score, highScore, highComboThisRound, highComboOverall, newHighReached);     // 3 NOT REALLY A THING, JUST A PLACEHOLDER
                guiCtrl.ActivateGameOverMenu();
                music.volume = 0.25f;
            }

            // This will shut off the players motion and exit this state if a certain fall distance is reached.
            player.OnGameOver();
            gameState = player.AffectGameState();
            break;

        case GameStates.replay:
            music.Stop();
            if (!guiCtrl.CheckBlinkerOpen())
            {
                if (adLaunched == false)
                {
                    adCtrl.CountReset();
                    adLaunched = true;
                }
                if (!adCtrl.CheckAdShowing())
                {
                    adLaunched = false;
                    Reset();
                    guiCtrl.OpenBlinker();
                }
            }
            break;

        case GameStates.exit:
            music.Stop();
            if (!guiCtrl.CheckBlinkerOpen())
            {
                Reset();
                guiCtrl.EndScene();
                SceneManager.LoadScene(1);
            }
            break;
        }
    }
Exemple #2
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            OnExitBtn();
        }

        angle += 3.0f;
        if (angle >= 360.0f)
        {
            angle = 0.0f;
        }

        spiralImgTrans.rotation = Quaternion.Euler(0.0f, 0.0f, angle);

        switch (state)
        {
        case TitleScreenState.none:
            blinker.Open();
            state = TitleScreenState.transitioningIn;
            break;

        case TitleScreenState.transitioningIn:
            if (blinker.CheckOpen())
            {
                foreach (Button button in uiButtons)
                {
                    button.interactable = true;
                }

                audioS.clip = music;
                audioS.loop = true;
                audioS.Play();
                state = TitleScreenState.inMain;
            }
            break;

        case TitleScreenState.inMain:
            achTimer -= Time.deltaTime;
            break;

        case TitleScreenState.startingGame:
            if (!blinker.CheckOpen())
            {
                if (adLaunched == false)
                {
                    adCtrl.CountReset();
                    adLaunched = true;
                }
                if (!adCtrl.CheckAdShowing())
                {
                    adLaunched = false;
                    state      = TitleScreenState.none;
                    blinker.EndSceneTrigger();
                    SceneManager.LoadScene(2);
                }
            }
            break;

        case TitleScreenState.inOptions:
            achTimer -= Time.deltaTime;
            break;

        case TitleScreenState.inExtras:
            achTimer -= Time.deltaTime;
            break;
        }

        if (achTimer <= 0.0f && achReached == false)
        {
            achReached = true;
            UpdateAchievement(Constants.ACH_SOOTHING_SONG, "Achievement: Soothing Song");
        }
    }