Sei sulla pagina 1di 1

Game Master State Machine

ES_Event runGameMaster(ES_Event ThisEvent){ //This function runs the top level hierarchical state machine for
the gameplay service
//store the current event
//declare a return event
//assume no errors
//set the next state equal to the current state, assume no state transition
//assume we're not changing states

//Respond to an ES_GAMEOVER event at this level


//take different actions depending on the state of the gameMaster state machine
//if we're waiting for the game to start
// Set currentEvent to the output of duringWaitingForGameToStart(currentEvent);
//take different actions depending on the current event
//if a timer has expired
//if the expired timer was the waiting for game to start timer
//indicate that we want new data from the LOC
//set the parameter to indicate a query for new game
//status data from the LOC
//send the event to the SSI service for sending to the
//LOC
// end if
//if the SSI service has retrieved new game status data
//update the local module-level game status variables with the
//new LOC response data
//if construction is active
//move to the gamePlaying state
// Set MakeTransition to true;
//else if the game has not yet started
//restart the timer to query the SSI to see if the game has
//started
// end if
//end if
// if current state is gamePlaying
//run the during function of this state before handling the event at this level
// if this event type
//if we want to switch to our end game strategy
//change to the final countdown state
//indicate that we're changing states
//end if

// end if
// if current state is finalCountdown
//run the during function of this state before handling the event at this level
// if this event type
//if a timer timed out
//if the game is over
//declare a new event
//the event indicates we should shut off the motors at
// the game's end
//turn on the construction active LED
//go back to the initial state of waiting for the game
//to start
//indicate that we're changing states
//end if
// end if
// if MakeTransition is set to true
{
// set current event to ES_EXIT currentEvent.EventType = ES_EXIT;
// run GameMaster using currentEvent
// set currentState to nextState
// runGameMaster using EntryEventKind
}
//return the event, assume no errors
}