Package com.starpoints.game
Class Field
- java.lang.Object
-
- com.starpoints.game.Field
-
- All Implemented Interfaces:
java.io.Serializable
public class Field extends java.lang.Object implements java.io.SerializableThe field for a game of Starpoints. The field stores a number of points and handles point events when a Thing enters or stays on a point by calling the corresponding methods in this fields levels Effects.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFieldListener(FieldListener listener)Adds a field listener.voidbigMinePlaced(ItemBigMine r)Fires the bigmine placed event.voidcolorPoints(Point center, int radius, int newcolor, Thing source, AnimationInfo animation)Colors the points on the field in a best possible circle around the center point in the given color.FieldStatecreateState(java.util.Map<java.lang.Integer,FigureState> figs, AnimationInfo animation)intgetExplosionCount(Figure source)Counts the explosions currently on the field.intgetExplosionEnergyLoss()Gets the eexplosion energy loss depending on the levels settings.intgetExplosionStrength(Figure source)Aggregates the explosions strength currently on the field.intgetHeight()Gets this fields height.LevelgetLevel()Returns the level for this field.PointgetPoint(int x, int y)Gets the point at the given coordinates.intgetRandomBlueColor()Gets a random blue color depending on the levels settings.intgetRandomColor(boolean includeSwirling)Gets a random color depending on the levels settings.intgetWidth()Gets this fields width.booleanisRandomPoint(int x, int y)Checks, if a random point is on position x,y.voidremoveFieldListener(FieldListener listener)Removes a field listener.voidrocketStarted(ItemRocket r)Fires the rocket started event.voidstopSwirling(Point center, int radius)Stops swirling on the points on the field in a best possible circle around the center point in the given color.voidupdateField(AnimationInfo animation)Updates the field by calling the update method for every point and the updateEnergy-method for all point occupants afterwards.
-
-
-
Method Detail
-
isRandomPoint
public boolean isRandomPoint(int x, int y)Checks, if a random point is on position x,y.- Parameters:
x- The x coordinatey- The y coordinate- Returns:
- true, if the field info has a random point at the position.
-
getRandomColor
public int getRandomColor(boolean includeSwirling)
Gets a random color depending on the levels settings.- Parameters:
includeSwirling- Flag, if swirling colors should be included in random colors- Returns:
- A random color.
-
getWidth
public int getWidth()
Gets this fields width.- Returns:
- The width
-
getHeight
public int getHeight()
Gets this fields height.- Returns:
- The height
-
getRandomBlueColor
public int getRandomBlueColor()
Gets a random blue color depending on the levels settings.- Returns:
- A random blue color.
-
getExplosionEnergyLoss
public int getExplosionEnergyLoss()
Gets the eexplosion energy loss depending on the levels settings.- Returns:
- The energy loss in an expolosion per round.
-
getLevel
public Level getLevel()
Returns the level for this field.- Returns:
- The level.
-
getPoint
public Point getPoint(int x, int y)
Gets the point at the given coordinates. If the coordinates are off the field bounds, a lightGray Point for the given coordinates with no reference to the game is returned.- Parameters:
x- The x coordinatey- The y coordinate- Returns:
- The point at the given coordinates
-
addFieldListener
public void addFieldListener(FieldListener listener)
Adds a field listener.- Parameters:
listener- The listener
-
removeFieldListener
public void removeFieldListener(FieldListener listener)
Removes a field listener.- Parameters:
listener- The listener
-
rocketStarted
public void rocketStarted(ItemRocket r)
Fires the rocket started event.- Parameters:
r- The rocket.
-
bigMinePlaced
public void bigMinePlaced(ItemBigMine r)
Fires the bigmine placed event.- Parameters:
r- The mine.
-
updateField
public void updateField(AnimationInfo animation)
Updates the field by calling the update method for every point and the updateEnergy-method for all point occupants afterwards.- Parameters:
animation- The AnimationInfo.
-
getExplosionCount
public int getExplosionCount(Figure source)
Counts the explosions currently on the field.- Parameters:
source- The source of the explosions. Pass null for all explosions.- Returns:
- The number of explosions caused by the source, or all if null is passed.
-
getExplosionStrength
public int getExplosionStrength(Figure source)
Aggregates the explosions strength currently on the field.- Parameters:
source- The source of the explosions. Pass null for all explosions.- Returns:
- The sum of explosion strengths caused by the source, or all if null is passed.
-
colorPoints
public void colorPoints(Point center, int radius, int newcolor, Thing source, AnimationInfo animation)
Colors the points on the field in a best possible circle around the center point in the given color.- Parameters:
center- The center point.radius- The radius of the circle to color.newcolor- The new color for the points.source- The color source.animation- The AnimationInfo.
-
stopSwirling
public void stopSwirling(Point center, int radius)
Stops swirling on the points on the field in a best possible circle around the center point in the given color.- Parameters:
center- The center point.radius- The radius of the circle to stop swirling in.
-
createState
public FieldState createState(java.util.Map<java.lang.Integer,FigureState> figs, AnimationInfo animation)
-
-