コード例 #1
0
 public GameState CreateGameState(GameStateDefinition settings)
 {
     return(_factory.CreateValue(settings.GetType()));
 }
コード例 #2
0
    void Internal_TransitionToState(GameStateDefinition gameStateSettings, GameStateParam[] parameters)
    {
        if (gameStateSettings == null)
        {
            Log.Error("[GameStateManager] Trying to transition to a null GameState");
            return;
        }

        _parameters = parameters;

        GameState newGameState = _gameStateFactory.CreateGameState(gameStateSettings);

        newGameState.SetDefinition(gameStateSettings);

        if (newGameState == null)
        {
            Log.Error("[GameStateManager] Failed to create a GameState from gameStateSettings: " + gameStateSettings.GetType()
                      + ". You may have forgot to register it in the factory.");
            return;
        }

        _targetGameState = newGameState;

        if (log)
#pragma warning disable CS0162 // Unreachable code detected
        {
            Log.Info("[GameStateManager] Transitioning from " + GetPrintGameStateName(_currentGameState) + " to " + GetPrintGameStateName(_targetGameState) + "...");
        }
#pragma warning restore CS0162 // Unreachable code detected
        _currentGameState?.BeginExit(_parameters);
    }