group1.model.gameobject
Class LivingObj

java.lang.Object
  extended by group1.model.gameobject.GameObj
      extended by group1.model.gameobject.LivingObj
Direct Known Subclasses:
Enemy, Jeff

public abstract class LivingObj
extends GameObj

A "living" game object, which has hp, can receive damage, and can die. (Use this class for enemies and for Jeff.)


Field Summary
protected  double contactDamageMultiplier
          The multiplier for weakness/resistance to direct contact damage.
protected  int curr_hp
          The current hit points.
protected  double fireDamageMultiplier
          The multiplier for weakness/resistance to fire damage.
protected  double katanaDamageMultiplier
          The multiplier for weakness/resistance to katana damage.
protected  double laserDamageMultiplier
          The multiplier for weakness/resistance to laser damage.
protected  int max_hp
          The maximum hit points.
protected  double tomahawkDamageMultiplier
          The multiplier for weakness/resistance to tomahawk damage.
static java.lang.String VALID_WEAPON_CODES
          List of all valid weapon codes, each a single character.
 
Fields inherited from class group1.model.gameobject.GameObj
acceleration, ENEMY_TEAM, GRID_SPACE_SIZE, id, isMovable, JEFF_TEAM, NO_TEAM, regions, shape, velocity
 
Constructor Summary
LivingObj()
          Default constructor.
LivingObj(double x, double y, double w, double h, boolean moves, int hitPoints, PictureList p)
          Constructor.
 
Method Summary
 void changeWeapon(char nextWeapon)
          Change the weapon to the specified one.
protected  void die()
          An overridable method that defines exactly what happens to a LivingObj when it dies.
 char getCurrentWeapon()
          Returns the letter code for the current weapon, or ' ' if not using a weapon right now.
 int getCurrHP()
          Get the current hit points.
 int getMaxHP()
          Get the maximum value for hit points.
 boolean hasFireball()
          Returns true if object has a fireball.
 boolean hasKatana()
          Returns true if object has a katana.
 boolean hasLaser()
          Returns true if object has a laser.
 boolean hasTomahawk()
          Returns true if object has a tomahawk.
 boolean hasWeapon(char weaponCode)
          Returns true if object currently has the specified weapon, else false.
 boolean hasWeaponIndex(int index)
          Returns true if object currently has the specified weapon, else false.
 boolean takeDamage(double damage, char damageType)
          Take damage, depleting hit points.
 
Methods inherited from class group1.model.gameobject.GameObj
addRegion, addRegion, equals, getAcceleration, getAccelerationX, getAccelerationY, getFilm, getFilm, getHeight, getID, getNumRegions, getPictureList, getPosition, getPositionX, getPositionY, getRectangle, getRegion, getState, getTeam, getVelocity, getVelocityX, getVelocityY, getWidth, intersectRegions, isMovable, isSameState, makeRegions, makeSolid, makeSolidTop, move, setAcceleration, setAcceleration, setAccelerationX, setAccelerationY, setID, setPictureList, setPosition, setPosition, setPositionX, setPositionY, setRectangle, setSize, setState, setTeam, setVelocity, setVelocity, setVelocityX, setVelocityY, stopHorizontal, stopVertical
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

curr_hp

protected int curr_hp
The current hit points.


max_hp

protected int max_hp
The maximum hit points.


fireDamageMultiplier

protected double fireDamageMultiplier
The multiplier for weakness/resistance to fire damage.


katanaDamageMultiplier

protected double katanaDamageMultiplier
The multiplier for weakness/resistance to katana damage.


tomahawkDamageMultiplier

protected double tomahawkDamageMultiplier
The multiplier for weakness/resistance to tomahawk damage.


laserDamageMultiplier

protected double laserDamageMultiplier
The multiplier for weakness/resistance to laser damage.


contactDamageMultiplier

protected double contactDamageMultiplier
The multiplier for weakness/resistance to direct contact damage.


VALID_WEAPON_CODES

public static final java.lang.String VALID_WEAPON_CODES
List of all valid weapon codes, each a single character. Currently 'k' for katana, 'f' for fireball, 'l' for laser, 't' for tomahawk, and ' ' for none.

See Also:
Constant Field Values
Constructor Detail

LivingObj

public LivingObj()
Default constructor.


LivingObj

public LivingObj(double x,
                 double y,
                 double w,
                 double h,
                 boolean moves,
                 int hitPoints,
                 PictureList p)
Constructor.

Parameters:
x - The x-position.
y - The y-position.
w - The width.
h - The height.
moves - Whether or not the object can move.
hitPoints - The max HP.
Method Detail

getCurrHP

public int getCurrHP()
Get the current hit points.

Returns:
The HP.

getMaxHP

public int getMaxHP()
Get the maximum value for hit points.

Returns:
The max HP.

getCurrentWeapon

public char getCurrentWeapon()
Returns the letter code for the current weapon, or ' ' if not using a weapon right now.


hasWeaponIndex

public boolean hasWeaponIndex(int index)
                       throws java.lang.IndexOutOfBoundsException
Returns true if object currently has the specified weapon, else false.

Parameters:
index - Index into VALID_WEAPON_CODES pointing to the weapon code in question.
Returns:
true if has specified weapon, else false.
Throws:
java.lang.IndexOutOfBoundsException - if (index < 0) or (index >= VALID_WEAPON_CODES.length()).

hasWeapon

public boolean hasWeapon(char weaponCode)
Returns true if object currently has the specified weapon, else false.

Parameters:
weaponCode - The letter code for the weapon in question.
Returns:
true if has specified weapon, else false. Also returns false on invalid weapon code. See documentation of VALID_WEAPON_CODES for list valid codes.

hasKatana

public boolean hasKatana()
Returns true if object has a katana.


hasFireball

public boolean hasFireball()
Returns true if object has a fireball.


hasLaser

public boolean hasLaser()
Returns true if object has a laser.


hasTomahawk

public boolean hasTomahawk()
Returns true if object has a tomahawk.


changeWeapon

public void changeWeapon(char nextWeapon)
Change the weapon to the specified one. Object must have the weapon first.

Parameters:
nextWeapon - The letter code for the next weapon, or ' ' for no weapon. See documentation of VALID_WEAPON_CODES for list valid codes.

takeDamage

public boolean takeDamage(double damage,
                          char damageType)
Take damage, depleting hit points. Damage might be affected by in-born weaknesses or resistances.

Parameters:
damage - The damage taken.
damageType - A value representing the kind of damage. 'f', 'k', 't', 'l', or 'c'.
Returns:
true if this object is now out of hit points.

die

protected void die()
An overridable method that defines exactly what happens to a LivingObj when it dies. (Like, does it fall off of the screen, or something?)

Default: Nothing in particular happens.