Game Development Reference
In-Depth Information
The m_StateID variable holds the id that identifies the states that the tank can be in. See Listing 8-9
for the full list.
private FSM_StatesTank m_StateID;
The Init() function is called once, when the finite state machine that this class object is part of is
first created and reset.
void Init() {}
The Enter() function is called when the state is first entered from a different state.
void Enter() {}
The Exit() function is called before exiting the state to a different state.
void Exit() {}
The Update() function is called to update the state.
void Update() {}
The CheckTransitions() function checks for transitions to another state, based on game conditions,
and returns no state by default, unless overridden by a subclass.
The entire StateTank class is shown in Listing 8-10.
Listing 8-10. The Base Class for the Tank States
public class StateTank
{
private Driver m_Parent;
private FSM_StatesTank m_StateID;
StateTank(FSM_StatesTank ID, Driver Parent)
{
m_StateID = ID;
m_Parent = Parent;
}
void Init() {}
void Enter() {}
void Exit() {}
void Update() {}
FSM_StatesTank CheckTransitions()
{
return FSM_StatesTank.FSM_STATE_NONE;
}
Driver GetParent() {return m_Parent;}
FSM_StatesTank GetStateID() { return m_StateID;}
}
 
Search WWH ::




Custom Search