Пример #1
0
        /// <summary>
        /// Change the current state to a new state
        /// </summary>
        /// <param name="newState">The new state to change to </param>
        public void ChangeState(State newState)
        {
            if (currentState == newState)
            {
                return;
            }

            //check null for initialization
            if (currentState != null)
            {
                //Exit the current state
                currentState.Exit();
                _LogState("Exit");
            }

            //Make current state as previous
            prevState = currentState;

            //Make the new state as current
            currentState = newState;

            //Enter the new state
            currentState.Entry();

            _LogState("Entry");
        }
Пример #2
0
 /// <summary>
 /// Cambia del estado actual a un nuevo estado
 /// </summary>
 /// <param name="stateID">Estado objetivo</param>
 public virtual void ChangeState(StateID stateID)
 {
     CurrentState.Exit();
     CurrentState = StatesMap[(byte)stateID];
     CurrentState.Entry();
 }