コード例 #1
0
ファイル: FSMMachine.cs プロジェクト: ThaH3lper/AITestGame
        public void UpdateMachine(float delta)
        {
            //If the machine has no states then return;
            if (states.Count == 0)
                return;

            //If state is null set the default state.
            if (currentState == null)
                currentState = defaultState;
            if (currentState == null)
                return;

            FSMEnum oldType = currentState.GetStateType();
            FSMEnum newType = currentState.CheckTransitions();

            //Check if current state wants to change state.
            if(oldType != newType)
            {
                //Checks if the state exists in this machine.
                if (TransitionState(newType))
                {
                    //Enter the new state
                    currentState = (FSMState)states[newType];
                    currentState.Enter();
                }
            }
            //Update the current state.
            currentState.Update(delta);
        }
コード例 #2
0
ファイル: FSMMachine.cs プロジェクト: ThaH3lper/AITestGame
 public void AddState(FSMState state){
     states[state.GetStateType()] = state;
 }
コード例 #3
0
ファイル: FSMMachine.cs プロジェクト: ThaH3lper/AITestGame
 public void SetDefaultState(FSMState state){
     defaultState = state;
 }