Game Development Reference
In-Depth Information
3. Initialize the machine by calling Reset() .
4. Update the machine by calling UpdateMachine() .
The MAX_STATES variable holds the maximum number of states that this machine can hold.
private int MAX_STATES = 20;
The m_NumberStates variable holds the number of states in this state machine.
private int m_NumberStates = 0;
The m_States array holds the tank states that make up the finite state machine.
protected StateTank[] m_States = new StateTank[MAX_STATES];
The m_CurrentState variable holds a reference to the currently executing tank state.
protected StateTank m_CurrentState = null;
The m_DefaultState variable holds a reference to the default state that the finite state
machine starts in.
protected StateTank m_DefaultState = null;
The m_GoalState is the state that the finite state machine is going to transition to.
protected StateTank m_GoalState = null;
The m_GoalID is the enumeration that identifies the type of tank state to transition to either the
process command state or the patrol/attack state.
protected FSM_StatesTank m_GoalID;
The Reset() function initializes the finite state machine and does the following (see Listing 8-39):
If there is a current state being executed, it exits that state by calling Exit()
on the state object.
1.
2.
It sets the current state to the default state of the machine.
3.
For all the states in the machine, it initializes them by calling each state's
Init() function.
If there is a current state, it then “enters” that state by calling Enter() on
that state.
4.
 
Search WWH ::




Custom Search