public void Update()
    {
        switch (State)
        {
        case GameStateComponentState.CountDown:
            break;

        case GameStateComponentState.InGame:

            // no more time or the user hit the debug command to go to the next level ?
            if (TimeRemaining <= 0 || CheckDebugKey(KeyCode.Slash))
            {
                // fade the screen to black and load the next scene
                FadeUtility.FadeToNextScene(loadSpinnerObject, webComponent,
                                            () => SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1));

                State = GameStateComponentState.GameCompleted;
            }
            else
            {
                TimeRemaining = Mathf.Max(0, TimeRemaining - Time.deltaTime);

                // check if the user wants to pause the game
                if (Input.GetKeyUp(KeyCode.P))
                {
                    Time.timeScale = 0.0f;
                    State          = GameStateComponentState.Paused;
                }
                // debug command to decrease the time by 3 minutes
                else if (CheckDebugKey(KeyCode.Z))
                {
                    TimeRemaining = Mathf.Max(0, TimeRemaining - 180);
                }
            }
            break;

        case GameStateComponentState.Paused:
            if (Input.GetKeyUp(KeyCode.P))
            {
                Time.timeScale = 1.0f;
                State          = GameStateComponentState.InGame;
            }
            break;

        case GameStateComponentState.LostServerConnection:
            break;

        case GameStateComponentState.GameCompleted:

            // just (wait for the server to ack and) do nothing
            break;
        }
    }
예제 #2
0
 public void OnClick()
 {
     FadeUtility.FadeToNextScene(loadScreenSpinner, _webCom, () => SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1));
 }