Пример #1
0
        public void Reset()
        {
            if (currentState != null)
                currentState.Exit();
            currentState = defaultState;

            //init all the states
            for (int i = 0; i < states.Count; i++)
                states[i].Init();

            //and now enter the m_defaultState, if any
            if (currentState != null)
                currentState.Enter();
        }
Пример #2
0
        public void Reset()
        {
            if (currentState != null)
            {
                currentState.Exit();
            }
            currentState = defaultState;

            //init all the states
            for (int i = 0; i < states.Count; i++)
            {
                states[i].Init();
            }

            //and now enter the m_defaultState, if any
            if (currentState != null)
            {
                currentState.Enter();
            }
        }
Пример #3
0
        public void UpdateMachine(GameTime gameTime)
        {
            //don't do anything if you have no states
            if (states.Count == 0)
            {
                return;
            }

            //don't do anything if there's no current
            //state, and no default state
            if (currentState == null)
            {
                currentState = defaultState;
            }
            if (currentState == null)
            {
                return;
            }

            //check for transitions, and then update
            FSMStateEnum oldStateID = currentState.GetID();

            goalStateID = currentState.CheckTransitions();

            //switch if there was a transition
            if (goalStateID != oldStateID)
            {
                if (TransitionState(goalStateID))
                {
                    currentState.Exit();
                    currentState = goalState;
                    currentState.Enter();
                }
            }
            currentState.Update(gameTime);
        }
Пример #4
0
        public void UpdateMachine(GameTime gameTime)
        {
            //don't do anything if you have no states
            if (states.Count == 0)
                return;

            //don't do anything if there's no current
            //state, and no default state
            if (currentState == null)
                currentState = defaultState;
            if (currentState == null)
                return;

            //check for transitions, and then update
            FSMStateEnum oldStateID = currentState.GetID();
            goalStateID = currentState.CheckTransitions();

            //switch if there was a transition
            if (goalStateID != oldStateID)
            {
                if (TransitionState(goalStateID))
                {
                    currentState.Exit();
                    currentState = goalState;
                    currentState.Enter();
                }
            }
            currentState.Update(gameTime);
        }