Package com.starpoints.game
Class Point
- java.lang.Object
-
- com.starpoints.game.Point
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public final class Point extends java.lang.Object implements java.io.Serializable, java.lang.CloneableThe point is the atomic part on the Starpoint field. It has a color, and x and y coordinates on the field. It can have one occupant, which might be any thing, an item, or a figure, but only one at once. In addition to that, a fog can reside on a point. If a point is exploding, the explosionCounter is greater 0 indicating the number of rounds the point will proceed to explode. The explosion power is removed from an occupant as explosion damage each round it stays on the point. Use the explode()-methods to make the point explode immediatly (energy losses to occupants caused by the explosion are handled at the end of the round like all others. Use the explodeDelayed()-method, to cause a delayed explosion of the point after a specified number of rounds. The Effect-class provides convenience methods to make all points in a certain radius explode.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanblueSwirlingFlag, if the blue swirling efffect is on.protected intcolorThis points color.protected intcolorPowerThe power of the new color setter.protected ThingcolorSrcReference to the last caller of setColor().protected intcountDownCounter for delayed explosions.protected ThingdelayerThe source of a delayed explosion.protected intdelayExplosionLengthLength of delayed explosions.protected intdelayExplosionPowerExplosion power for delayed explosions.protected intdelayExplosionRadiusRadius of delayed explosions.protected intexplosionPowerThe current explosions power.protected ThingexplosionSourceThe source of an explosion on this pointprotected FieldfieldThe field this point is on.protected FogfogThe fog on the point.protected ThinggrayerThe source of a gray colouringprotected ThingheaterLast thing responsible for heat change.protected intheatLevelHeat value for occupants.protected intnewColorThe new color to set.protected ThingswirlerThe source of a swirling effectprotected intswirlingCounter for swirling effect.intxThe x coordinate of this point.intyThe y coordinate of this point.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PointStatecreateState(java.util.Map<java.lang.Integer,FigureState> figs, AnimationInfo animation)Creates a state object for this point.voiddrawAsTarget()After calling this method, the point will be drawn with a target cross this round.booleanequals(java.lang.Object o)Checks, if the other Object is a thing with the same id.voidexplode(int length, int power, Thing source)Lets the point explode for the number of length rounds with an explosion power of power.voidexplode(Thing source)Lets this point explode for 3 rounds with the fields default energy loss.voidexplodeDelayed(int delay, int power, int radius, int rounds, Thing source)Lets the point explode after the given delay with the given explosion power for the given number of rounds with the given radius.intgetColor()Returns the points color.intgetDotColor()Gets the color of a dot to display on the point.ThinggetEnergyLossSource()Gets the source of enrgy losses on this pointintgetExplosionCounter()Returns the explosion counter that indicates how many rounds this point will explode.intgetExplosionPower()Gets the explosion power of this point.FieldgetField()Gets the field this point belongs to.FoggetFog()Gets the fog on the point.ThinggetHeater()Gets the thing that is responsible for the points heat.intgetHeatLevel()Gets the heat level of this point.intgetID()static intgetNextID()Gets the next possible ID for a figure.ThinggetOccupant()Returns this points opponentThinggetOldOccupant()Gets the last occupant.intgetX()Gets the x coordinate of the point.intgetY()Gets the y coordinate of the point.inthashCode()Returns the id.booleanisBlueSwirling()Checks, if this point is blue swirling.booleanisExploding()Checks, if this point is exploding.booleanisOccupied()Checks, if the point is occupied.booleanisRandomPoint()Checks, if this is a randomly colored point.booleanisSwirling()Checks, if this point is swirling.booleanisTarget()Checks, if targetcross to display on the point.voidoccupy(Thing newOccupant, boolean performEnterEffect, AnimationInfo animation)Occupies this point with the thing newOccupant performs the point enter effect.voidsetColor(int newColor, Thing source, AnimationInfo animation)Sets the new color of the point.voidsetDotColor(int col)Sets a color for a dot in the middle of the point.voidsetExplosionCounter(int explosionCounter)Sets the explosion counter that indicates how many rounds this point will explode.voidsetFog(Fog fog)Sets the fog on this point.voidsetHeatLevel(int heat, Thing heater)Sets the heat level of this point.voidsetID(int iD)voidstopExplosion()Stops an explosion on the point.voidstopSwirling()Stops the swirling color effect for this point.voidswirlBlue(int rounds, Thing source)Starts the swirling color effect for the given number of rounds.voidswirlColors(int rounds, Thing source)Starts the swirling color effect for the given number of rounds.java.lang.StringtoLongString()Returns a String represantation for this point containing this points coordinates, occupant info etc.java.lang.StringtoString()Returns a String represantation for this point containing this points coordinatesprotected voidupdateOccupant(AnimationInfo animation)Updates the points occupant.protected voidupdatePoint(AnimationInfo animation)Update routine which is called once after each round in a game. - It fires OccupantEvents if a thing stays on a field or left it this round. - If this point is currently exploding, the explosion pointer is increased, and the status set back to normal, if the explosion length is reached, otherwise any opponent is hit with the explosion power.
-
-
-
Field Detail
-
x
public int x
The x coordinate of this point.
-
y
public int y
The y coordinate of this point.
-
swirling
protected int swirling
Counter for swirling effect.
-
heatLevel
protected int heatLevel
Heat value for occupants.
-
heater
protected Thing heater
Last thing responsible for heat change.
-
blueSwirling
protected boolean blueSwirling
Flag, if the blue swirling efffect is on.
-
field
protected Field field
The field this point is on.
-
color
protected int color
This points color.
-
explosionSource
protected Thing explosionSource
The source of an explosion on this point
-
swirler
protected Thing swirler
The source of a swirling effect
-
grayer
protected Thing grayer
The source of a gray colouring
-
fog
protected Fog fog
The fog on the point.
-
delayer
protected Thing delayer
The source of a delayed explosion.
-
countDown
protected int countDown
Counter for delayed explosions.
-
delayExplosionPower
protected int delayExplosionPower
Explosion power for delayed explosions.
-
delayExplosionRadius
protected int delayExplosionRadius
Radius of delayed explosions.
-
delayExplosionLength
protected int delayExplosionLength
Length of delayed explosions.
-
explosionPower
protected int explosionPower
The current explosions power.
-
colorPower
protected int colorPower
The power of the new color setter.
-
newColor
protected int newColor
The new color to set.
-
colorSrc
protected Thing colorSrc
Reference to the last caller of setColor().
-
-
Constructor Detail
-
Point
public Point(Field f, int x, int y, int color)
Creates a new point on the field f at the coordinates (x,y).- Parameters:
f- The Field to create the point on.x- The x coordinate of this point.y- The y coordinate of this point.color- The color of this point.
-
-
Method Detail
-
getColor
public int getColor()
Returns the points color.- Returns:
- The color of this point
-
drawAsTarget
public void drawAsTarget()
After calling this method, the point will be drawn with a target cross this round.
-
getHeatLevel
public int getHeatLevel()
Gets the heat level of this point.- Returns:
- The heat level
-
setHeatLevel
public void setHeatLevel(int heat, Thing heater)Sets the heat level of this point.- Parameters:
heat- The heat levelheater- The responsible thing
-
explode
public void explode(Thing source)
Lets this point explode for 3 rounds with the fields default energy loss.- Parameters:
source- The explosion source.
-
explode
public void explode(int length, int power, Thing source)Lets the point explode for the number of length rounds with an explosion power of power. If the point is currently exploding, the new explosions power is added to the current power.- Parameters:
length- The length of the explosion.power- The explosion power.source- The explosion source.
-
getEnergyLossSource
public Thing getEnergyLossSource()
Gets the source of enrgy losses on this point- Returns:
- A thing that originated the explosion, the gray color, or the swirling state of this point.
-
updatePoint
protected void updatePoint(AnimationInfo animation)
Update routine which is called once after each round in a game. - It fires OccupantEvents if a thing stays on a field or left it this round. - If this point is currently exploding, the explosion pointer is increased, and the status set back to normal, if the explosion length is reached, otherwise any opponent is hit with the explosion power.- Parameters:
animation- The AnimationInfo
-
updateOccupant
protected void updateOccupant(AnimationInfo animation)
Updates the points occupant. If an opponent is destroyed, he is removed from the field.- Parameters:
animation- The AnimationInfo.
-
occupy
public void occupy(Thing newOccupant, boolean performEnterEffect, AnimationInfo animation)
Occupies this point with the thing newOccupant performs the point enter effect. The things coordinates are set to this points coordinates.- Parameters:
newOccupant- The new occupant for this point. (The old occupant is remembered until the update routine in this.oldOccupant.)performEnterEffect- Flag, if enter effect should be performed.animation- The AnimationInfo.
-
isExploding
public boolean isExploding()
Checks, if this point is exploding.- Returns:
- true, if this points explosionCounter is greater 0.
-
isSwirling
public boolean isSwirling()
Checks, if this point is swirling.- Returns:
- true, if this point is swirling.
-
isBlueSwirling
public boolean isBlueSwirling()
Checks, if this point is blue swirling.- Returns:
- true, if this point is blue swirling.
-
swirlColors
public void swirlColors(int rounds, Thing source)Starts the swirling color effect for the given number of rounds.- Parameters:
rounds- The number of rounds the effect should last.source- The source.
-
swirlBlue
public void swirlBlue(int rounds, Thing source)Starts the swirling color effect for the given number of rounds.- Parameters:
rounds- The number of rounds the effect should last.source- The source.
-
stopSwirling
public void stopSwirling()
Stops the swirling color effect for this point.
-
explodeDelayed
public void explodeDelayed(int delay, int power, int radius, int rounds, Thing source)Lets the point explode after the given delay with the given explosion power for the given number of rounds with the given radius. Optionally, a currently blue point can take is blue level into account and explode even bigger. In this case, the color of the point will be switched from verydarkblue to darkblue, from darkblue to blue, from blue to lightblue, or to the specified color, if the point is lightblue.- Parameters:
delay- The number of rounds, the explosion will be delayedpower- The explosion power per roundradius- The explosion radius.rounds- The number of rounds the explosion will lastsource- The source.
-
getOccupant
public Thing getOccupant()
Returns this points opponent- Returns:
- The Thing on the point.
-
getFog
public Fog getFog()
Gets the fog on the point.- Returns:
- The fog.
-
setFog
public void setFog(Fog fog)
Sets the fog on this point.- Parameters:
fog- The new fog
-
setDotColor
public void setDotColor(int col)
Sets a color for a dot in the middle of the point. Set to null for no dot.- Parameters:
col- The color.
-
setColor
public void setColor(int newColor, Thing source, AnimationInfo animation)Sets the new color of the point. If the points color was already set in the same round, this method only has an effect, if the sources energy is higher than the former source. If the sources energy is the same, it is randomly chosen, if the coloring takes place. If the source is null, the energy is checked against 0.- Parameters:
newColor- The new color to set.source- The sourceanimation- The AnimationInfo
-
getExplosionPower
public int getExplosionPower()
Gets the explosion power of this point.- Returns:
- The explosion power or 0, if not exploding.
-
toString
public java.lang.String toString()
Returns a String represantation for this point containing this points coordinates- Overrides:
toStringin classjava.lang.Object- Returns:
- A String
-
toLongString
public java.lang.String toLongString()
Returns a String represantation for this point containing this points coordinates, occupant info etc.- Returns:
- A String
-
getDotColor
public int getDotColor()
Gets the color of a dot to display on the point.- Returns:
- The dot color
-
isTarget
public boolean isTarget()
Checks, if targetcross to display on the point.- Returns:
- true, if target cross should be draw
-
getExplosionCounter
public int getExplosionCounter()
Returns the explosion counter that indicates how many rounds this point will explode.- Returns:
- The explosion counter.
-
setExplosionCounter
public void setExplosionCounter(int explosionCounter)
Sets the explosion counter that indicates how many rounds this point will explode.- Parameters:
explosionCounter- The explosion counter.
-
getX
public int getX()
Gets the x coordinate of the point.- Returns:
- The x coordinate.
-
getY
public int getY()
Gets the y coordinate of the point.- Returns:
- The y coordinate.
-
getID
public int getID()
- Returns:
- the iD
-
setID
public void setID(int iD)
- Parameters:
iD- the iD to set
-
stopExplosion
public void stopExplosion()
Stops an explosion on the point.
-
getOldOccupant
public Thing getOldOccupant()
Gets the last occupant.- Returns:
- the oldOccupant
-
getField
public Field getField()
Gets the field this point belongs to.- Returns:
- The field.
-
isOccupied
public boolean isOccupied()
Checks, if the point is occupied.- Returns:
- true, if point is occupied by item or figure.
-
getHeater
public Thing getHeater()
Gets the thing that is responsible for the points heat.- Returns:
- The heater.
-
equals
public boolean equals(java.lang.Object o)
Checks, if the other Object is a thing with the same id.- Overrides:
equalsin classjava.lang.Object- Parameters:
o- The object to compare.- Returns:
- true, if o is a point with same id.
-
isRandomPoint
public boolean isRandomPoint()
Checks, if this is a randomly colored point.- Returns:
- true, random point.
-
hashCode
public int hashCode()
Returns the id.- Overrides:
hashCodein classjava.lang.Object
-
getNextID
public static int getNextID()
Gets the next possible ID for a figure. Calling this method is valid Integer.MAXINT times- Returns:
- a unique integer ID.
-
createState
public PointState createState(java.util.Map<java.lang.Integer,FigureState> figs, AnimationInfo animation)
Creates a state object for this point.- Parameters:
figs- The map of figure states.animation- The AnimationInfo.- Returns:
- The point state.
-
-