Пример #1
0
    protected virtual void Transition(State value)
    {
        if (_currentState == value || _inTransition)
        {
            return;
        }

        _inTransition = true;

        StateTransition.Transition(_currentState, value, () =>
        {
            _currentState = value;
            _inTransition = false;
        });

        //if (_currentState != null)
        //{
        //    _currentState.Exit();
        //}

        //_currentState = value;

        //if (_currentState != null)
        //{
        //    _currentState.Enter();
        //}

        //_inTransition = false;
    }
Пример #2
0
 public override StateTransition <GameData> EvaluateTransition()
 {
     if (m_finishLoading)
     {
         return(StateTransition <GameData> .Transition <GameLevelSelectionState>());
     }
     return(StateTransition <GameData> .NullTransition);
 }
Пример #3
0
 public override StateTransition <GameData> EvaluateTransition()
 {
     if (m_currentSession.SessionFinished)
     {
         return(StateTransition <GameData> .Transition <GamePostSessionState>(new GameData(m_currentSession, m_data.LevelIndex)));
     }
     return(StateTransition <GameData> .NullTransition);
 }
Пример #4
0
 public override StateTransition <GameData> EvaluateTransition()
 {
     if (m_goToSelectedLevel)
     {
         m_gamagaView.Close();
         return(StateTransition <GameData> .Transition <GameSessionState>(new GameData(0, ResourceManager.Instance.GetLevelByIndex(0), ResourceManager.Instance.GameResources.CharacterResources.MainCharacter, m_blackScreen)));
     }
     return(StateTransition <GameData> .NullTransition);
 }
Пример #5
0
 public override StateTransition <GameData> EvaluateTransition()
 {
     if (m_retry)
     {
         return(StateTransition <GameData> .Transition <GameSessionState>(new GameData(m_data.LevelIndex, ResourceManager.Instance.GetLevelByIndex(m_data.LevelIndex), ResourceManager.Instance.GameResources.CharacterResources.MainCharacter, m_blackScreen)));
     }
     if (m_nextLevel)
     {
         var nextLevel = ResourceManager.Instance.GetLevelByIndex(m_data.LevelIndex + 1);
         if (nextLevel != null)
         {
             return(StateTransition <GameData> .Transition <GameSessionState>(new GameData(m_data.LevelIndex + 1, nextLevel, ResourceManager.Instance.GameResources.CharacterResources.MainCharacter, m_blackScreen)));
         }
         else
         {
             return(StateTransition <GameData> .Transition <GameSessionState>(new GameData(0, ResourceManager.Instance.GetLevelByIndex(0), ResourceManager.Instance.GameResources.CharacterResources.MainCharacter, m_blackScreen)));
         }
     }
     return(StateTransition <GameData> .NullTransition);
 }
Пример #6
0
 /// <summary>
 /// Accept the state and transition to the new state.
 /// </summary>
 /// <param name="context">The session context to use for accepting session based transitions.</param>
 public void Transition(SmtpSessionContext context)
 {
     _current = _transition.Transition(context);
 }
Пример #7
0
 public void Initialize <State>(Data data = null) where State : GenericState <Data>
 {
     m_statesCache = new Dictionary <Type, GenericState <Data> >();
     ChangeState(StateTransition <Data> .Transition <State>(data));
 }