Пример #1
0
        }                                                       //game state
        public static void SetGameState(GameState newState)
        {
            GameState = newState;         //update the state

            if (MultiplayerGame == false) //only in single player games
            {
                //if the new state is set to running:
                if (GameState == GameState.running)
                {
                    Time.timeScale = 1.0f;             //set the time scale to 1.0 to allow the game to run
                }
                else if (GameState == GameState.pause) //if the game is paused
                {
                    Time.timeScale = 0.0f;             //to freeze the game
                }
            }

            CustomEvents.OnGameStateUpdated(); //and trigger the custom event
        }
 public void RpcFreezeGame(bool freeze)
 {
     GameManager.SetGameState((freeze == true) ? GameState.frozen : GameState.running); //set the game state
     Time.timeScale = (freeze == false) ? 1.0f : frozenTimeScale;                       //set the time scale
     CustomEvents.OnGameStateUpdated();
 }