Package com.starpoints.state
Class GameState
- java.lang.Object
-
- com.starpoints.state.GameState
-
- All Implemented Interfaces:
java.io.Serializable
public class GameState extends java.lang.Object implements java.io.Serializable
Represents the state of the game. The GameState is serializable and is updated frequently by the StarpointController (or retrieved from the game routing). It contains all information for UI updates. Replay- and BestMoveManagers use the GameState to store all display information for game replay. It is NOT used for saving the game (which is done by serializing the Game-instance), since the game state does not preserve listener references, internal thing states etc. that are not necessary for display purposes. Certain state references like LevelState, ShopState et. might be null, if not currently available depending on the state of the game.
The constant EMPTY might be used for calling methods requiring a GameState as parameter, if necessary.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description GameState()
Creates a GameState.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAdditionalItemMove(ItemState item, ItemMove additionalItemMove)
Adds an additional item move (mainly for rockets that are launched directly into an enemy).void
addFlashAnimation(FlashAnimationState flashAnimation)
Adds a flash animation.void
addLevelPlayer(FigureState levelPlayer)
Adds a level player.void
fillEmptyState()
Creates a default LevelState and FiedState.ItemMove
getAdditionalItemMove(ItemState item)
Gets an additional item move.java.util.Set<ItemState>
getAdditionalItemMoveKeys()
Gets a list of additional item move keys.int
getAnimationIndex()
int
getBackgroundColor()
Gets the background color.int
getBackgroundForeColor()
Gets the background forecolor.EffectsInfo
getEffectsInfo()
Gets the effect infos.FigureState
getFirstHumanPlayer()
Gets the first human player in the level.int
getFlashAnimationIndex()
java.util.List<FlashAnimationState>
getFlashAnimations()
Gets a list of flash animations.Game.FlashState
getFlashState()
Gets the flash state.long
getIndex()
Gets the index.LeagueState
getLeagueState()
Gets the league state in league game.int
getLevelIndex()
Gets the level index.java.util.Map<java.lang.Integer,FigureState>
getLevelPlayers()
Gets the map of level players (mapping Ids to figures).LevelState
getLevelState()
Gets the LevelState.int
getMaxStartingLevelIndex()
Sets the maxStartingLevelIndex.java.lang.String
getMessage()
int
getMessageColor()
GameMode
getMode()
int
getModeCount()
int
getPlayerCount()
int
getPlayerID()
Gets the player ID.PointState
getPoint(int x, int y)
Service method to retrive point state for given coordinates from level states field.int
getRoundCount()
ShopState
getShopState()
Gets the ShopState.java.util.List<FigureState>
getSortedPlayerList()
Gets a sorted list of figures in the level.SoundFxUpdate
getSoundInfo()
Gets the sound infos.boolean
isDuringLevel()
Checks, if the game routine is running.boolean
isEditor()
boolean
isFlashing()
Checks, if background should be painted flashy.boolean
isGameFinished()
Checks, if the game has finished.boolean
isLeagueGame()
Checks, if the game is a league game.boolean
isShowingBackgroundAnimation()
Checks, if background animation is shown.boolean
isShowingFigureVisibility()
boolean
isShowingFlashAnimation()
Checks, if flash animation is shown.boolean
isShowingReplay()
Checks, if replay is running.boolean
isShowingScoreAnimation()
Checks, if score animation is shown.boolean
isTutorial()
void
setAnimationIndex(int animationIndex)
void
setEditor(boolean isEditor)
void
setEffectsInfo(EffectsInfo effectsInfo)
Sets the effect infos.void
setFlashAnimationIndex(int flashAnimationIndex)
void
setFlashState(Game.FlashState flashState)
Sets the flash state.void
setLeagueState(LeagueState leagueState)
void
setLevelIndex(int levelIndex)
Sets the level index.void
setLevelState(LevelState levelState)
Sets the level state.void
setMaxStartingLevelIndex(int maxStartingLevelIndex)
Sets the maxStartingLevelIndex.void
setMessage(java.lang.String message)
void
setMessageColor(int messageColor)
void
setMode(GameMode mode)
void
setModeCount(int modeCount)
void
setPlayerCount(int playerCount)
void
setPlayerID(int playerID)
Sets the playerID.void
setShopState(ShopState shopState)
Sets the ShopState.void
setShowBackgroundAnimation(boolean showBackgroundAnimation)
Sets, if background animation is shown.void
setShowFigureVisibility(boolean showFigureVisibility)
void
setShowingFlashAnimation(boolean isShowingFlashAnimation)
Sets, if flash animation is shown.void
setShowScoreAnimation(boolean showScoreAnimation)
Sets, if score animation is shown.void
setSoundInfo(SoundFxUpdate soundFxUpdate)
Sets the sound infos.void
setTutorial(boolean isTutorial)
java.lang.String
toString()
Returns a string representation.
-
-
-
Field Detail
-
EMPTY
public static final GameState EMPTY
An empty GameState.
-
-
Method Detail
-
getLevelState
public LevelState getLevelState()
Gets the LevelState.- Returns:
- The levelState.
-
getShopState
public ShopState getShopState()
Gets the ShopState.- Returns:
- The ShopState.
-
setShopState
public void setShopState(ShopState shopState)
Sets the ShopState.- Parameters:
shopState
- The shopState.
-
fillEmptyState
public void fillEmptyState()
Creates a default LevelState and FiedState.
-
setLevelState
public void setLevelState(LevelState levelState)
Sets the level state.- Parameters:
levelState
- the levelState to set.
-
getLevelPlayers
public java.util.Map<java.lang.Integer,FigureState> getLevelPlayers()
Gets the map of level players (mapping Ids to figures).- Returns:
- The level players.
-
addLevelPlayer
public void addLevelPlayer(FigureState levelPlayer)
Adds a level player.- Parameters:
levelPlayer
- the levelPlayers to set.
-
getLevelIndex
public int getLevelIndex()
Gets the level index.- Returns:
- the levelIndex.
-
setLevelIndex
public void setLevelIndex(int levelIndex)
Sets the level index.- Parameters:
levelIndex
- The levelIndex to set.
-
getMode
public GameMode getMode()
- Returns:
- the mode
-
setMode
public void setMode(GameMode mode)
- Parameters:
mode
- the mode to set
-
getModeCount
public int getModeCount()
- Returns:
- the modeCount
-
setModeCount
public void setModeCount(int modeCount)
- Parameters:
modeCount
- the modeCount to set
-
getAnimationIndex
public int getAnimationIndex()
- Returns:
- the animationIndex
-
setAnimationIndex
public void setAnimationIndex(int animationIndex)
- Parameters:
animationIndex
- the animationIndex to set
-
getMessage
public java.lang.String getMessage()
- Returns:
- the message
-
setMessage
public void setMessage(java.lang.String message)
- Parameters:
message
- the message to set
-
getMessageColor
public int getMessageColor()
- Returns:
- the messageColor
-
setMessageColor
public void setMessageColor(int messageColor)
- Parameters:
messageColor
- the messageColor to set
-
getPlayerCount
public int getPlayerCount()
- Returns:
- the playerCount
-
setPlayerCount
public void setPlayerCount(int playerCount)
- Parameters:
playerCount
- the playerCount to set
-
isTutorial
public boolean isTutorial()
- Returns:
- the isTutorial
-
setTutorial
public void setTutorial(boolean isTutorial)
- Parameters:
isTutorial
- the isTutorial to set
-
isShowingScoreAnimation
public boolean isShowingScoreAnimation()
Checks, if score animation is shown.- Returns:
- the showScoreAnimation
-
setShowScoreAnimation
public void setShowScoreAnimation(boolean showScoreAnimation)
Sets, if score animation is shown.- Parameters:
showScoreAnimation
- The showScoreAnimation to set.
-
isShowingBackgroundAnimation
public boolean isShowingBackgroundAnimation()
Checks, if background animation is shown.- Returns:
- The showBackgroundAnimation.
-
setShowBackgroundAnimation
public void setShowBackgroundAnimation(boolean showBackgroundAnimation)
Sets, if background animation is shown.- Parameters:
showBackgroundAnimation
- The showBackgroundAnimation to set
-
isShowingReplay
public boolean isShowingReplay()
Checks, if replay is running.- Returns:
- state == GameState.Replay
-
isDuringLevel
public boolean isDuringLevel()
Checks, if the game routine is running.- Returns:
- true for RoundBegin, RoundBeforeGettingMoves, RoundBeforeMoves, RoundBeforeUpdate
-
isGameFinished
public boolean isGameFinished()
Checks, if the game has finished.- Returns:
- true , if the state is Finished.
-
isShowingFlashAnimation
public boolean isShowingFlashAnimation()
Checks, if flash animation is shown.- Returns:
- The isShowingFlashAnimation.
-
setShowingFlashAnimation
public void setShowingFlashAnimation(boolean isShowingFlashAnimation)
Sets, if flash animation is shown.- Parameters:
isShowingFlashAnimation
- the isShowingFlashAnimation to set.
-
getFlashAnimationIndex
public int getFlashAnimationIndex()
- Returns:
- the flashAnimationIndex
-
setFlashAnimationIndex
public void setFlashAnimationIndex(int flashAnimationIndex)
- Parameters:
flashAnimationIndex
- the flashAnimationIndex to set
-
isShowingFigureVisibility
public boolean isShowingFigureVisibility()
- Returns:
- the showFigureVisibility
-
setShowFigureVisibility
public void setShowFigureVisibility(boolean showFigureVisibility)
- Parameters:
showFigureVisibility
- the showFigureVisibility to set
-
isFlashing
public boolean isFlashing()
Checks, if background should be painted flashy.- Returns:
- true, if background should be painted flashy.
-
getPoint
public PointState getPoint(int x, int y)
Service method to retrive point state for given coordinates from level states field.- Parameters:
x
- The x coordinate.y
- The y coordinate.- Returns:
- The point state for the given coordinates, or null, if off level.
-
getAdditionalItemMoveKeys
public java.util.Set<ItemState> getAdditionalItemMoveKeys()
Gets a list of additional item move keys.- Returns:
- The list of Items with additionalItemMoves.
-
getAdditionalItemMove
public ItemMove getAdditionalItemMove(ItemState item)
Gets an additional item move.- Parameters:
item
- The item to get the additional move for.- Returns:
- The additionalItemMove or null, if none exists.
-
addAdditionalItemMove
public void addAdditionalItemMove(ItemState item, ItemMove additionalItemMove)
Adds an additional item move (mainly for rockets that are launched directly into an enemy).- Parameters:
item
- The item to set the additional move for.additionalItemMove
- The additionalItemMove to set
-
getSoundInfo
public SoundFxUpdate getSoundInfo()
Gets the sound infos.- Returns:
- The sound info.
-
setSoundInfo
public void setSoundInfo(SoundFxUpdate soundFxUpdate)
Sets the sound infos.- Parameters:
soundFxUpdate
- The soundInfo to set.
-
getEffectsInfo
public EffectsInfo getEffectsInfo()
Gets the effect infos.- Returns:
- The effectsInfo.
-
setEffectsInfo
public void setEffectsInfo(EffectsInfo effectsInfo)
Sets the effect infos.- Parameters:
effectsInfo
- The effectsInfo to set.
-
getIndex
public long getIndex()
Gets the index.- Returns:
- the index
-
getRoundCount
public int getRoundCount()
- Returns:
- the roundCount
-
getFirstHumanPlayer
public FigureState getFirstHumanPlayer()
Gets the first human player in the level. PlayerFigures first, than ComputerFigures, Dummies last.- Returns:
-
getSortedPlayerList
public java.util.List<FigureState> getSortedPlayerList()
Gets a sorted list of figures in the level. PlayerFigures first, than ComputerFigures, Dummies last.- Returns:
-
getBackgroundColor
public int getBackgroundColor()
Gets the background color.- Returns:
- The background color.
-
getBackgroundForeColor
public int getBackgroundForeColor()
Gets the background forecolor.- Returns:
- The background forecolor.
-
getFlashAnimations
public java.util.List<FlashAnimationState> getFlashAnimations()
Gets a list of flash animations.- Returns:
- The list of flash animations
-
addFlashAnimation
public void addFlashAnimation(FlashAnimationState flashAnimation)
Adds a flash animation.- Parameters:
flashAnimation
- the flashAnimation to add
-
getMaxStartingLevelIndex
public int getMaxStartingLevelIndex()
Sets the maxStartingLevelIndex.- Returns:
- The maxStartingLevel
-
setMaxStartingLevelIndex
public void setMaxStartingLevelIndex(int maxStartingLevelIndex)
Sets the maxStartingLevelIndex.- Parameters:
maxStartingLevelIndex
- the maxStartingLevel to set
-
setFlashState
public void setFlashState(Game.FlashState flashState)
Sets the flash state.- Parameters:
flashState
- The flash state.
-
getFlashState
public Game.FlashState getFlashState()
Gets the flash state.- Returns:
- The flash state or null, if not flashing.
-
getLeagueState
public LeagueState getLeagueState()
Gets the league state in league game.- Returns:
- the leagueState
-
isLeagueGame
public boolean isLeagueGame()
Checks, if the game is a league game.- Returns:
- the leagueState
-
setLeagueState
public void setLeagueState(LeagueState leagueState)
- Parameters:
leagueState
- the leagueState to set
-
getPlayerID
public int getPlayerID()
Gets the player ID.- Returns:
- the playerID
-
setPlayerID
public void setPlayerID(int playerID)
Sets the playerID.- Parameters:
playerID
- The playerID to set
-
toString
public java.lang.String toString()
Returns a string representation.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string containing most important state information.
-
isEditor
public boolean isEditor()
- Returns:
- the isEditor
-
setEditor
public void setEditor(boolean isEditor)
- Parameters:
isEditor
- the isEditor to set
-
-