예제 #1
0
 public StateMachine(BaseGameEntity owner)
 {
     m_pOwner = owner;
     m_pCurrentState = null;
     m_pPreviousState = null;
     m_pGlobalState = null;
 }
예제 #2
0
        //change to a new state
        public void ChangeState(State pNewState)
        {
            Debug.Assert(pNewState != null, "<StateMachine::ChangeState>:trying to assign null state to current");

            //keep a record of the previous state
            m_pPreviousState = m_pCurrentState;

            //call the exit method of the existing state
            m_pCurrentState.Exit(m_pOwner);

            //change state to the new state
            m_pCurrentState = pNewState;

            //call the entry method of the new state
            m_pCurrentState.Enter(m_pOwner);
        }