- 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 void
addFinishListener(IFinishListener listener)
<T> void
addGameState(T identifier, IGameState gameState)
void
clearGameStates()
Clears all game states but the current game state.<T> void
completed(T completionData)
IGameState
currentGameState()
void
currentGameState(IGameState gameState)
void
finish()
Finishes the game.protected Map<Object,IGameState>
gameStateMap()
void
onFinished()
This is called when the game is finished.void
removeFinishListener(IFinishListener listener)
<T> void
removeGameState(T identifier)
<D> D
runtimeData()
<D> void
runtimeData(D data)
void
start()
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:
completed
in interfaceIGameStateListener
- Parameters:
completionData
- The data ran at completion.
-
currentGameState
public IGameState currentGameState()
- Specified by:
currentGameState
in interfaceIGameStateManager
- Returns:
- The currently running game state.
-
currentGameState
public void currentGameState(IGameState gameState)
- Specified by:
currentGameState
in 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:
addGameState
in interfaceIGameStateManager
- Parameters:
identifier
- The unique id for this game state.gameState
- The actual game state.
-
removeGameState
public <T> void removeGameState(T identifier)
- Specified by:
removeGameState
in interfaceIGameStateManager
- Parameters:
identifier
- The unique id for this game state.
-
clearGameStates
public void clearGameStates()
Description copied from interface:IGameStateManager
Clears all game states but the current game state.- Specified by:
clearGameStates
in interfaceIGameStateManager
-
runtimeData
public <D> D runtimeData()
- Specified by:
runtimeData
in interfaceIGameStateManager
- Returns:
- The runtime data associated with this game state manager.
-
runtimeData
public <D> void runtimeData(D data)
- Specified by:
runtimeData
in interfaceIGameStateManager
- Parameters:
data
- The new runtime data for this game state manager.
-
start
public void start()
Description copied from interface:IGameStateManager
Starts running the current game state.- Specified by:
start
in interfaceIGameStateManager
-
finish
public void finish()
Description copied from interface:IGameStateManager
Finishes the game.- Specified by:
finish
in interfaceIGameStateManager
-
addFinishListener
public void addFinishListener(IFinishListener listener)
- Specified by:
addFinishListener
in interfaceIGameStateManager
- Parameters:
listener
- A @see IFinishListener to be called when the game is finished.
-
removeFinishListener
public void removeFinishListener(IFinishListener listener)
- Specified by:
removeFinishListener
in interfaceIGameStateManager
- Parameters:
listener
- A @see IFinishListener to be removed.
-
onFinished
public void onFinished()
Description copied from interface:IFinishListener
This is called when the game is finished.- Specified by:
onFinished
in interfaceIFinishListener
-
-