- java.lang.Object
-
- ilusr.gamestatemanager.GameStateManager
-
- All Implemented Interfaces:
IFinishListener,IGameStateListener,IGameStateManager
- Direct Known Subclasses:
BufferedGameStateManager
public class GameStateManager extends Object implements IGameStateManager
- Author:
- Jeffrey Riggle
-
-
Constructor Summary
Constructors Constructor Description GameStateManager(T id, IGameState currentGameState)GameStateManager(T id, IGameState currentGameState, D runtimeData)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFinishListener(IFinishListener listener)<T> voidaddGameState(T identifier, IGameState gameState)voidclearGameStates()Clears all game states but the current game state.<T> voidcompleted(T completionData)IGameStatecurrentGameState()voidcurrentGameState(IGameState gameState)voidfinish()Finishes the game.protected Map<Object,IGameState>gameStateMap()voidonFinished()This is called when the game is finished.voidremoveFinishListener(IFinishListener listener)<T> voidremoveGameState(T identifier)<D> DruntimeData()<D> voidruntimeData(D data)voidstart()Starts running the current game state.
-
-
-
Constructor Detail
-
GameStateManager
public GameStateManager(T id, IGameState currentGameState)- Parameters:
id- The identifier to map the first game state to.currentGameState- The @see IGameState that should be the first game state to run.
-
GameStateManager
public GameStateManager(T id, IGameState currentGameState, D runtimeData)- Parameters:
id- The identifier to map the first game state to.currentGameState- The @see IGameState that should be the first game state to run.runtimeData- The data to pass into game states at run time.
-
-
Method Detail
-
completed
public <T> void completed(T completionData)
- Specified by:
completedin interfaceIGameStateListener- Parameters:
completionData- The data ran at completion.
-
currentGameState
public IGameState currentGameState()
- Specified by:
currentGameStatein interfaceIGameStateManager- Returns:
- The currently running game state.
-
currentGameState
public void currentGameState(IGameState gameState)
- Specified by:
currentGameStatein interfaceIGameStateManager- Parameters:
gameState- The new game state (maybe this should be removed).
-
gameStateMap
protected Map<Object,IGameState> gameStateMap()
- Returns:
- A Map of completion data to Game state.
-
addGameState
public <T> void addGameState(T identifier, IGameState gameState)- Specified by:
addGameStatein interfaceIGameStateManager- Parameters:
identifier- The unique id for this game state.gameState- The actual game state.
-
removeGameState
public <T> void removeGameState(T identifier)
- Specified by:
removeGameStatein interfaceIGameStateManager- Parameters:
identifier- The unique id for this game state.
-
clearGameStates
public void clearGameStates()
Description copied from interface:IGameStateManagerClears all game states but the current game state.- Specified by:
clearGameStatesin interfaceIGameStateManager
-
runtimeData
public <D> D runtimeData()
- Specified by:
runtimeDatain interfaceIGameStateManager- Returns:
- The runtime data associated with this game state manager.
-
runtimeData
public <D> void runtimeData(D data)
- Specified by:
runtimeDatain interfaceIGameStateManager- Parameters:
data- The new runtime data for this game state manager.
-
start
public void start()
Description copied from interface:IGameStateManagerStarts running the current game state.- Specified by:
startin interfaceIGameStateManager
-
finish
public void finish()
Description copied from interface:IGameStateManagerFinishes the game.- Specified by:
finishin interfaceIGameStateManager
-
addFinishListener
public void addFinishListener(IFinishListener listener)
- Specified by:
addFinishListenerin interfaceIGameStateManager- Parameters:
listener- A @see IFinishListener to be called when the game is finished.
-
removeFinishListener
public void removeFinishListener(IFinishListener listener)
- Specified by:
removeFinishListenerin interfaceIGameStateManager- Parameters:
listener- A @see IFinishListener to be removed.
-
onFinished
public void onFinished()
Description copied from interface:IFinishListenerThis is called when the game is finished.- Specified by:
onFinishedin interfaceIFinishListener
-
-