Package com.starpoints.game
Class Game
- java.lang.Object
-
- com.starpoints.game.Game
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
LeagueGame
,StarpointEditor
,Tutorial
public class Game extends java.lang.Object implements java.io.Serializable
The Starpoints game. Handles the different states during game. A game instance must be initialized with a game info, that contains information about the number of players etc. the game can than be started by calling one of the two methods:- startGame() to start a new game.
- skipIntoGame(int l) to enter the game in a certain level
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Game.FlashState
States during flashing to the next level.
-
Field Summary
Fields Modifier and Type Field Description protected BonusManager
bonusManager
The Replayer.protected StarpointController
controller
The application context.protected Level
currentLevel
The current Level.protected AbstractLevelInfo
currentLevelInfo
The current Levelinfo.protected GameState
currentState
The current game stateprotected static boolean
DEBUG
Debug flag.protected static boolean
DEBUG_ROUNDS
Debug flag.protected static int[]
EXTRALIVES
Point values at which a player will get an extra life.static int
FADECOUNT
Duration of message fade mode changes in LevelIntro etc.protected long
finalScore
static int
FLASH_ANIMATION_COUNT
Number of update cycles for showing the animation to the next galaxy.static int
FLASH_FADE_IN_COUNT
Number of update cycles for fading in the new level.static int
FLASH_FADE_OUT_COUNT
Number of update cycles for fading out the old level.static int
FLASH_FIGURE_COUNT
Number of update cycles for fading out the old levels figures.static int
FLASH_TO_NEXT_COUNT
Number of update cycles during flash between two levels.protected int
flashAnimationIndex
Number of flash animation. -1, if no animation is shown.protected FlashEffects
flashFx
The flash effects for this game.protected Field
flashOldField
Last levels field for flashing.protected Game.FlashState
flashState
State for flashing.protected Effects
fx
The effects for this game.protected AnimationInfo
gameAnimation
The current game animation.protected GameInfo
gameInfo
The GameInfo.protected com.starpoints.game.Game.GameOverState
gameOverState
State for flashing.protected java.util.LinkedList<java.lang.String>
gameOverTexts
List of texts to display after a level.protected GameRoutine
gameRoutine
The game routine responsible for gameplay.protected PlayerFigure
gameWinner
The games winner.protected boolean
gotExtraLife
Flag, if the last levels winner gained an extra life.protected boolean
isUpdating
Flag, that is true during update routine.protected int
levelCount
The number of the current level.protected java.util.List<Figure>
levelEnemies
List of enemies in the current level.protected java.util.List<Figure>
levelFigures
List of all figures in the current level.protected java.util.List<PlayerFigure>
levelPlayers
List of player figures in the current level.protected LevelSet
levelSet
The level set.static int
MAX_LEVELOVERMODE
Max counter for mode changes in LevelIntro etc.protected int
maxStartLevel
The highest level to select when starting game.protected java.lang.String
message
The current game message.protected GameMode
mode
Current state of the game.protected int
modeCount
Counter for flashing.protected java.util.Hashtable<java.lang.Integer,PlayerFigure>
playerFigures
Table storing all figures mapping ids to figuresprotected boolean
replay
Flag, if replay should be played for last level.protected Replayer
replayer
The Replayer.protected int
scoreEntered
Flag, if one player reached the high score list. -1 if highscore list was not reached.protected int
selectedLevel
Currently selected level index.protected Shop
shop
The shop if in shop mode, otherwise null.int
thingNextID
Stores the (static) next thing id for saving (by serialization of the game).
-
Constructor Summary
Constructors Constructor Description Game(StarpointController context, GameInfo gameInfo)
Creates a new game.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
adjustPlayerForLevel(FlashAnimationInfo fai)
Adds items, energy and screenitems to the player figures, depending on the current level.protected boolean
allAlive()
Checks, if any human player has lost all his or her lives.boolean
canEnterScoreList()
Checks, if high score list entry is valid for this game.protected void
clearLevelItems()
Calls the onLevelFinishedMethod for all items on the field.protected void
createAndPlaceEnemyFigures(LevelInfo li, java.util.List<Figure> figures, Field field, java.util.List<java.lang.Integer> ids)
Initializes the enemy figures for a new level and places tham.protected void
createAndPlacePlayerFigures(java.util.List<Figure> figures, Field field, java.util.Collection<java.lang.Integer> ids)
Reinitializes and places the player figures for a new level.Figure
createFigureFromInfo(FigureInfo figureInfo)
Returns a new instance of a Figure of the given class.protected GameState
createGameStateReplay()
Item
createItem(ItemInfo ii)
Creates an item for the given ItemInfo with the given energy and maxenergy.Item
createItem(java.lang.String className)
Creates an item for the given ItemClass.protected PlayerFigure
createPlayerFigure(int i, FigureInfo figureInfo)
Creates a player figureGameState
createState()
Creates a GameState object representing the current state of the game.protected boolean
currentLevelHasFlashAnimation()
Checks, if the current level has a flash animation.protected PlayerFigure
determineGameWinner(java.util.List<PlayerFigure> levelPlayers)
Gets the winner of the last game.protected void
determineLevelOverMessages(boolean gotExtraLife, BonusDescriptor bd)
Creates the list of messages to display after level is over.protected java.lang.String
determineLevelOverString(Figure lastWinner)
Returns a string describing the last levels result.protected Figure
determineLevelWinner()
Gets the winner of the last level.static long
determineNextExtraLifeCount(long oldPointSum)
Determines the next point count, at which this figure gets an extra life.void
displayMessage(java.lang.String msg, int duration, MessagePosition pos, int c, FontSize size)
Displays a message by calling controllers displayMessage.protected void
fillGameState(GameState gs)
protected void
findAndPlaceEnemy(LevelInfo li, java.util.List<Figure> figures, Field field, java.util.List<java.lang.Integer> ids, EnemyInfo ei, int invulnerableRounds)
Finds and places an enemy and adds it to the list of figures.FigureInfo
findEnemyInfoForClassName(java.lang.String name)
Returns the FigureInfo for a given enemy classprotected FlashAnimationInfo
findPreviousFlashAnimationInfo()
Finds the FlashAnimationInfo before the currently selected level.protected void
finishFlashAnimation()
Finishes a flash animation and switches to FlashToNext.void
finishLevelSelection()
Finishes LevelSelection.protected void
gameFinishAnimation()
Performs the game finished animation.protected void
gameOver()
Displays winner messages etc. during mode Game over..AnimationInfo
getAnimationInfo()
Gets the current AnimationInfo.BonusManager
getBonusManager()
Gets the BonusManager.StarpointController
getController()
Gets the game context.AbstractLevelInfo
getCurrentLevelInfo()
Gets the Info for the currently selected level (or shop or FlashAnimation).GameState
getCurrentState()
int
getDefaultExplosionRadius(int c)
Returns the default radius, an explosion has on the different colors.Effects
getEffects()
Gets the Point effects reference.int
getEnemyCount()
Returns the number of enemies in the current level.Field
getField()
Gets the field of the current level.int
getFlashAnimationIndex()
Gets the current flash animation index.java.util.LinkedList<FlashAnimationInfo>
getFlashAnimationInfos()
Gets the list of FlashAnimationInfos of the level set.protected java.lang.String
getFlashAnimationSound()
Retrieves the sound from the next level for flash animation.GameInfo
getGameInfo()
Gets the GameInfo.java.lang.String
getGameInfoFileName()
Gets the name of the GameInfo-Inifile.GameMode
getGameMode()
Gets ana immutable current game state e.g. for painting purposes.protected int
getGameTiming()
Gets the timing during game, depending on speed level.double
getHeatFactor()
Gets a factor for heat gain modification depending on heat options.FlashAnimationInfo
getInitialFlashInformation()
Gets the Level Sets first flash info.BonusDescriptor
getLastBonus()
Returns the current levels winners bonus during level over sequence.Figure
getLastWinner()
Returns the last levels winner.Level
getLevel()
Gets the current levelint
getLevelCount()
Returns the number of the current level.java.util.List<Figure>
getLevelEnemies()
Gets the list of enemies in the current level.java.util.List<Figure>
getLevelFigures()
Return the list of figures in the current level.protected java.lang.String
getLevelFinishedText()
Gets the Level finished text, if no human player has won.protected java.io.InputStream
getLevelInputStream()
Gets the InputStream for reading level information.protected java.lang.String
getLevelResourceName()
Gets the resource name for the LevelIni-File.LevelSet
getLevelSet()
Returns the games level set.int
getMaxStartLevel()
Gets the max. level a player might start at.java.lang.String
getMessage()
Gets the current message, the game displays.int
getMessageColor()
Gets the current message color for the message the game displays.Options
getOptions()
Gets the Options (from the GameInfo).int
getPlayerCount()
Returns the number of players.java.util.List<PlayerFigure>
getPlayers()
Gets the list of player figures in the game.Replayer
getReplayer()
Gets the replayer.int
getReplayTiming()
Gets the timing during replay, depending on speed level.int
getRoundCount()
Returns the current levels round count (or the replayers during replay).int
getSelectedLevel()
Shop
getShop()
Gets the shop.SoundFx
getSoundFx()
Gets the SoundFx.int
getStartLevel()
int
getTiming()
Gets the update time (in ms) for the current game mode, after which the next update should be called.protected boolean
giveExtraLives(Figure figure, long oldPoints)
Checks, if the figure retrieves extra lives after adding the last levels points.void
hideGameMessage()
Sets the game message to null.protected void
informReplayer(GameState currentState)
Update the replayer with the current game state.protected void
initializeFlashAnimationInfo(FlashAnimationInfo currentLevelInfo2)
Initializes the flash animation with the given FlashAnimationInfo.void
initializeFlashAnimations()
Initializes the list of flash animations from level set.protected void
initializeGameComponents()
Initializes game routine, bonus manager etc.protected void
initializeLevelSet()
Initializes the LevelSet from the Level ini file.protected Level
initializeNextLevel(LevelInfo nextLevel)
Initializes the next level for the given LevelInfo.protected Shop
initializeShop(ShopInfo si)
(Re-)Initializes the shop with the given ShopInfo.boolean
isBackgroundFlickering()
Checks, if the backgroud is flickering due to orange point entered.boolean
isDuringLevel()
Checks, if the game routine is running.boolean
isFlashing()
Checks, if currently during flash animation.boolean
isGameFinished()
Checks, if the game has finished.boolean
isGameOver()
Checks, if the state is GameOver.boolean
isLevelOver()
Checks, if this level is over.boolean
isShowingFigureVisisbility()
Checks, if the visibility display in the player panel should be shown.boolean
isShowingFlashAnimation()
Checks, if a flash animation is running.boolean
isShowingReplay()
Checks, if replay is running.boolean
isSkippable()
Checks, if the current mode can be skipped by user.protected boolean
isSteppingToNextLevel()
Checks, if game should be switches to next level, after a level is over.void
onAfterLoad()
Resets the update flag.void
onAfterSave()
Called by controller after saving is completed.void
onBeforeSave()
Waits for a current update cycle to finish.protected boolean
placeEnemyFigure(Figure f, Field field, EnemyInfo enemyInfo)
Places the enemy figures on the field.protected java.util.List<Figure>
placeFiguresForLevel(Level level)
Places the figures on the field.protected void
placeFogs(Level l)
Randomly places fogs in the level.protected void
placeItems(Level l)
Places random at defined items in the level.protected void
placePlayerFigure(Figure f, Field field, int index)
Places the figure on the field.void
quitReplay()
Quits the replay mode.protected AbstractLevelInfo
readNextLevelInfo()
Reads the next levelInfo from the specified ini file name.void
registerThingMove(Thing t, Point target)
Registers an item request for movement.protected void
reinitFigure(Field field, Figure fig)
Reinitializes the figure for a new level.protected void
replay()
Performs the replay.protected java.util.Map<Thing,Point>
requestThingMoves()
Returns the map of figure requests for movement and clear the list for next round.void
selectNextLevel()
Steps fore to the previous level during LevelSelection.void
selectPreviousLevel()
Steps back to the previous level during LevelSelection.void
setController(StarpointController controller)
Sets the context for this game (necessary after game deserialization).void
setMaxStartLevel(int maxStartLevel)
Sets the max. level a player might start at.void
setRoundCount(int roundCount)
Sets the current levels round count.protected void
setState(GameMode state)
Sets the game statevoid
skip()
Handles skip requests during level over etc.void
skipIntoGame(int levelCount, FlashAnimationInfo init, boolean startWithFastFlash)
Starts a game with the given FlashAnimationInfo.protected void
startGame()
Starts the game.protected void
startGameFinishedFlash()
Starts the routine after a player has finished the complete game.protected void
startLevelOver()
Starts the level over sequence.void
startReplay()
Starts the replay mode.protected void
stepToNextLevel()
Steps to the next level, after flash fade out field or end of shop or flash animation.protected void
switchLevelAfterLevelOver()
Switches to the next levels flash effect after all level over messages are shown.protected void
switchToLevelIntro()
Switches to mode LevelIntro.protected boolean
switchToNextLevel()
Switches to the next level.void
update()
Updates the game.
-
-
-
Field Detail
-
DEBUG
protected static final boolean DEBUG
Debug flag.- See Also:
- Constant Field Values
-
DEBUG_ROUNDS
protected static final boolean DEBUG_ROUNDS
Debug flag.- See Also:
- Constant Field Values
-
MAX_LEVELOVERMODE
public static final int MAX_LEVELOVERMODE
Max counter for mode changes in LevelIntro etc.- See Also:
- Constant Field Values
-
FADECOUNT
public static final int FADECOUNT
Duration of message fade mode changes in LevelIntro etc.- See Also:
- Constant Field Values
-
FLASH_FIGURE_COUNT
public static final int FLASH_FIGURE_COUNT
Number of update cycles for fading out the old levels figures.- See Also:
- Constant Field Values
-
FLASH_FADE_OUT_COUNT
public static final int FLASH_FADE_OUT_COUNT
Number of update cycles for fading out the old level.- See Also:
- Constant Field Values
-
FLASH_TO_NEXT_COUNT
public static final int FLASH_TO_NEXT_COUNT
Number of update cycles during flash between two levels.- See Also:
- Constant Field Values
-
FLASH_FADE_IN_COUNT
public static final int FLASH_FADE_IN_COUNT
Number of update cycles for fading in the new level.- See Also:
- Constant Field Values
-
FLASH_ANIMATION_COUNT
public static final int FLASH_ANIMATION_COUNT
Number of update cycles for showing the animation to the next galaxy.- See Also:
- Constant Field Values
-
thingNextID
public int thingNextID
Stores the (static) next thing id for saving (by serialization of the game).
-
EXTRALIVES
protected static int[] EXTRALIVES
Point values at which a player will get an extra life.
-
playerFigures
protected java.util.Hashtable<java.lang.Integer,PlayerFigure> playerFigures
Table storing all figures mapping ids to figures
-
currentLevel
protected Level currentLevel
The current Level.
-
currentLevelInfo
protected AbstractLevelInfo currentLevelInfo
The current Levelinfo.
-
levelCount
protected int levelCount
The number of the current level.
-
gameInfo
protected GameInfo gameInfo
The GameInfo.
-
mode
protected GameMode mode
Current state of the game.
-
controller
protected transient StarpointController controller
The application context.
-
fx
protected Effects fx
The effects for this game.
-
flashFx
protected FlashEffects flashFx
The flash effects for this game.
-
levelSet
protected LevelSet levelSet
The level set.
-
levelFigures
protected java.util.List<Figure> levelFigures
List of all figures in the current level.
-
levelPlayers
protected java.util.List<PlayerFigure> levelPlayers
List of player figures in the current level.
-
levelEnemies
protected java.util.List<Figure> levelEnemies
List of enemies in the current level.
-
isUpdating
protected boolean isUpdating
Flag, that is true during update routine.
-
gameWinner
protected PlayerFigure gameWinner
The games winner.
-
replay
protected boolean replay
Flag, if replay should be played for last level.
-
gameOverTexts
protected java.util.LinkedList<java.lang.String> gameOverTexts
List of texts to display after a level.
-
gameAnimation
protected AnimationInfo gameAnimation
The current game animation.
-
flashState
protected Game.FlashState flashState
State for flashing.
-
gameOverState
protected com.starpoints.game.Game.GameOverState gameOverState
State for flashing.
-
modeCount
protected int modeCount
Counter for flashing.
-
flashAnimationIndex
protected int flashAnimationIndex
Number of flash animation. -1, if no animation is shown.
-
flashOldField
protected Field flashOldField
Last levels field for flashing.
-
message
protected java.lang.String message
The current game message.
-
scoreEntered
protected int scoreEntered
Flag, if one player reached the high score list. -1 if highscore list was not reached.
-
finalScore
protected long finalScore
-
replayer
protected Replayer replayer
The Replayer.
-
bonusManager
protected BonusManager bonusManager
The Replayer.
-
shop
protected Shop shop
The shop if in shop mode, otherwise null.
-
gotExtraLife
protected boolean gotExtraLife
Flag, if the last levels winner gained an extra life.
-
maxStartLevel
protected int maxStartLevel
The highest level to select when starting game. Default is -1 for no free levels.
-
selectedLevel
protected int selectedLevel
Currently selected level index.
-
gameRoutine
protected GameRoutine gameRoutine
The game routine responsible for gameplay.
-
currentState
protected GameState currentState
The current game state
-
-
Constructor Detail
-
Game
public Game(StarpointController context, GameInfo gameInfo)
Creates a new game. Player figures are initialized.- Parameters:
context
- The application context.gameInfo
- The GameInfo.
-
-
Method Detail
-
initializeGameComponents
protected void initializeGameComponents()
Initializes game routine, bonus manager etc.
-
createPlayerFigure
protected PlayerFigure createPlayerFigure(int i, FigureInfo figureInfo)
Creates a player figure- Parameters:
i
- The figure number.figureInfo
- The playerfigure info.- Returns:
- The PlayerFigure.
-
initializeLevelSet
protected void initializeLevelSet()
Initializes the LevelSet from the Level ini file.
-
initializeFlashAnimations
public void initializeFlashAnimations()
Initializes the list of flash animations from level set.
-
initializeNextLevel
protected Level initializeNextLevel(LevelInfo nextLevel)
Initializes the next level for the given LevelInfo.- Parameters:
nextLevel
- LevelInfo.- Returns:
- the level.
-
placeFogs
protected void placeFogs(Level l)
Randomly places fogs in the level.- Parameters:
l
- the level.
-
placeItems
protected void placeItems(Level l)
Places random at defined items in the level.- Parameters:
l
- the level.
-
readNextLevelInfo
protected AbstractLevelInfo readNextLevelInfo()
Reads the next levelInfo from the specified ini file name.- Returns:
- The next LevelInfo or null, if no next level exists.
-
getLevelInputStream
protected java.io.InputStream getLevelInputStream()
Gets the InputStream for reading level information.- Returns:
- A resource input string from the controller to the game infos ini file.
-
getLevelResourceName
protected java.lang.String getLevelResourceName()
Gets the resource name for the LevelIni-File.- Returns:
- The GameInfos level ini filename.
-
placeFiguresForLevel
protected java.util.List<Figure> placeFiguresForLevel(Level level)
Places the figures on the field.- Parameters:
level
- The level- Returns:
- The list of level figures.
-
createAndPlacePlayerFigures
protected void createAndPlacePlayerFigures(java.util.List<Figure> figures, Field field, java.util.Collection<java.lang.Integer> ids)
Reinitializes and places the player figures for a new level.- Parameters:
figures
- The List of figures to add the created figures to.field
- The field.ids
- The list of figure ids.
-
reinitFigure
protected void reinitFigure(Field field, Figure fig)
Reinitializes the figure for a new level.- Parameters:
field
- The field of the new level.fig
- The figure.
-
placePlayerFigure
protected void placePlayerFigure(Figure f, Field field, int index)
Places the figure on the field. Depending on the index, the figure is placed in one of the corners of the field, or randomly on an empty field for indexes higher than 3.- Parameters:
f
- The figure to place.field
- The field.index
- The players index.
-
createAndPlaceEnemyFigures
protected void createAndPlaceEnemyFigures(LevelInfo li, java.util.List<Figure> figures, Field field, java.util.List<java.lang.Integer> ids)
Initializes the enemy figures for a new level and places tham.- Parameters:
li
- The LevelInfo.figures
- The list of figures to add the enemies to.field
- The field.ids
- A list of already placed figures ids.
-
findAndPlaceEnemy
protected void findAndPlaceEnemy(LevelInfo li, java.util.List<Figure> figures, Field field, java.util.List<java.lang.Integer> ids, EnemyInfo ei, int invulnerableRounds)
Finds and places an enemy and adds it to the list of figures.- Parameters:
li
- level info.figures
- List of figuresfield
- The fieldids
- A list of already used enemy ids.ei
- The enemy info object.invulnerableRounds
- Number of rounds figure is invulnerable.
-
placeEnemyFigure
protected boolean placeEnemyFigure(Figure f, Field field, EnemyInfo enemyInfo)
Places the enemy figures on the field. Depending on the index, the figure is placed in one of the corners of the field, or randomly on an empty field for indexes higher than 3.- Parameters:
f
- The Enemy.field
- The field.enemyInfo
- The EnemyInfo.- Returns:
- true, if the point to place the figure on is unoccupied.
-
findEnemyInfoForClassName
public FigureInfo findEnemyInfoForClassName(java.lang.String name)
Returns the FigureInfo for a given enemy class- Parameters:
name
- The classname.- Returns:
- The FigureInfo.
-
getLevelFigures
public java.util.List<Figure> getLevelFigures()
Return the list of figures in the current level.- Returns:
- The list of figures.
-
createFigureFromInfo
public Figure createFigureFromInfo(FigureInfo figureInfo)
Returns a new instance of a Figure of the given class. If the class cannot be found or another Exception occurs during figure creation, a normal dummy figure is returned.- Parameters:
figureInfo
- The info about the figure- Returns:
- A figure of the desired class (s.a.)
-
isDuringLevel
public boolean isDuringLevel()
Checks, if the game routine is running.- Returns:
- true for RoundBegin, RoundBeforeGettingMoves, RoundBeforeMoves, RoundBeforeUpdate
-
isSkippable
public boolean isSkippable()
Checks, if the current mode can be skipped by user.- Returns:
- true for GameOver, LevelOver, -Intro, -Info and -Text
-
determineLevelWinner
protected Figure determineLevelWinner()
Gets the winner of the last level.- Returns:
- The last levels winner or null for remis.
-
determineLevelOverString
protected java.lang.String determineLevelOverString(Figure lastWinner)
Returns a string describing the last levels result.- Parameters:
lastWinner
- The last levels winner.- Returns:
- A string that is used for the level dialog.
-
determineGameWinner
protected PlayerFigure determineGameWinner(java.util.List<PlayerFigure> levelPlayers)
Gets the winner of the last game.- Parameters:
levelPlayers
- The list of figures in the level.- Returns:
- The last games winner.
-
getOptions
public Options getOptions()
Gets the Options (from the GameInfo).- Returns:
- The options.
-
getGameInfoFileName
public java.lang.String getGameInfoFileName()
Gets the name of the GameInfo-Inifile.- Returns:
- The name of the GameInfo-Inifile.
-
getGameInfo
public GameInfo getGameInfo()
Gets the GameInfo.- Returns:
- The GameInfo.
-
displayMessage
public void displayMessage(java.lang.String msg, int duration, MessagePosition pos, int c, FontSize size)
Displays a message by calling controllers displayMessage.- Parameters:
msg
- The messageduration
- The durationpos
- The positionc
- The colorsize
- The text size
-
getField
public Field getField()
Gets the field of the current level.- Returns:
- The current levels field. Might be null during Level flash!
-
getPlayerCount
public int getPlayerCount()
Returns the number of players.- Returns:
- The number of players.
-
getEnemyCount
public int getEnemyCount()
Returns the number of enemies in the current level.- Returns:
- The number of enemies.
-
getLevelCount
public int getLevelCount()
Returns the number of the current level. First level is 0.- Returns:
- The number of the current level
-
getCurrentLevelInfo
public AbstractLevelInfo getCurrentLevelInfo()
Gets the Info for the currently selected level (or shop or FlashAnimation).- Returns:
- The current level info.
-
getHeatFactor
public double getHeatFactor()
Gets a factor for heat gain modification depending on heat options.- Returns:
- A factor for heat gains.
-
getEffects
public Effects getEffects()
Gets the Point effects reference.- Returns:
- The game effects.
-
getBonusManager
public BonusManager getBonusManager()
Gets the BonusManager.- Returns:
- The BonusManager.
-
getDefaultExplosionRadius
public int getDefaultExplosionRadius(int c)
Returns the default radius, an explosion has on the different colors. Returns 4 for very dark blue, 3 for dark blue, 2 for blue, 1 for light dark blue, -1 for any other color- Parameters:
c
- The color to get the explosion radius for- Returns:
- The radius in points. Goes well with explosion methods in Effects class.
-
isBackgroundFlickering
public boolean isBackgroundFlickering()
Checks, if the backgroud is flickering due to orange point entered.- Returns:
- true, if the backgroud is flickering.
-
getGameMode
public GameMode getGameMode()
Gets ana immutable current game state e.g. for painting purposes. This state is updated after each sequence of a game round and contains an immutable copy of all paint relevant information.- Returns:
- The current state.
-
isShowingFigureVisisbility
public boolean isShowingFigureVisisbility()
Checks, if the visibility display in the player panel should be shown.- Returns:
- true during Replay or running level.
-
getLevel
public Level getLevel()
Gets the current level- Returns:
- The current level.
-
getMessage
public java.lang.String getMessage()
Gets the current message, the game displays.- Returns:
- The current game message
-
getMessageColor
public int getMessageColor()
Gets the current message color for the message the game displays.- Returns:
- The current game message color
-
isGameOver
public boolean isGameOver()
Checks, if the state is GameOver.- Returns:
- true , if the state is GameOver.
-
isGameFinished
public boolean isGameFinished()
Checks, if the game has finished.- Returns:
- true , if the state is Finished.
-
hideGameMessage
public void hideGameMessage()
Sets the game message to null.
-
registerThingMove
public void registerThingMove(Thing t, Point target)
Registers an item request for movement. Call this method if an item wants to move during item usage (Item.beUsed) or field update (Item.performFieldUpdate).- Parameters:
t
- The thing.target
- The target point.
-
requestThingMoves
protected java.util.Map<Thing,Point> requestThingMoves()
Returns the map of figure requests for movement and clear the list for next round.- Returns:
- Map of move requests.
-
update
public void update()
Updates the game. Must be called by the application during game frequently to update the game.
-
informReplayer
protected void informReplayer(GameState currentState)
Update the replayer with the current game state.
-
gameFinishAnimation
protected void gameFinishAnimation()
Performs the game finished animation.
-
startGame
protected void startGame()
Starts the game. Switches to the next level and sets mode to LevelText.
-
findPreviousFlashAnimationInfo
protected FlashAnimationInfo findPreviousFlashAnimationInfo()
Finds the FlashAnimationInfo before the currently selected level.- Returns:
- The FlashAnimationInfo before the currently selected level.
-
quitReplay
public void quitReplay()
Quits the replay mode.
-
skipIntoGame
public void skipIntoGame(int levelCount, FlashAnimationInfo init, boolean startWithFastFlash)
Starts a game with the given FlashAnimationInfo.- Parameters:
levelCount
- The level index before the first level to play.init
- The flash animation used for player adjustment.startWithFastFlash
- Flag, if game starts with a fast flash, with level intro if false.
-
adjustPlayerForLevel
protected void adjustPlayerForLevel(FlashAnimationInfo fai)
Adds items, energy and screenitems to the player figures, depending on the current level.- Parameters:
fai
- The FlashAnimationInfo before the level skipped to.
-
switchToNextLevel
protected boolean switchToNextLevel()
Switches to the next level. If the last level has been reached, currentLevel is set to null and false is returned- Returns:
- true, if there is a next level.
-
switchToLevelIntro
protected void switchToLevelIntro()
Switches to mode LevelIntro. Sets the game message to the Level intro text ("Enter Level x!").
-
startLevelOver
protected void startLevelOver()
Starts the level over sequence.
-
determineLevelOverMessages
protected void determineLevelOverMessages(boolean gotExtraLife, BonusDescriptor bd)
Creates the list of messages to display after level is over.- Parameters:
gotExtraLife
- Flag, if the level winner got an extra live.bd
- The BonusDescriptor to fill.
-
getLevelFinishedText
protected java.lang.String getLevelFinishedText()
Gets the Level finished text, if no human player has won.- Returns:
- "Level finished!"
-
switchLevelAfterLevelOver
protected void switchLevelAfterLevelOver()
Switches to the next levels flash effect after all level over messages are shown. Determines whether to show replay first. Otherwise, either the next level is initialized, or the game finish animation is started, if the last level is over.
-
clearLevelItems
protected void clearLevelItems()
Calls the onLevelFinishedMethod for all items on the field.
-
startReplay
public void startReplay()
Starts the replay mode.
-
isSteppingToNextLevel
protected boolean isSteppingToNextLevel()
Checks, if game should be switches to next level, after a level is over.- Returns:
- true, if either a player won the level, or if player count is 0, or if level.stepToNextLevel() returns true.
-
startGameFinishedFlash
protected void startGameFinishedFlash()
Starts the routine after a player has finished the complete game.
-
giveExtraLives
protected boolean giveExtraLives(Figure figure, long oldPoints)
Checks, if the figure retrieves extra lives after adding the last levels points.- Parameters:
figure
- The figure to checkoldPoints
- The figures point sum before finishing the last level.- Returns:
- true, if the figure got an extra life.
-
onBeforeSave
public void onBeforeSave()
Waits for a current update cycle to finish.
-
onAfterSave
public void onAfterSave()
Called by controller after saving is completed. Resets the isSaveRequested-flag to no longer prevent updating.
-
onAfterLoad
public void onAfterLoad()
Resets the update flag.
-
replay
protected void replay()
Performs the replay.
-
stepToNextLevel
protected void stepToNextLevel()
Steps to the next level, after flash fade out field or end of shop or flash animation. Reinitializes the player figures. Switches either to flash to next level, shop or FlashAnimation.
-
currentLevelHasFlashAnimation
protected boolean currentLevelHasFlashAnimation()
Checks, if the current level has a flash animation.- Returns:
- true, if the current level has a flash animation.
-
getFlashAnimationSound
protected java.lang.String getFlashAnimationSound()
Retrieves the sound from the next level for flash animation.- Returns:
- The next levels sound if existing, otherwise the current levels sound, or "flashLevel" as fallback.
-
finishFlashAnimation
protected void finishFlashAnimation()
Finishes a flash animation and switches to FlashToNext.
-
getFlashAnimationIndex
public int getFlashAnimationIndex()
Gets the current flash animation index.- Returns:
- The flash animation index.
-
isShowingFlashAnimation
public boolean isShowingFlashAnimation()
Checks, if a flash animation is running.- Returns:
- true, if flash animation is running.
-
isFlashing
public boolean isFlashing()
Checks, if currently during flash animation.- Returns:
- true, if currently during flash animation.
-
gameOver
protected void gameOver()
Displays winner messages etc. during mode Game over..
-
canEnterScoreList
public boolean canEnterScoreList()
Checks, if high score list entry is valid for this game.- Returns:
- always true (originally only in a one player game).
-
determineNextExtraLifeCount
public static long determineNextExtraLifeCount(long oldPointSum)
Determines the next point count, at which this figure gets an extra life.- Parameters:
oldPointSum
- The point score. The next highest extra point sum is serached.- Returns:
- The point sum for the next extra life.
-
setController
public void setController(StarpointController controller)
Sets the context for this game (necessary after game deserialization).- Parameters:
controller
- the context.
-
getTiming
public int getTiming()
Gets the update time (in ms) for the current game mode, after which the next update should be called.- Returns:
- The frequence in ms, after which the next update-call should be done.
-
skip
public void skip()
Handles skip requests during level over etc.
-
getReplayTiming
public int getReplayTiming()
Gets the timing during replay, depending on speed level.- Returns:
- The replay timing in ms.
-
getGameTiming
protected int getGameTiming()
Gets the timing during game, depending on speed level.- Returns:
- 100 for normal speed,
-
getRoundCount
public int getRoundCount()
Returns the current levels round count (or the replayers during replay).- Returns:
- The round count.
-
setRoundCount
public void setRoundCount(int roundCount)
Sets the current levels round count.- Parameters:
roundCount
- The new round count.
-
getPlayers
public java.util.List<PlayerFigure> getPlayers()
Gets the list of player figures in the game.- Returns:
- The list of player figures in the game.
-
getLevelEnemies
public java.util.List<Figure> getLevelEnemies()
Gets the list of enemies in the current level.- Returns:
- The list of enemies in the current level.
-
isShowingReplay
public boolean isShowingReplay()
Checks, if replay is running.- Returns:
- state == GameState.Replay
-
getAnimationInfo
public AnimationInfo getAnimationInfo()
Gets the current AnimationInfo. Returns the game routine gameAnimation during game, the replayeers during replay and this games animation during other game states.- Returns:
- The animation Info
-
allAlive
protected boolean allAlive()
Checks, if any human player has lost all his or her lives.- Returns:
- true, if all human players are still alive.
-
getController
public StarpointController getController()
Gets the game context.- Returns:
- The gme context.
-
getShop
public Shop getShop()
Gets the shop.- Returns:
- The Shop.
-
initializeShop
protected Shop initializeShop(ShopInfo si)
(Re-)Initializes the shop with the given ShopInfo.- Parameters:
si
- The ShopInfo.- Returns:
- The Shop.
-
initializeFlashAnimationInfo
protected void initializeFlashAnimationInfo(FlashAnimationInfo currentLevelInfo2)
Initializes the flash animation with the given FlashAnimationInfo.- Parameters:
currentLevelInfo2
- The FlashAnimationInfo.
-
createState
public GameState createState()
Creates a GameState object representing the current state of the game.- Returns:
- The GameState.
-
fillGameState
protected void fillGameState(GameState gs)
- Parameters:
gs
-
-
createGameStateReplay
protected GameState createGameStateReplay()
- Returns:
-
getInitialFlashInformation
public FlashAnimationInfo getInitialFlashInformation()
Gets the Level Sets first flash info.- Returns:
- An initial FlashAnimationInfo.
-
getSoundFx
public SoundFx getSoundFx()
Gets the SoundFx.- Returns:
- The Sound fx.
-
setState
protected void setState(GameMode state)
Sets the game state- Parameters:
state
- The new state
-
getReplayer
public Replayer getReplayer()
Gets the replayer.- Returns:
- The replayer.
-
createItem
public Item createItem(ItemInfo ii)
Creates an item for the given ItemInfo with the given energy and maxenergy.- Parameters:
ii
- The ItemInfo specifying the items class and energy.- Returns:
- The item.
-
createItem
public Item createItem(java.lang.String className)
Creates an item for the given ItemClass.- Parameters:
className
- The items classname. Might be fully qualified classname or any simple classname for items from package com.starpoints.game.item- Returns:
- An item for the given class
-
getMaxStartLevel
public int getMaxStartLevel()
Gets the max. level a player might start at. Default is -1 for no free levels. If MaxStartLevel is set to a level lower than the first level entry, game starts directly at level 1, otherwise with level selection.- Returns:
- The Max. start level.
-
setMaxStartLevel
public void setMaxStartLevel(int maxStartLevel)
Sets the max. level a player might start at. Default is -1 for no free levels. If MaxStartLevel is set to a level lower than the first level entry, game starts directly at level 1, otherwise with level selection.- Parameters:
maxStartLevel
- The Max. start level.
-
selectPreviousLevel
public void selectPreviousLevel()
Steps back to the previous level during LevelSelection.
-
getSelectedLevel
public int getSelectedLevel()
-
selectNextLevel
public void selectNextLevel()
Steps fore to the previous level during LevelSelection.
-
finishLevelSelection
public void finishLevelSelection()
Finishes LevelSelection.
-
getLastWinner
public Figure getLastWinner()
Returns the last levels winner.- Returns:
- the lastWinner
-
getLastBonus
public BonusDescriptor getLastBonus()
Returns the current levels winners bonus during level over sequence.- Returns:
- the lastBonus
-
getStartLevel
public int getStartLevel()
- Returns:
- the startLevel
-
getLevelSet
public LevelSet getLevelSet()
Returns the games level set.- Returns:
- The LevelSet.
-
getFlashAnimationInfos
public java.util.LinkedList<FlashAnimationInfo> getFlashAnimationInfos()
Gets the list of FlashAnimationInfos of the level set.- Returns:
- The FlashAnimationInfos
-
getCurrentState
public GameState getCurrentState()
- Returns:
- the currentState
-
isLevelOver
public boolean isLevelOver()
Checks, if this level is over.- Returns:
- Return value of level.isLevelOver().
-
-