Exemplo n.º 1
0
    public void SetGameState(GameState newState)
    {
        if (currentState == newState)
        {
            Debug.Log("Error: no se va a mostrar el " + newState.ToString());
        }
        else
        {
            DisableInput();
            switch (newState)
            {
            case GameState.MainMenu:
                if (ServicesConfigurationInitialized && ServicesConfiguration.enable_tappx && !isTappxBannerVisible)
                {
                    ShowTappxBanner(true);
                }
                if (ScreenManager.Instance.currentGUIScreen.screenDefinition == ScreenDefinitions.HIGHSCORES)
                {
                    animator.SetBool("highscores", false);
                }
                ShowScreen(ScreenDefinitions.MAIN_MENU);
                AudioMaster.instance.StopAll(false);
                AudioMaster.instance.PlayLoop(SoundDefinitions.THEME_MAINMENU);
                rotator.EraseAllPins();
                if (currentState != GameState.Highscores && currentState != GameState.None)
                {
                    animator.SetTrigger("menu");
                }
                break;

            case GameState.GoToPlay:
                if (ServicesConfigurationInitialized && ServicesConfiguration.enable_tappx)
                {
                    ShowTappxBanner(false);
                }
                animator.SetTrigger("start");
                nextGameState = GameState.Playing;
                break;

            case GameState.Playing:
                ScreenManager.Instance.HideScreen();
                StartCoroutine(WaitUntilPlayingState());
                break;

            case GameState.GameOver:
                AudioMaster.instance.Play(SoundDefinitions.END_FX);
                animator.SetTrigger("exit");
                GameOverPoints.text = Score.ToString();
                if (ServicesConfigurationInitialized && ServicesConfiguration.enable_tappx && !isTappxBannerVisible)
                {
                    ShowTappxBanner(true);
                }
                break;

            case GameState.Highscores:
                animator.SetBool("highscores", true);
                ShowScreen(ScreenDefinitions.HIGHSCORES);
                break;
            }
            currentState = newState;
            if (nextGameState != GameState.None)
            {
                GameState theNextState = nextGameState;
                nextGameState = GameState.None;
                SetGameState(theNextState);
            }
        }
    }