Exemplo n.º 1
0
 public void ChangeState(State <T> state)
 {
     if (currentState != null)
     {
         currentState.Exit();
     }
     currentState = state;
     currentState.Enter();
 }
Exemplo n.º 2
0
 public void ChangeState(State <T> newState)
 {
     if (m_pCurrentState != null)
     {
         Log.Print("entity:{0} [{1}]->[{2}]", m_entity.GetID(), m_pCurrentState?.GetName(), newState.GetName());
         m_pPreState = m_pCurrentState;
         m_pCurrentState.Exit(m_entity);
         m_pCurrentState = newState;
         m_pCurrentState.Enter(m_entity);
     }
 }
Exemplo n.º 3
0
        public void ChangeState <T>() where T : State, new()
        {
            if (_current != null)
            {
                _current.Exit();
            }

            _current = _states[typeof(T)];
            UnityEngine.Debug.Log($"Change State {typeof(T)}");
            _current.Enter();
        }
 public void ChangeState(State <TContext> newState)
 {
     if (newState == null)
     {
         return;
     }
     if (CurrentState != null)
     {
         CurrentState.Exit();
     }
     CurrentState = newState;
     CurrentState.Enter();
 }