group1.model.gameobject.projectile
Class Projectile

java.lang.Object
  extended by group1.model.gameobject.GameObj
      extended by group1.model.gameobject.projectile.Projectile
Direct Known Subclasses:
Fireball, Katana, Laser, Tomahawk

public class Projectile
extends GameObj

A Projectile is a flying object that directly gives damage to another game object. Projectiles are emitted by Jeff or enemies as weapons.

Usage: construct the Projectile, then set its attack power, speed, and direction.


Field Summary
 
Fields inherited from class group1.model.gameobject.GameObj
acceleration, ENEMY_TEAM, GRID_SPACE_SIZE, id, isMovable, JEFF_TEAM, NO_TEAM, regions, shape, velocity
 
Constructor Summary
Projectile()
          Creates an idle Projectile.
 
Method Summary
 ObjRegion findObjRegion(int side)
          Finds an occurrence of an ObjRegion for this object that is on the specified side.
 double getAttackPower()
          Returns the attack power of the Projectile, which is the amount of damage that it gives to a GameObj that it hits.
 ObjRegion getBottomObjRegion()
          Returns the ObjRegion on the bottom side of the Projectile that gives damage.
 char getDamageType()
          Returns a letter code indicating the type of damage that this Projectile gives.
 Direction getDirection()
          Returns the horizontal direction of the Projectile.
 ObjRegion getLeftObjRegion()
          Returns the ObjRegion on the left side of the Projectile that gives damage.
 ObjRegion getRightObjRegion()
          Returns the ObjRegion on the right side of the Projectile that gives damage.
 double getSpeed()
          Returns the speed (magnitude of velocity) of the Projectile.
 ObjRegion getTopObjRegion()
          Returns the ObjRegion on the top side of the Projectile that gives damage.
 XYPair getVelocityVector()
          Gives the current velocity vector of the Projectile, based on its current speed and direction.
 XYPair move(Environment env)
          Movement function that should be called by the Environment at each time click.
 void setAttackPower(double newAttackPower)
          Sets this Projectile to give the specified amount of damage.
 void setDirection(Direction newDirection)
          Sets the horizontal direction of this Projectile.
 void setSpeed(double newSpeed)
          Sets the speed (magnitude of velocity) of this Projectile.
 
Methods inherited from class group1.model.gameobject.GameObj
addRegion, addRegion, equals, getAcceleration, getAccelerationX, getAccelerationY, getFilm, getFilm, getHeight, getID, getNumRegions, getPictureList, getPosition, getPositionX, getPositionY, getRectangle, getRegion, getState, getTeam, getVelocity, getVelocityX, getVelocityY, getWidth, intersectRegions, isMovable, isSameState, makeRegions, makeSolid, makeSolidTop, setAcceleration, setAcceleration, setAccelerationX, setAccelerationY, setID, setPictureList, setPosition, setPosition, setPositionX, setPositionY, setRectangle, setSize, setState, setTeam, setVelocity, setVelocity, setVelocityX, setVelocityY, stopHorizontal, stopVertical
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Projectile

public Projectile()
Creates an idle Projectile. Use the setters to tell it to start moving.

Method Detail

getDamageType

public char getDamageType()
Returns a letter code indicating the type of damage that this Projectile gives. This is a property of the specific subclass of Projectile. By default, Projectile (the superclass) returns ' ' for nothing.


getAttackPower

public double getAttackPower()
Returns the attack power of the Projectile, which is the amount of damage that it gives to a GameObj that it hits.


getDirection

public Direction getDirection()
Returns the horizontal direction of the Projectile.


getSpeed

public double getSpeed()
Returns the speed (magnitude of velocity) of the Projectile.


getLeftObjRegion

public ObjRegion getLeftObjRegion()
Returns the ObjRegion on the left side of the Projectile that gives damage.


getRightObjRegion

public ObjRegion getRightObjRegion()
Returns the ObjRegion on the right side of the Projectile that gives damage.


getTopObjRegion

public ObjRegion getTopObjRegion()
Returns the ObjRegion on the top side of the Projectile that gives damage.


getBottomObjRegion

public ObjRegion getBottomObjRegion()
Returns the ObjRegion on the bottom side of the Projectile that gives damage.


getVelocityVector

public XYPair getVelocityVector()
Gives the current velocity vector of the Projectile, based on its current speed and direction.


findObjRegion

public ObjRegion findObjRegion(int side)
Finds an occurrence of an ObjRegion for this object that is on the specified side.

Parameters:
side - Constant from ObjRegion denoting which side the ObjRegion is on.
Returns:
the first ObjRegion found that is on the specified side, or null if not found.

setAttackPower

public void setAttackPower(double newAttackPower)
Sets this Projectile to give the specified amount of damage. The ObjRegions will be updated to give this damage.


setDirection

public void setDirection(Direction newDirection)
Sets the horizontal direction of this Projectile.


setSpeed

public void setSpeed(double newSpeed)
Sets the speed (magnitude of velocity) of this Projectile. The value must be non-negative.


move

public XYPair move(Environment env)
Movement function that should be called by the Environment at each time click.

Specified by:
move in class GameObj
Parameters:
env - The environment that this object is moving in.
Returns:
Guess of velocity.