netwar.game
Class Base

java.lang.Object
  |
  +--netwar.game.GameObject
        |
        +--netwar.game.Base
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public class Base
extends GameObject
implements java.awt.event.ActionListener

Large immobile GameObject which creates Units. This object occupies seven hexes, is immobile, and has no weapon. The official victory conditions state that losing your Base means you lose the game, last player with a Base wins. Implementation of that victory condition are being delayed during this phase of development/testing.

Author:
Group N2 - Project Netwar, Daniel Grund

Fields inherited from class netwar.game.GameObject
action, firstSSMDS, frame, GameObjects, goalX, goalY, mode, myID, myPlayer, reload, target, targetSSMDS, vr, x, y
 
Constructor Summary
Base(int X, int Y)
          Reserves the region occupied by the base.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent actionEvent)
          SCHEDULED TO BE REMOVED
This is currently used to catch button presses which cause the creation of new Units.
protected  boolean aim()
          Makes adjustments if possible (for independent turrets) and returns true if the current target is within the firing arc (though it may be out of range to fire).
protected  void animateDie()
          Performs the calculations for one frame of animation during the death sequence.
protected  void animateMake()
          Perform the data changes for one frame of animation while being made.
protected  void createVectors()
          Initialize the Point3Ds used for this Base.
 boolean damageable()
          Return true if an explosion can possibly damage this object.
 void draw(GameViewer v)
          Draw this Base onto GameViewer v, by using v's drawing methods.
protected  int framesToDie()
          Returns the number of frames of animation for the death sequence.
protected  int framesToMake()
          Return the number of frames of animation for creation animation.
 float getHeight()
          Return the height of this Base for selection box and explosion hit calculations.
 float getWidth()
          Return the width of this Base for selection box and explosion hit calculations.
 boolean isDead()
          Return true if the object is not a valid target for attacks nor following.
 void recieveDamage(int dam)
          Apply damage to this object.
 void setGoal()
          Clear the current long-term goal.
 void setGoal(GameObject u)
          Set the current long-term goal to a GameObject.
 void setGoal(int gx, int gy)
          Set the current long-term goal to a location, at hex coordinate (gx, gy).
 void spawnUnit(int uNumber)
          If the base is not already trying to make a Unit, this will cause it to begin attempting to make a unit.
protected  void update()
          Perform operations for this time step.
 int weaponDelay()
          Return the number of frames to wait between firing shots.
 float weaponRangeSquared()
          Return the square of the maximum weapon range of this GameObject.
 
Methods inherited from class netwar.game.GameObject
center, fire, getID, getMinimapColor, getObjectWithID, getPlayer, locate, newGameObject, param, removeMe, scan, scanRangeSquared, updateAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base

public Base(int X,
            int Y)
Reserves the region occupied by the base. The hex coordinates passed, (X,Y), are the bottom center hex of the 7-hex region occupied by the base.
Method Detail

spawnUnit

public void spawnUnit(int uNumber)
If the base is not already trying to make a Unit, this will cause it to begin attempting to make a unit. A Unit currently takes one frame of the Base's time to make, unless the Base has no available locations to build the Unit.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent actionEvent)
SCHEDULED TO BE REMOVED
This is currently used to catch button presses which cause the creation of new Units. That function is being moved to netwar.gui.NetwarPanel, which will have its own buttons.
Specified by:
actionPerformed in interface java.awt.event.ActionListener

update

protected void update()
Perform operations for this time step. Specifically, perform the Point3D transforms for any/all animations, and attempt to make a unit if a unit creation was requested.
Overrides:
update in class GameObject

createVectors

protected void createVectors()
Initialize the Point3Ds used for this Base. These are the location of the ground-center of the Base in game-space, and the relative locations of the triangle/line vertices relative to that point.
Overrides:
createVectors in class GameObject

draw

public void draw(GameViewer v)
Draw this Base onto GameViewer v, by using v's drawing methods.
Overrides:
draw in class GameObject
Following copied from class: netwar.game.GameObject
Parameters:
v - The GameViewer which will display this GameObject.
See Also:
HexViewer

getHeight

public float getHeight()
Return the height of this Base for selection box and explosion hit calculations.
Overrides:
getHeight in class GameObject
Returns:
The height of the Base in game-space units.

getWidth

public float getWidth()
Return the width of this Base for selection box and explosion hit calculations.
Overrides:
getWidth in class GameObject
Returns:
The width of the Base in game-space units.

framesToMake

protected int framesToMake()
Return the number of frames of animation for creation animation. The Base is pre-built before the game, so no creation animation.
Overrides:
framesToMake in class GameObject
Returns:
The number of frames of game-time needed to animate creation.

animateMake

protected void animateMake()
Perform the data changes for one frame of animation while being made. The Base is pre-built before the game, so this method does nothing.
Overrides:
animateMake in class GameObject

weaponRangeSquared

public float weaponRangeSquared()
Return the square of the maximum weapon range of this GameObject. Since the base has no weapons, it returns 0.
Overrides:
weaponRangeSquared in class GameObject
Returns:
The square of the weapons range in game-space units.

weaponDelay

public int weaponDelay()
Return the number of frames to wait between firing shots. Since the base has no weapons, it returns 0.
Overrides:
weaponDelay in class GameObject

setGoal

public void setGoal()
Clear the current long-term goal. Since the base is immobile, it doesn't use the goal system.
Overrides:
setGoal in class GameObject

setGoal

public void setGoal(int gx,
                    int gy)
Set the current long-term goal to a location, at hex coordinate (gx, gy). Since the base is immobile, it doesn't use the goal system.
Overrides:
setGoal in class GameObject
Parameters:
gx - The x coordinate of the goal, in hex coords.
gy - The y coordinate of the goal, in hex coords.

setGoal

public void setGoal(GameObject u)
Set the current long-term goal to a GameObject. Since the base is immobile, it doesn't use the goal system.
Overrides:
setGoal in class GameObject
Parameters:
u - The GameObject which is the goal.

aim

protected boolean aim()
Makes adjustments if possible (for independent turrets) and returns true if the current target is within the firing arc (though it may be out of range to fire). For the Base, it returns false, because there is no weapon.
Overrides:
aim in class GameObject
Returns:
True iff the target is within the firing arc.

animateDie

protected void animateDie()
Performs the calculations for one frame of animation during the death sequence.
Overrides:
animateDie in class GameObject

framesToDie

protected int framesToDie()
Returns the number of frames of animation for the death sequence.
Overrides:
framesToDie in class GameObject
Returns:
The number of frames needed to animate death.

isDead

public boolean isDead()
Return true if the object is not a valid target for attacks nor following. This is always true for indestructable obstacles. Otherwise, it is true only when the Unit/obstacle is destroyed. This is necessary to allow a GameObject to become completely dereferenced.
Overrides:
isDead in class GameObject
Returns:
True iff the unit is destroyed or it is both immobile and indestructable.

damageable

public boolean damageable()
Return true if an explosion can possibly damage this object.
Overrides:
damageable in class GameObject
Returns:
True iff the object is damageable.

recieveDamage

public void recieveDamage(int dam)
Apply damage to this object. A GameObject can apply its own rules for taking damage. The 'standard' is to track a health integer, which is reduced by (dam - armor) for each hit, with a minimum loss of 1 per hit.
Overrides:
recieveDamage in class GameObject
Parameters:
dam - The number of damage points to be inflicted.