unc.cdva.interactiveitems
Class Projectile

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.MobileItem
                  extended by unc.cdva.interactiveitems.Projectile
All Implemented Interfaces:
Taggable

public class Projectile
extends MobileItem

Represents a projectile. Maintains the state of the projectile, and information as to where the projectile lands, and what it will land on. The projectile will 'fly' via the advanceTime method which advances the position of the projectile. The way it works is as follows, when the projectile is initially created it will be in the looking for hit state. It is calculated then what the projectile will hit, either a target, pathway, or the background. It is then set to the appropriate exploding state. When the projectile finally actually travels to where it is supposed to land, it then goes into the exploding state, and explodes. NOTE: The id of the projectile will match the id of problem given in the constructor.

Author:
Guillaume Conte

Field Summary
 
Fields inherited from class unc.cdva.interactiveitems.MobileItem
MOVING, STOPPED
 
Fields inherited from class unc.cdva.interactiveitems.InteractiveItem
direction, position, scaling
 
Constructor Summary
Projectile(Gun gun, javax.vecmath.Vector3f landingPoint, Id problemId)
          Initializes a projectile object.
 
Method Summary
 void advanceInTime(long delta)
          Advances time for the projectile, it will move by a certain distance according to the given time interval.
 void explodeBackground()
          Sets the state of the projecitle to exploding over the background, change to this state as soon as it is known that the projectile will miss it's targets and is overshot missing even the pathway (river).
 void explodePathway()
          Sets the state of the projecitle to exploding over the pathway, change to this state as soon as it is known that the projectile will miss it's targets and will explode on the pathway.
 void explodeTarget()
          Sets the projectile to explode target, change to this state as soon as it is determined that the projectile will hit a target.
 void exploding()
          Sets the state of the projectile to exploding, ie the projectile has arrived to it's target and should then blow up.
 javax.vecmath.Vector3f getLandingPoint()
          Getter for the landing point.
 boolean isExplodeBackground()
           
 boolean isExplodePathway()
           
 boolean isExplodeTarget()
           
 boolean isExploding()
           
 boolean isLookingForHitSurface()
           
 void lookingForHitSurface()
          The very initial state of a projectile.
 void setLandingPoint(javax.vecmath.Vector3f landingPoint)
          Setter for the landing point, the projectile will explode when it reaches this point, the projectile will also be shot and travel from the gun to this point.
 
Methods inherited from class unc.cdva.interactiveitems.MobileItem
isMoving, isStopped, setMoving, setStopped
 
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

Projectile

public Projectile(Gun gun,
                  javax.vecmath.Vector3f landingPoint,
                  Id problemId)
Initializes a projectile object.

Parameters:
gun - The gun that is firing the object.
landingPoint - Where the object is to land.
problemId - The id of the problem that corresponds to the projectile. This id will be used to tag the projectile object. For every problem the user places a reticle, and clicks fire to fire the gun, placement of the reticle involves the creation of a problem whose id is used to tag everything associated with it, including the projectile.
Method Detail

advanceInTime

public void advanceInTime(long delta)
Advances time for the projectile, it will move by a certain distance according to the given time interval.

Specified by:
advanceInTime in class MobileItem
Parameters:
delta - the amount of time to elapse (in ms)

explodeTarget

public void explodeTarget()
Sets the projectile to explode target, change to this state as soon as it is determined that the projectile will hit a target.


explodePathway

public void explodePathway()
Sets the state of the projecitle to exploding over the pathway, change to this state as soon as it is known that the projectile will miss it's targets and will explode on the pathway.


explodeBackground

public void explodeBackground()
Sets the state of the projecitle to exploding over the background, change to this state as soon as it is known that the projectile will miss it's targets and is overshot missing even the pathway (river).


exploding

public void exploding()
Sets the state of the projectile to exploding, ie the projectile has arrived to it's target and should then blow up.


lookingForHitSurface

public void lookingForHitSurface()
The very initial state of a projectile.


isExplodeTarget

public boolean isExplodeTarget()
Returns:
True if the projectile is in the 'explode target' state, false otherwise.

isExplodePathway

public boolean isExplodePathway()
Returns:
True if the projectile is in the 'explode target' state, false otherwise.

isExplodeBackground

public boolean isExplodeBackground()
Returns:
True if the projectile is in the 'explode target' state, false otherwise.

isExploding

public boolean isExploding()
Returns:
True if the projectile is in the 'exploding' state, false otherwise.

isLookingForHitSurface

public boolean isLookingForHitSurface()
Returns:
True if the projectile is in the 'looking for hit surface' state, false otherwise.

setLandingPoint

public void setLandingPoint(javax.vecmath.Vector3f landingPoint)
Setter for the landing point, the projectile will explode when it reaches this point, the projectile will also be shot and travel from the gun to this point.

Parameters:
landingPoint - The landing point to set.

getLandingPoint

public javax.vecmath.Vector3f getLandingPoint()
Getter for the landing point.

Returns:
The point where the projectile will land.