javoids
Class PowerUp

java.lang.Object
  extended by javoids.BasicSprite
      extended by javoids.Sprite
          extended by javoids.ShieldedSprite
              extended by javoids.PowerUp
All Implemented Interfaces:
java.io.Serializable, Sizes

public final class PowerUp
extends ShieldedSprite

A sprite that grants Ship sprites special items, bonus points, or effects like repairing damage

Author:
mallette
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javoids.BasicSprite
BasicSprite.Collision, BasicSprite.Gravity
 
Field Summary
private static double CHANCE_HOMING
          the chance this sprite is homing
private static double CHANCE_ROTATE
          the chance this sprite will rotate
private static double CHANCE_SHIELDED
          the chance this sprite is shielded
private static int DEFAULT_POINTS
          The default number of points this is worth
protected static int DEFAULT_SIZE
          the sprite's default size
private  Health extraAlive
          extra health information
private  BasicSprite.Gravity extraGravity
          extra gravity related information
private  int extraGravityDuration
          extra gravity duration information (how long a gravity effect will last)
private  java.util.HashMap<Item.Type,Item> items
          a mapping of item names to items
protected static int MAX_NUMBER
          The maximum number of these sprites allowed in the game
protected static int MAX_SIZE
          the sprite's maximum size
protected static int MIN_SIZE
          the sprite's minimum size
private static double ROTATION
          the amount to rotate
private static long serialVersionUID
          This is the version used for serializing/deserializing (storing/retrieving) this object
 
Fields inherited from class javoids.BasicSprite
size
 
Constructor Summary
PowerUp(BasicSprite parent, Health health, Move move, int _size)
          Constructor
 
Method Summary
 int getDefaultSize()
           
 BasicSprite.Gravity getExtraGravity()
           
 int getExtraGravityDuration()
           
 Health getExtraHealth()
           
 ImageMap.Name getImageNumber()
           
 java.util.HashMap<Item.Type,Item> getItems()
           
 int getMaximumSize()
           
 int getMinimumSize()
           
 int modifyDamage(int _damage)
          modify the sprite's damage level
private  void modifyRandomAttribute()
          Change a random attribute like points or health information.
private  void modifyRandomItem()
          Pick an item this power up has and change a property of it (count, points, duration, etc).
private  void modifyRandomItems()
          Bbuild a powerup with raqndom effects and attributes to apply to a ship when the two collide.
 void setSize(int _size)
          set the sprite's size
 java.lang.String toString()
          Provide a String representation of this object.
 
Methods inherited from class javoids.ShieldedSprite
accelerate, collide, collisionDetected, draw, getMass, getShield, move, setDirection, setMove, setRotation, setShield, turn
 
Methods inherited from class javoids.Sprite
getAreas, getColors, getMultiplier, getOriginalImage, getShape, setAreas, setColors, setColors, setImage, setShape
 
Methods inherited from class javoids.BasicSprite
age, collisionDetected, expire, explode, getAgingRate, getAreaChecking, getColor, getDamage, getDeaths, getDirection, getDuration, getGravity, getHealth, getMaxDamage, getMaxDeaths, getMaxDuration, getMaxVelocity, getMove, getPacmanGame, getParent, getPoints, getRelativeVelocity, getRotation, getScreen, getSize, getX, getY, isAlive, isAutomaticMove, isDisplayAreas, isExploded, isGravitySource, isGravityWell, isHoming, isPlayer, isRestorable, kill, modifyDeaths, modifyDuration, modifyPoints, setAgingRate, setAreaChecking, setAutomaticMove, setDamage, setDeaths, setDisplayAreas, setDuration, setGravity, setHealth, setHoming, setMaxDamage, setMaxDuration, setMaxLives, setMaxVelocity, setPacmanGame, setParent, setPlayer, setPoints, setScreen, setX, setY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
This is the version used for serializing/deserializing (storing/retrieving) this object

See Also:
Constant Field Values

DEFAULT_POINTS

private static final int DEFAULT_POINTS
The default number of points this is worth

See Also:
Constant Field Values

MAX_NUMBER

protected static final int MAX_NUMBER
The maximum number of these sprites allowed in the game

See Also:
Constant Field Values

MAX_SIZE

protected static final int MAX_SIZE
the sprite's maximum size

See Also:
Constant Field Values

MIN_SIZE

protected static final int MIN_SIZE
the sprite's minimum size

See Also:
Constant Field Values

DEFAULT_SIZE

protected static final int DEFAULT_SIZE
the sprite's default size

See Also:
Constant Field Values

CHANCE_SHIELDED

private static final double CHANCE_SHIELDED
the chance this sprite is shielded

See Also:
Constant Field Values

CHANCE_HOMING

private static final double CHANCE_HOMING
the chance this sprite is homing

See Also:
Constant Field Values

CHANCE_ROTATE

private static final double CHANCE_ROTATE
the chance this sprite will rotate

See Also:
Constant Field Values

ROTATION

private static final double ROTATION
the amount to rotate

See Also:
Constant Field Values

items

private java.util.HashMap<Item.Type,Item> items
a mapping of item names to items


extraAlive

private Health extraAlive
extra health information


extraGravity

private BasicSprite.Gravity extraGravity
extra gravity related information


extraGravityDuration

private int extraGravityDuration
extra gravity duration information (how long a gravity effect will last)

Constructor Detail

PowerUp

public PowerUp(BasicSprite parent,
               Health health,
               Move move,
               int _size)
Constructor

Parameters:
parent - the parent of this sprite
health - the health information
move - the movment information
_size - the size this should be
Method Detail

getMaximumSize

public int getMaximumSize()
Returns:
the maximum size

getMinimumSize

public int getMinimumSize()
Returns:
the minimum size

getDefaultSize

public int getDefaultSize()
Returns:
the default size

setSize

public void setSize(int _size)
Description copied from class: BasicSprite
set the sprite's size

Overrides:
setSize in class Sprite
Parameters:
_size - the size to set the sprite's size to

getItems

public java.util.HashMap<Item.Type,Item> getItems()
Returns:
a hashmap of items (key=item type or name, value=item object)

getExtraHealth

public Health getExtraHealth()
Returns:
get any health related information that should be given to the capturing sprite

getExtraGravity

public BasicSprite.Gravity getExtraGravity()
Returns:
get any gravity related information that should be given to the capturing sprite

getExtraGravityDuration

public int getExtraGravityDuration()
Returns:
get any gravity duration related information that should be given to the capturing sprite (only limited durations)

modifyDamage

public int modifyDamage(int _damage)
Description copied from class: BasicSprite
modify the sprite's damage level

Overrides:
modifyDamage in class BasicSprite
Parameters:
_damage - the damage the sprite sustained
Returns:
the new damage level

modifyRandomItems

private void modifyRandomItems()
Bbuild a powerup with raqndom effects and attributes to apply to a ship when the two collide.


modifyRandomItem

private void modifyRandomItem()
Pick an item this power up has and change a property of it (count, points, duration, etc).


modifyRandomAttribute

private void modifyRandomAttribute()
Change a random attribute like points or health information.


getImageNumber

public ImageMap.Name getImageNumber()
Specified by:
getImageNumber in class Sprite
Returns:
the image name this sprite is using for drawing purposes

toString

public java.lang.String toString()
Provide a String representation of this object.

Overrides:
toString in class ShieldedSprite
Returns:
String A representation of the object for debugging.