Ejemplo n.º 1
0
    private void GoToState(GameState toState)
    {
        if (_states.TryGetValue(toState, out var nextState))
        {
            _currentState?.OnStateExit();

            _currentState = nextState;
            Debug.Log($"Enter state: {_currentState.State}");
            _currentState.OnStateEnter();
        }
        else
        {
            Debug.LogError($"Unexpected {nameof(GameState)}: {toState.ToString()}");
        }
    }