Beispiel #1
0
        public void AddState(StateType id, SimpleFiniteState <StateType> state)
        {
            if (state == null)
            {
                return;
            }

            mStates[id] = state;
        }
Beispiel #2
0
        public SimpleFiniteState <StateType> GetState(StateType id)
        {
            SimpleFiniteState <StateType> state = null;

            if (mStates.TryGetValue(id, out state))
            {
                return(state);
            }

            return(null);
        }
Beispiel #3
0
        public void SwitchToState(StateType id)
        {
            SimpleFiniteState <StateType> nextState = GetState(id);

            if (nextState == null)
            {
                //GameLog.LogError(string.Format("FSMachine.SwitchToState error,can not find {0} state", id));
                return;
            }

            if (nextState == mCurrentState)
            {
                return;
            }

            if (mCurrentState != null)
            {
                mCurrentState.Exit();
            }

            nextState.Enter();
            mCurrentState = nextState;
        }