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; } }