|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--netwar.game.GameObject
|
+--netwar.game.Unit
Abstract class which defines a mobile GameObject.
This provides default implementation of the following behaviors:
Guard mode in which the Unit scans for nearby enemies.
Move mode in which the Unit tries to reach a particular Hex.
Pursuit mode in which the Unit moves toward a particular GameObject,
up to a range less than the weapon range, and fires repeatedly if that
GameObject is a damagable object which is not part of the same team.
Receiving damage using the standard health/armor model.
Navigating obstacles using a simple alternate direction system.
| Field Summary | |
protected int |
f
A code number indicating the direction that the Unit is facing |
protected int |
health
A value indicating the amount of damage still needed to destroy this Unit. |
protected boolean |
reserved
True if the Unit has a Hex reserved to move into. |
protected int |
resF
The facing this Unit should have when moving into the reserved Hex. |
protected int |
resX
X part of the Hex coord reserved for this Unit to move into another Hex. |
protected int |
resY
Y part of the Hex coord reserved for this Unit to move into another Hex. |
| Fields inherited from class netwar.game.GameObject |
action, firstSSMDS, frame, GameObjects, goalX, goalY, mode, myID, myPlayer, reload, target, targetSSMDS, vr, x, y |
| Constructor Summary | |
Unit()
|
|
| Method Summary | |
protected boolean |
aim()
Make applicable adjustments, then return true if the target is within the firing arc. |
protected abstract void |
animateMove()
Do the processing for a frame of animation while moving forward. |
protected abstract void |
animateRotateLeft()
Do the processing for a frame of animation while rotating left. |
protected abstract void |
animateRotateRight()
Do the processing for a frame of animation while rotating right. |
protected abstract int |
armor()
Returns the number of damage points to be ignored from each hit. |
protected int |
bestDirection(int gx,
int gy)
Returns the facing code for the 'best' direction to head. |
protected void |
confirmSubPlan(int gx,
int gy)
Checks to make sure that the idealized direction to get to the destination is still good. |
boolean |
damageable()
Return True if the Unit can be damaged. |
abstract int |
followRange()
Returns the number of Hexes to get within if in Pursuit Mode. |
protected abstract int |
framesToMove()
Returns the number of frames needed to move forward one hex. |
protected abstract int |
framesToRotate()
Returns the number of frames needed to rotate one hex-side. |
boolean |
isDead()
Return True iff the Unit is already destroyed. |
protected abstract int |
maxHealth()
Returns The maximum value of health for this Unit, which is the initial value for health. |
protected void |
param(int p)
Sets the facing of the Unit when it is created |
void |
recieveDamage(int dam)
Applies damage to this Unit, possibly destroying it. |
void |
setGoal()
Sets the unit to Guard Mode |
void |
setGoal(GameObject u)
Sets the Unit to Pursuit Mode |
void |
setGoal(int gx,
int gy)
Sets the unit to Move Mode |
protected void |
think()
Think about what to do. |
protected void |
update()
Called once per time-step to perform necessary processing. |
| Methods inherited from class netwar.game.GameObject |
animateDie, animateMake, center, createVectors, draw, fire, framesToDie, framesToMake, getHeight, getID, getMinimapColor, getObjectWithID, getPlayer, getWidth, locate, newGameObject, removeMe, scan, scanRangeSquared, updateAll, weaponDelay, weaponRangeSquared |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected int health
protected int f
protected int resX
protected int resY
protected int resF
protected boolean reserved
| Constructor Detail |
public Unit()
| Method Detail |
protected void param(int p)
param in class GameObjectpublic void setGoal()
setGoal in class GameObject
public void setGoal(int gx,
int gy)
setGoal in class GameObjectgx - The X part of the Hex coordinate to move to.gy - The Y part of the Hex coordinate to move to.public void setGoal(GameObject u)
setGoal in class GameObjectu - The GameObject to approach/pursue and attack (if not an ally).protected void update()
update in class GameObject
protected int bestDirection(int gx,
int gy)
gx - The x part of the destination hex coordinate.gy - The y part of the destination hex coordinate.
protected void confirmSubPlan(int gx,
int gy)
gx - The (updated) x part of the goal hex coordinate.gy - The (updated) y part of the goal hex coordinate.protected abstract int framesToMove()
protected abstract int framesToRotate()
protected abstract void animateMove()
protected abstract void animateRotateLeft()
protected abstract void animateRotateRight()
protected void think()
public abstract int followRange()
protected abstract int maxHealth()
protected abstract int armor()
public void recieveDamage(int dam)
recieveDamage in class GameObjectnetwar.game.GameObjectdam - The number of damage points to be inflicted.protected boolean aim()
aim in class GameObjectpublic boolean isDead()
isDead in class GameObjectpublic boolean damageable()
damageable in class GameObject
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||