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  Direction ourFacingDirection
          The direction in which the LivingObj is facing.
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, myState, NO_TEAM, regions, shape, THICKNESS, 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 changeDirectionFacing(Direction newDirection)
          Set the direction in which this LivingObj faces.
 void changeWeapon(char nextWeapon)
          Change the weapon to the specified one.
 boolean decrementInvincibilityCounter()
          Decrement the invincibility counter of this object.
protected  void die()
          An overridable method that defines exactly what happens to a LivingObj when it dies.
 Direction facingWhichDirection()
          The direction in which the LivingObj is facing.
 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 isInvincible()
          Return whether or not this living object is temporarily invincible.
protected  void setInvincibilityPeriod(long period)
          Set the amount of time this object should be invincible for.
 void setVulnerable()
          Make an object no longer invincible, assuming it already was.
 int 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, getHeight, getID, getNumRegions, getPictureList, getPosition, getPositionX, getPositionY, getRectangle, getRegion, getState, getTeam, getVelocity, getVelocityX, getVelocityY, getWidth, giveDamage, intersectRegions, isMovable, isSameState, makeBottomSideRegion, makeLeftSideRegion, makeRegions, makeRightSideRegion, makeSolid, makeSolidTop, makeTopSideRegion, move, playAudio, resizeBottomRegion, resizeLeftRegion, resizeRightRegion, resizeTopRegion, setAcceleration, setAcceleration, setAccelerationX, setAccelerationY, setID, setPictureList, setPosition, setPosition, setPositionX, setPositionY, setRectangle, setSize, setState, setTeam, setVelocity, setVelocity, setVelocityX, setVelocityY, shouldBeBlinking, 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

ourFacingDirection

protected Direction ourFacingDirection
The direction in which the LivingObj is facing. NEITHER means facing forward.

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.
p - The picture list.
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.


facingWhichDirection

public Direction facingWhichDirection()
The direction in which the LivingObj is facing. NEITHER means facing forward.


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.

changeDirectionFacing

public void changeDirectionFacing(Direction newDirection)
Set the direction in which this LivingObj faces.


setInvincibilityPeriod

protected void setInvincibilityPeriod(long period)
Set the amount of time this object should be invincible for.

Parameters:
period - The invincibility period.

takeDamage

public int 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:
The actual amount of damage taken.

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: Just remove this object from the Environment.


decrementInvincibilityCounter

public boolean decrementInvincibilityCounter()
Decrement the invincibility counter of this object.

Returns:
true if its invincibility has run out, false if not.

isInvincible

public boolean isInvincible()
Return whether or not this living object is temporarily invincible.

Returns:
If this object is currently temporarily invincible.

setVulnerable

public void setVulnerable()
Make an object no longer invincible, assuming it already was.