Package com.starpoints.game.item
Class ItemRocket
- java.lang.Object
-
- com.starpoints.game.Thing
-
- com.starpoints.game.Item
-
- com.starpoints.game.item.ItemRocket
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
- Direct Known Subclasses:
ItemBigBossRocket,ItemCleverRocket,ItemDropRocket,ItemDuckRocket,ItemFastRocket,ItemGrayRocket,ItemSwirlRocket,ItemVeryFastRocket
public class ItemRocket extends Item
Rocket item that moves slowly to the next figures point if used and detonates there.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanactiveState of the rocket (ACTIVE/INACTIVE)protected booleanDEBUGDebug flag.protected booleandetonatingFlag, if currently detonating.protected PointdropPointThe point on which the user fired the rocket.protected intexplosionDurationDuration of detonation.protected java.lang.StringloopNameThe name of the sound clip to loop as rocket warning.protected static intOFFSound constant for no sound.protected FigureownerOwner after being picked upprotected intspeedSpeed of the rocket.protected java.util.ArrayList<Point>targetLineThe line of points to the target.protected inttargetXTarget x position.protected inttargetYTarget y position.-
Fields inherited from class com.starpoints.game.Item
affectsBlue, category, DEFAULT_ITEM_PAINTERCLASS, dieReason, isBomb, isWeapon, pickupClip, pickupText, pointBonus, useClip, user
-
Fields inherited from class com.starpoints.game.Thing
energy, energyFx, energyMaxSoundPlayed, energyModifications, explosionCounter, game, imageName, innerColor, invulnCount, isAffectedByBlack, isAffectedByGray, level, MAX_TEXTPAINT, maxEnergy, nextID, outerColor, p, shieldCount, status, text
-
-
Constructor Summary
Constructors Constructor Description ItemRocket()Creates a new ItemRocket.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddStateProperties(ThingState state, AnimationInfo animation)Adds properties necessary for rocket painting.protected voidbeFired()Sets the state to ACTIVE, calls the fields rocketStarted-method, and starts the sound fx.voidcalculateTarget(int xpos, int ypos)Calculates the rocket target using the given start coordinates.voidcalculateTarget(int xpos, int ypos, boolean checkInvisibility, boolean checkECM)Determines the nearest target figure and calculates the target line.protected voidcalculateTargetLine()Calculates the points to move over when fired.voiddetonate(Point p, AnimationInfo animation)Detonates with a radius depending on the rockets energy.voiddie(Thing source, DieReason reason, AnimationInfo animation)Explodes, if INACTIVE, otherwise detonate.protected voiddoSpecialUpdate(AnimationInfo animation)Recalculates the target and target line.ItemCategorygetCategory()Returns the items category.intgetItemRating()Returns an item value for ComputerFigures rating in the items category.intgetMoveAnimationLength()Method that can be overwritten by moving item subclasses, in case move animation should not last for default of 3 update cycles.protected ThinggetNearestTarget(int xpos, int ypos, boolean checkInvisibility, boolean checkECM)Gets the nearest figure for target determinationprotected PointgetNextCalculatedPoint()Gets the first point of the target line.protected PointgetNextPoint(int xp, int yp)Gets the next point.protected FiguregetOwner()Returns this rockets owner.java.lang.StringgetPainterClassname()Gets the fully qualified classname of the Painter to use for this item (in 2D game).ItemgetRocketeer()Gets an ItemRocketeer, in case this figure is fired by one.intgetSpeed()Gets the speed of this rocket (nr of rounds between each move).intgetSpeedCount()Gets the current speed counter value.PointgetStartingPoint()Gets the starting point of this rocket.java.util.ArrayList<Point>getTargetLine()Gets the line of points this rocket will move.PointgetTargetPoint()Gets the target point.booleanhasTarget()Checks if this rocket has a target.booleanisActive()Checks, if the rocket is active.booleanisDetonating()Checks, if the rocket is currently detonprotected voidmoveToTarget(AnimationInfo animation)Moves to the target, in case the speedCounter has increased to the speed value.booleanonBePickedUp(Figure picker, AnimationInfo animation)If INACTIVE, normal picking up, if ACTIVE, picker dies, if he has no explosion shielding, otherwise the pickers energy is reduced by 2 times this rockets energy, divided by the rocket shielding.booleanonBeUsed(Figure user, AnimationInfo animation)Starts this rocket (if it is ok).voidonEnemyKilled(Figure enemy, int round, DieReason reason, AnimationInfo animation)Called, if the thing killed an enemy.booleanonHitItem(Item rammedItem, AnimationInfo animation)Method called if this item moves and hits another item.voidpaintUpdate()Increases the speed counter.protected voidperformFieldEffect(AnimationInfo animation)Moves to the target if active and speedcount is reached.voidsetActive(boolean active)Checks, if the rocket is active.voidsetDropPoint(Point p)Sets the drop pointvoidsetNasty(boolean nasty)Makes this rocket nasty (only targeting PlayerFigures).protected voidsetOwner(Figure owner)Sets the owner.voidsetRocketeer(Item rocketeer)Sets an ItemRocketeer, in case this figure is fired by one.voidsetSpeed(int speed)Sets the speed of this rocket (nr of rounds between each move).voidsetTarget(int x, int y)Sets the target point.protected voidstopClip()Stops the warning music.-
Methods inherited from class com.starpoints.game.Item
affectsBlue, bePickedUp, beUsed, bombPlaced, createState, entersColor, explodes, gainsEnergy, gainsPermanentItem, gainsSlots, getDieReason, getDrawText, getItemRating, getName, getPickUpClip, getPickupText, getPointBonus, getRamPower, getUseClip, getUser, heatChanges, is3DItem, isAffectedByColor, isAvailableInEditor, isBomb, isRammed, isRocketTarget, isStunned, isWeapon, killedEnemy, losesEnergy, losesItem, losesPermanentItem, lostPermanentItem, onBeforeDie, onBeHitByItem, onDrop, onLevelFinished, pickesUpBomb, pickesUpExplosive, pickesUpItem, pointsChange, pointSumChanges, removeAfterLevel, retrieveState, rocketStarted, setUser, startsHovering, staysOnColor, toString, updateExplodingStatus, updateThing, usesItem, visibilityChanges
-
Methods inherited from class com.starpoints.game.Thing
addEnergy, addShielding, clearTexts, displayText, displayText, entersColor, equals, getColor, getEnergy, getEnergyMaxCount, getExplosionCounter, getField, getGame, getID, getImageName, getInnerColor, getInvulnerableRounds, getLevel, getMaxEnergy, getNextID, getOuterColor, getPoint, getShadowColor, getShield, getStateObject, getStatus, getText, getTextColor, getTextPaintCount, getX, getY, hashCode, invulnerable, isAffectedByBlack, isAffectedByGray, isDestroyed, isExploding, isInvulnerable, isOK, isShowingEnergyFx, onExplode, removeEnergy, retrieveState, setEnergy, setEnergyMaxCount, setGame, setMaxEnergy, setPoint, setStatus, staysOnColor, stepText, updateEnergy
-
-
-
-
Field Detail
-
DEBUG
protected boolean DEBUG
Debug flag.
-
OFF
protected static int OFF
Sound constant for no sound.
-
explosionDuration
protected int explosionDuration
Duration of detonation.
-
active
protected boolean active
State of the rocket (ACTIVE/INACTIVE)
-
dropPoint
protected Point dropPoint
The point on which the user fired the rocket.
-
detonating
protected boolean detonating
Flag, if currently detonating.
-
targetX
protected int targetX
Target x position.
-
targetY
protected int targetY
Target y position.
-
targetLine
protected java.util.ArrayList<Point> targetLine
The line of points to the target.
-
speed
protected int speed
Speed of the rocket.
-
owner
protected Figure owner
Owner after being picked up
-
loopName
protected java.lang.String loopName
The name of the sound clip to loop as rocket warning.
-
-
Method Detail
-
getPainterClassname
public java.lang.String getPainterClassname()
Gets the fully qualified classname of the Painter to use for this item (in 2D game).- Overrides:
getPainterClassnamein classItem- Returns:
- "com.starpoints.painter.arena2D.PainterItemRocket"
-
getItemRating
public int getItemRating()
Returns an item value for ComputerFigures rating in the items category.- Overrides:
getItemRatingin classItem- Returns:
- energy * 12.
-
addStateProperties
protected void addStateProperties(ThingState state, AnimationInfo animation)
Adds properties necessary for rocket painting.- Overrides:
addStatePropertiesin classThing- Parameters:
state- The state to add properties to.animation- The current AnimationInfo.
-
getCategory
public ItemCategory getCategory()
Returns the items category.- Overrides:
getCategoryin classItem- Returns:
- the category
-
die
public void die(Thing source, DieReason reason, AnimationInfo animation)
Explodes, if INACTIVE, otherwise detonate.
-
getOwner
protected Figure getOwner()
Returns this rockets owner.- Returns:
- The owner.
-
setOwner
protected void setOwner(Figure owner)
Sets the owner.- Parameters:
owner- the owner to set
-
detonate
public void detonate(Point p, AnimationInfo animation)
Detonates with a radius depending on the rockets energy.- Parameters:
p- The detonation point.animation- The AnimationInfo.
-
stopClip
protected void stopClip()
Stops the warning music.
-
onEnemyKilled
public void onEnemyKilled(Figure enemy, int round, DieReason reason, AnimationInfo animation)
Called, if the thing killed an enemy.- Overrides:
onEnemyKilledin classItem- Parameters:
enemy- The killed enemy.round- The round count.reason- The reason.animation- The AnimationInfo.
-
onBePickedUp
public boolean onBePickedUp(Figure picker, AnimationInfo animation)
If INACTIVE, normal picking up, if ACTIVE, picker dies, if he has no explosion shielding, otherwise the pickers energy is reduced by 2 times this rockets energy, divided by the rocket shielding.- Overrides:
onBePickedUpin classItem- Parameters:
picker- The pickeranimation- The AnimationInfo.- Returns:
- true, if pickable, false otherwise.
-
onBeUsed
public boolean onBeUsed(Figure user, AnimationInfo animation)
Starts this rocket (if it is ok). Calculates the line (list of points) to the target, calls the rocketStarted()- method on the field, and inserts the warning sound loop.
-
beFired
protected void beFired()
Sets the state to ACTIVE, calls the fields rocketStarted-method, and starts the sound fx.
-
getTargetPoint
public Point getTargetPoint()
Gets the target point.- Returns:
- The target point.
-
performFieldEffect
protected void performFieldEffect(AnimationInfo animation)
Moves to the target if active and speedcount is reached.- Overrides:
performFieldEffectin classItem- Parameters:
animation- The AnimationInfo.
-
doSpecialUpdate
protected void doSpecialUpdate(AnimationInfo animation)
Recalculates the target and target line.- Overrides:
doSpecialUpdatein classItem- Parameters:
animation- The AnimationInfo.
-
paintUpdate
public void paintUpdate()
Increases the speed counter. Can be used for dummy rocket painting.
-
onHitItem
public boolean onHitItem(Item rammedItem, AnimationInfo animation)
Method called if this item moves and hits another item.
-
moveToTarget
protected void moveToTarget(AnimationInfo animation)
Moves to the target, in case the speedCounter has increased to the speed value.- Parameters:
animation- The AnimationInfo.
-
getNextPoint
protected Point getNextPoint(int xp, int yp)
Gets the next point.- Parameters:
xp- The last x position.yp- The last y position.- Returns:
- The next point.
-
setDropPoint
public void setDropPoint(Point p)
Sets the drop point- Parameters:
p- The point.
-
calculateTargetLine
protected void calculateTargetLine()
Calculates the points to move over when fired.
-
getStartingPoint
public Point getStartingPoint()
Gets the starting point of this rocket.- Returns:
- The point of the owner.
-
getTargetLine
public java.util.ArrayList<Point> getTargetLine()
Gets the line of points this rocket will move.- Returns:
- The target line.
-
calculateTarget
public void calculateTarget(int xpos, int ypos)Calculates the rocket target using the given start coordinates.- Parameters:
xpos- X position.ypos- Y position.
-
calculateTarget
public void calculateTarget(int xpos, int ypos, boolean checkInvisibility, boolean checkECM)Determines the nearest target figure and calculates the target line.- Parameters:
xpos- The xpos, the rocket is fired from.ypos- The ypos, the rocket is fired from.checkInvisibility- Flag, if invisible figures are no target.checkECM- Flag, if an ECM system prevents the figures from being the target.
-
getNearestTarget
protected Thing getNearestTarget(int xpos, int ypos, boolean checkInvisibility, boolean checkECM)
Gets the nearest figure for target determination- Parameters:
xpos- The current x posypos- The current y poscheckInvisibility- Flag, if invisible figures should be ignoredcheckECM- Flag, if figures with ECM system should be ignored.- Returns:
- The nearest possible target
-
hasTarget
public boolean hasTarget()
Checks if this rocket has a target.- Returns:
- true, if rocket has target.
-
isActive
public boolean isActive()
Checks, if the rocket is active.- Returns:
- state == ACTIVE
-
setActive
public void setActive(boolean active)
Checks, if the rocket is active.- Parameters:
active- The new state.
-
getNextCalculatedPoint
protected Point getNextCalculatedPoint()
Gets the first point of the target line.- Returns:
- The first point of the target line.
-
setTarget
public void setTarget(int x, int y)Sets the target point.- Parameters:
x- target x coordinatey- target y coordinate
-
getSpeedCount
public int getSpeedCount()
Gets the current speed counter value.- Returns:
- The current speed counter value.
-
getSpeed
public int getSpeed()
Gets the speed of this rocket (nr of rounds between each move).- Returns:
- The speed of this rocket.
-
setSpeed
public void setSpeed(int speed)
Sets the speed of this rocket (nr of rounds between each move).- Parameters:
speed- The new speed of this rocket.
-
isDetonating
public boolean isDetonating()
Checks, if the rocket is currently deton- Returns:
- true if detonating.
-
setNasty
public void setNasty(boolean nasty)
Makes this rocket nasty (only targeting PlayerFigures).- Parameters:
nasty- Flag, if rocket will be nasty or not.
-
getRocketeer
public Item getRocketeer()
Gets an ItemRocketeer, in case this figure is fired by one. Needed for targetline-calculation.- Returns:
- The rocketeer.
-
setRocketeer
public void setRocketeer(Item rocketeer)
Sets an ItemRocketeer, in case this figure is fired by one. Needed for targetline-calculation. Should be called by items, that generate rockets during game.- Parameters:
rocketeer- The rocketeer.
-
getMoveAnimationLength
public int getMoveAnimationLength()
Method that can be overwritten by moving item subclasses, in case move animation should not last for default of 3 update cycles.- Overrides:
getMoveAnimationLengthin classItem- Returns:
- 3 by default.
-
-