unc.cdva.interactiveitems
Class Gun

java.lang.Object
  extended by unc.cdva.utils.TaggedObject
      extended by unc.cdva.interactiveitems.InteractiveItem
          extended by unc.cdva.interactiveitems.AnimatedItem
              extended by unc.cdva.interactiveitems.Gun
All Implemented Interfaces:
Taggable

public class Gun
extends AnimatedItem

Gun object, essentially stores the state of a players gun. The state information is used when rendering the gun. There is some other data associated with a gun, for example the reload time, and data to specify where a projectile is to originate. NOTE: There are two id's to this class, a userId, and an id for the gun object.

Author:
Dan Van Atta, Guillaume Conte

Field Summary
 
Fields inherited from class unc.cdva.interactiveitems.InteractiveItem
direction, position, scaling
 
Constructor Summary
Gun(Id userId, PdsBean pds)
          Gun constructor, uses a default value for the muzzle height, the other two values needed by the gun object are passed in as parameters.
Gun(Id userId, PdsBean pds, javax.vecmath.Vector2f muzzleHeight)
          Gun constructor that initializes the internal state of the gun.
 
Method Summary
 void advanceInTime(long delta)
          If the gun is reloading, then the amount of time until it is done is decreased, if the gun has spent long enough reloading, then it is set back to the ready state.
 void fire()
          Toggles the fire state.
static javax.vecmath.Vector2f getMuzzleHeight()
           
 javax.vecmath.Vector3f getProjectileStartPos()
          Given the 2d muzzle height vector, calculates where the projectile should originate (the end of the muzzle)
static java.lang.Long getReloadTime()
           
 boolean isFiring()
          The gun is in the firing state when it is in the act of firing.
 boolean isReady()
          Indicates if in the ready state.
 boolean isReloading()
          The gun is in the reloading state for some amount of time after it has fired.
 void ready()
          Toggles the ready state.
 void reload()
          Toggles the ready state.
static void setMuzzleHeight(javax.vecmath.Vector2f muzzleHeight)
           
static void setReloadTime(long reloadTime)
           
 
Methods inherited from class unc.cdva.interactiveitems.InteractiveItem
getDirection, getPdsBean, getPosition, getScaling, getState, setDirection, setPds, setPosition, setScaling, setState
 
Methods inherited from class unc.cdva.utils.TaggedObject
createId, equals, getId, hashCode, setId, setId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Gun

public Gun(Id userId,
           PdsBean pds)
Gun constructor, uses a default value for the muzzle height, the other two values needed by the gun object are passed in as parameters.

Parameters:
userId - The id of the user who 'owns' teh gun.
pds - A pds for the placement of the gun object.

Gun

public Gun(Id userId,
           PdsBean pds,
           javax.vecmath.Vector2f muzzleHeight)
Gun constructor that initializes the internal state of the gun.

Parameters:
userId - The id of the player who 'owns' the gun.
pds - PDS bean, used for the gun placement.
muzzleHeight - A 2d vector repres
Method Detail

advanceInTime

public void advanceInTime(long delta)
If the gun is reloading, then the amount of time until it is done is decreased, if the gun has spent long enough reloading, then it is set back to the ready state.

Specified by:
advanceInTime in class AnimatedItem
Parameters:
delta - The amount of time to elapse.

getProjectileStartPos

public javax.vecmath.Vector3f getProjectileStartPos()
Given the 2d muzzle height vector, calculates where the projectile should originate (the end of the muzzle)

Returns:
A vector3f representing the start position of the projectile.

ready

public void ready()
Toggles the ready state.


fire

public void fire()
Toggles the fire state.


reload

public void reload()
Toggles the ready state.


isReady

public boolean isReady()
Indicates if in the ready state. If in the ready state, the gun is 'ready' to fire again.

Returns:
True if in the ready state.

isReloading

public boolean isReloading()
The gun is in the reloading state for some amount of time after it has fired. After being in the reloading state for a sufficient amount of time, it goes to the ready state.

Returns:
True if in the ready state.

isFiring

public boolean isFiring()
The gun is in the firing state when it is in the act of firing.

Returns:
True if in the firing state.

getMuzzleHeight

public static javax.vecmath.Vector2f getMuzzleHeight()
Returns:
the muzzleHeight of the gun

getReloadTime

public static java.lang.Long getReloadTime()
Returns:
Returns the reloadTime.

setMuzzleHeight

public static void setMuzzleHeight(javax.vecmath.Vector2f muzzleHeight)
Parameters:
muzzleHeight - The muzzleHeight to set.

setReloadTime

public static void setReloadTime(long reloadTime)
Parameters:
reloadTime - The reloadTime to set.