Exemple #1
0
    void HandleOnGameStateChanged(GameState.state prevState, GameState.state nextState)
    {
        foreach (var UI in activeUIs)
        {
            UI.SetActive(false);
        }
        activeUIs.Clear();

        switch (nextState)
        {
        case GameState.state.PLAYING:
            activeUIs.Enqueue(playingUI);
            break;

        case GameState.state.POSTGAME:
            activeUIs.Enqueue(gameOverUI);
            activeUIs.Enqueue(startButton);
            activeUIs.Enqueue(scorePanelUI);
            break;

        case GameState.state.PAUSED:
            activeUIs.Enqueue(pauseUI);
            activeUIs.Enqueue(scorePanelUI);
            break;

        default:
            break;
        }

        foreach (var UI in activeUIs)
        {
            UI.SetActive(true);
        }
    }
Exemple #2
0
    private void TogglePause()
    {
        if (currentState == GameState.state.POSTGAME || currentState == GameState.state.PREGAME)
        {
            return;
        }
        GameState.state nextState = (currentState == GameState.state.PLAYING ? GameState.state.PAUSED : GameState.state.PLAYING);
        float           timescale = (currentState == GameState.state.PLAYING ? 0.0f : 1.0f);

        UpdateState(nextState);
        Time.timeScale = timescale;
    }
Exemple #3
0
 private void UpdateState(GameState.state nextState)
 {
     GameState.state prevState = currentState;
     OnGameStateChanged.Invoke(prevState, nextState);
     currentState = nextState;
 }
Exemple #4
0
 // Start is called before the first frame update
 void Start()
 {
     currentState = GameState.state.PREGAME;
 }