Ejemplo n.º 1
0
 private void RestartGameImpl()
 {
     roundTimer.StopTimer();
     PlayerSettings.MovementEnabled = false;
     panelBucket.Hud.GetComponent <CanvasGroup>().interactable = false;
     panelBucket.Hud.GetComponent <PanelAnimatorHelper>().HidePanel();
     gameRules.ClearRules();
     gameStateChanger.ChangeGameState(GameState.Instructions, 0.4f);
 }
Ejemplo n.º 2
0
        public void ChangeGameState(GameState gameState)
        {
#if DEBUG
            Debug.Log("Changing current game state to " + gameState);
#endif
            switch (gameState)
            {
            case GameState.SplashScreen:
                // Activate correct panel
                panelBucket.DeactivateAllPanels(panelBucket.SplashScreen);
                break;

            case GameState.StartMenu:
                // Activate correct panels
                panelBucket.DeactivateAllPanels(panelBucket.StartMenu);
                panelBucket.Options.GetComponent <PanelAnimatorHelper>().ShowPanelInstantly();
                break;

            case GameState.HowToPlay:
                // Activate correct panel
                CurrentGameState = gameState;

                panelBucket.DeactivateAllPanels();
                panelBucket.HowToPlay.GetComponent <HowToPlayController>().ActivateHowTo();

                // Set that HowToPlay has been seen
                PlayerSettings.HowToPlayShown = true;
                PlayerSettings.Save();
                break;

            case GameState.Instructions:
                // Activate correct panel
                panelBucket.DeactivateAllPanels(panelBucket.Instructions);

                // Reset camera
                Camera.main.transform.position = new Vector3(0f, 1f, -11f);

                // Set up round
                if (CurrentGameState == GameState.RoundEnd)
                {
#if DEBUG
                    Debug.Log("StartNextRound() called.");
#endif
                    roundCoordinator.StartNextRound();
                }
                else
                {
#if DEBUG
                    Debug.Log("StartFirstRound() called.");
#endif

                    roundCoordinator.StartFirstRound();
                    AudioClipPlayer.FadeFromMenuToInGameMusic();
                }

                break;

            case GameState.Playing:
                // Activate correct panel
                panelBucket.DeactivateAllPanels(panelBucket.Hud);
                panelBucket.Hud.GetComponent <CanvasGroup>().interactable = true;

                // Start the timer
                roundTimer.StartTimer();

                // Activate swiping
                PlayerSettings.MovementEnabled = true;
                break;

            case GameState.RoundEnd:
#if DEBUG
                Debug.Log("ROUND END");
#endif

                // Report on Lucky achievement
                if (sessionData.TimeLeft >= 23f)
                {
                    Achievements.Lucky.Unlock();
                }

                // Report progress on the Steady Hand achievement
                if (roundCoordinator.CurrentRound == 1)
                {
                    Achievements.SteadyHand.Increment(sessionData.Score, roundCoordinator.CardsToClearLow);
                }

                // Report progress on the Full Deck achievement
                if (sessionData.CurrentStreak > sessionData.HighestStreakInSession)
                {
                    sessionData.HighestStreakInSession = sessionData.CurrentStreak;
                }

                Achievements.FullDeck.Increment(sessionData.HighestStreakInSession, 52.0);

                // Clear current rules
                gameRules.ClearRules();

                // Prepare the round end card
                var timeLeft = (int)sessionData.TimeLeft;
                roundEndController.PrepareRoundEndCard(sessionData.Score, timeLeft);

                // Increase score
                sessionData.Score += timeLeft;

                // Activate correct panel
                panelBucket.DeactivateAllPanels(panelBucket.RoundResults);
#if DEBUG
                Debug.Log("ROUND END FINISH");
#endif
                break;

            case GameState.GameEnd:
#if DEBUG
                Debug.Log("GAME END");
#endif

                // Report progress on the Steady Hand achievement
                if (roundCoordinator.CurrentRound == 1)
                {
                    Achievements.SteadyHand.Increment(sessionData.Score, roundCoordinator.CardsToClearLow);
                }

                // Report progress on the Full Deck achievement
                if (sessionData.CurrentStreak > sessionData.HighestStreakInSession)
                {
                    sessionData.HighestStreakInSession = sessionData.CurrentStreak;
                }

                Achievements.FullDeck.Increment(sessionData.HighestStreakInSession, 52.0);

                // Clear current rules
                gameRules.ClearRules();

                // Check if High Score
                if (sessionData.Score > CloudVariables.HighScore)
                {
                    sessionData.NewHighScoreSet = true;
                    CloudVariables.HighScore    = sessionData.Score;
                }

                // Report on achievements
                ReportOnScoreAchievements();

                // Submit score to leaderboard
                Leaderboards.Highscore.SubmitScore(sessionData.Score);

                // Activate correct panel
                panelBucket.DeactivateAllPanels();
                panelBucket.GameResults.GetComponent <PanelAnimatorHelper>().ShowPanel();

                // Save data
                Cloud.Storage.Save();
#if DEBUG
                Debug.Log("GAME END FINISH");
#endif
                break;

            default:
                throw new ArgumentOutOfRangeException("gameState");
            }

            CurrentGameState = gameState;
        }