|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavoids.Health
public class Health
Health.java is used to keep track of a sprite's duration and damage level.
Nested Class Summary | |
---|---|
static class |
Health.DurationType
sprite's duration/immortality type |
Field Summary | |
---|---|
private int |
agingRate
the amount that the sprite ages after each delay |
private int |
damage
the sprite's damage level |
private int |
deaths
the number of deaths the sprite has |
static int |
DEFAULT_AGING_RATE
standard rate that sprites decay (take it off duration of sprite after every delay) |
static int |
DEFAULT_DAMAGE_CAPACITY
standard damage capacity for a sprite |
static int |
DEFAULT_DEATHS
standard number of deaths for a sprite |
static int |
DEFAULT_DURATION
standard amount of "ticks" that a sprite can survive for (if not ageless and an aging rate of -1) |
private int |
duration
the sprite's duration time |
static int |
MAX_DEATHS
standard maximum number of deaths for any sprite (>= minimum number of deaths and <= 9) |
private int |
maxDamage
the sprite's maximum damage level |
private int |
maxDeaths
the maxmimum number of deaths the sprite has |
private int |
maxDuration
the sprite's maximum duration |
static int |
MIN_DEATHS
standard minimum number of deaths a sprite can have (>= 1 always) |
private static long |
serialVersionUID
This is the version used for serializing/deserializing (storing/retrieving) this object |
private Health.DurationType |
state
the state of the sprite's duration type |
Constructor Summary | |
---|---|
Health()
default constructor |
|
Health(Health health)
copy constructor |
|
Health(int _maxLives,
int _maxDamage,
int _maxDuration,
int _agingRate,
Health.DurationType _state)
constructor that accepts parameters for every value |
Method Summary | |
---|---|
void |
age()
Cause the object to age (reduces duration if it is not ageless) |
int |
getAgingRate()
return the aging rate of the sprite |
int |
getDamage()
return the hit points of the sprite |
int |
getDeaths()
return the number of deaths of the sprite |
int |
getDuration()
return the duration left for the sprite |
int |
getMaxDamage()
return the maximum hit points of the sprite |
int |
getMaxDeaths()
return the maximum number of deaths of the sprite |
int |
getMaxDuration()
return the maximum duration left for the sprite |
boolean |
isAgeless()
Is the object ageless (won't die from aging, but will from damage)? |
boolean |
isAlive()
Is the object alive? |
boolean |
isImmortal()
Is the object immortal (won't die from damage or aging)? |
boolean |
isRestorable()
|
int |
modifyDamage(int _damage)
Modify the number of hitpoints for an object if it is not immortal. |
int |
modifyDeaths(int _deaths)
Modify the number of deaths for an object if it is not immortal. |
int |
modifyDuration(int _duration)
Modify the amount of duration for an object if it is not ageless. |
void |
setAgingRate(int _agingRate)
Set the rate that the object decays (time it has left) before it is destroyed. |
void |
setDamage(int _damage)
Set the number of hitpoints for an object (the amount of damage it can take before a lfie is taken ). |
void |
setDeaths(int _deaths)
Set the number of deaths for an object (the number of times it may die). |
void |
setDuration(int _duration)
Set the amount of time that an object will survive. |
void |
setMaxDamage(int _maxDamage)
Set the maximum number of hitpoints an object may have (but doesn't necessarily have). |
void |
setMaxDeaths(int _maxLives)
Set the maximum number of deaths an object may have (but doesn't necessarily have). |
void |
setMaxDuration(int _maxDuration)
Set the maximum amount of tie the object will survive. |
void |
setState(Health.DurationType _state)
Set the state the object is in (NORMAL,AGELESS,IMMORTAL,IMMORTAL_AGELESS). |
java.lang.String |
toString()
Provide a String representation of this object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
public static int DEFAULT_AGING_RATE
public static int DEFAULT_DAMAGE_CAPACITY
public static int DEFAULT_DURATION
public static int DEFAULT_DEATHS
public static int MAX_DEATHS
public static int MIN_DEATHS
private int agingRate
private int damage
private int duration
private int deaths
private int maxDamage
private int maxDuration
private int maxDeaths
private Health.DurationType state
Constructor Detail |
---|
public Health()
public Health(Health health)
health
- the Health object to copypublic Health(int _maxLives, int _maxDamage, int _maxDuration, int _agingRate, Health.DurationType _state)
_maxLives
- the maximum number of deaths_maxDamage
- the maximum damage capactiy of the sprite_maxDuration
- the maximum number of time units "ticks" the object will survive_agingRate
- the rate that the sprite decays (the number of "ticks" used up after every delay)_state
- the state of the object (normal, ageless, immortal, etc)Method Detail |
---|
public void age()
public int getAgingRate()
public int getDamage()
public int getDuration()
public int getDeaths()
public int getMaxDamage()
public int getMaxDuration()
public int getMaxDeaths()
public boolean isAgeless()
public boolean isAlive()
public boolean isImmortal()
public boolean isRestorable()
public int modifyDamage(int _damage)
_damage
- the number of hitpoints to give an object (positive values grants hitpoints, negative values take hitpoints away).
public int modifyDuration(int _duration)
_duration
- the amount of duration to give an object (positive values grants duration, negative values take duration away).
public int modifyDeaths(int _deaths)
_deaths
- the number of deaths to give an object (positive values grants deaths, negative values take deaths away).
public void setAgingRate(int _agingRate)
_agingRate
- The rate that the object decays (time it has left) before it is destroyed.public void setDamage(int _damage)
_damage
- The number of hitpointslives the object will have (0 <= __damage <= maxDamage)public void setDuration(int _duration)
_duration
- The amount of time the object will survive the object will have (0 <= _duration <= maxDuration)public void setDeaths(int _deaths)
_deaths
- The number of deaths the object will have (0 <= _lives <= MAX_DEATHS)public void setMaxDamage(int _maxDamage)
_maxDamage
- The maximum number of hitpoints the object will have (_maxDamage >= 1)public void setMaxDuration(int _maxDuration)
_maxDuration
- The maximum amount of time the object will survive (_maxDuration >= 1)public void setMaxDeaths(int _maxLives)
_maxLives
- The maximum number of deaths the object will have (_maxLives >= MIN_DEATHS)public void setState(Health.DurationType _state)
_state
- The state the object is in.public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |