group1.model.gameobject.projectile
Class Contact

java.lang.Object
  extended by group1.model.gameobject.GameObj
      extended by group1.model.gameobject.projectile.Projectile
          extended by group1.model.gameobject.projectile.Contact

public class Contact
extends Projectile

A Contact is a strange type of Projectile. It is not really a projectile at all in the sense of the usual definition. Rather, it is attached to a host GameObj to give it damaging power simply by touching other damageable GameObj's.

Usage: to give a GameObj contact-damage power. Steps: (1) create an instance of Contact and attach it to a host GameObj, either in the constructor, or set later; (2) set this Contact's team to be the same as the host's team. Do it or else this Contact will fry the host!!!!! (3) set the attack power; (4) add this Contact to the host's Environment.


Field Summary
 
Fields inherited from class group1.model.gameobject.GameObj
acceleration, ENEMY_TEAM, GRID_SPACE_SIZE, id, isMovable, JEFF_TEAM, myState, NO_TEAM, regions, shape, THICKNESS, velocity
 
Constructor Summary
Contact()
          Default constructor: sets host object to null.
Contact(double x, double y, PictureList p)
          Standard factory constructor.
Contact(double x, double y, PictureList p, GameObj newHostObj)
          Standard factory constructor specifying host object.
Contact(GameObj newHostObj)
          Constructor specifying host object.
 
Method Summary
 char getDamageType()
          Returns a letter code indicating the type of damage that this Projectile gives.
 GameObj getHostObj()
          Get the current host object.
 XYPair move(Environment env)
          Movement function that should be called by the Environment at each time click.
 void setDirection(Direction newDirection)
          NOT AVAILABLE FOR CONTACT.
 void setHostObj(GameObj newHostObj)
          Set a new host object.
 void setSpeed(double newSpeed)
          NOT AVAILABLE FOR CONTACT.
 
Methods inherited from class group1.model.gameobject.projectile.Projectile
findObjRegion, getAttackPower, getBottomObjRegion, getDirection, getLeftObjRegion, getRightObjRegion, getSpeed, getTopObjRegion, getVelocityVector, setAttackPower, setProjectileTeam
 
Methods inherited from class group1.model.gameobject.GameObj
addRegion, addRegion, equals, getAcceleration, getAccelerationX, getAccelerationY, getFilm, getHeight, getID, getNumRegions, getPictureList, getPosition, getPositionX, getPositionY, getRectangle, getRegion, getState, getTeam, getVelocity, getVelocityX, getVelocityY, getWidth, giveDamage, intersectRegions, isMovable, isSameState, makeBottomSideRegion, makeLeftSideRegion, makeRegions, makeRightSideRegion, makeSolid, makeSolidTop, makeTopSideRegion, playAudio, resizeBottomRegion, resizeLeftRegion, resizeRightRegion, resizeTopRegion, setAcceleration, setAcceleration, setAccelerationX, setAccelerationY, setID, setPictureList, setPosition, setPosition, setPositionX, setPositionY, setRectangle, setSize, setState, setTeam, setVelocity, setVelocity, setVelocityX, setVelocityY, shouldBeBlinking, stopHorizontal, stopVertical
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Contact

public Contact()
Default constructor: sets host object to null.


Contact

public Contact(GameObj newHostObj)
Constructor specifying host object.


Contact

public Contact(double x,
               double y,
               PictureList p)
Standard factory constructor.


Contact

public Contact(double x,
               double y,
               PictureList p,
               GameObj newHostObj)
Standard factory constructor specifying host object.

Method Detail

getHostObj

public GameObj getHostObj()
Get the current host object.


setHostObj

public void setHostObj(GameObj newHostObj)
Set a new host object. This Contact will move to the position of the new host object.


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. Contact returns 'c'.

Overrides:
getDamageType in class Projectile

setDirection

public void setDirection(Direction newDirection)
NOT AVAILABLE FOR CONTACT. Direction is always Direction.NEITHER.

Overrides:
setDirection in class Projectile

setSpeed

public void setSpeed(double newSpeed)
NOT AVAILABLE FOR CONTACT. Speed is always 0.0.

Overrides:
setSpeed in class Projectile

move

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

Contact moves together with its host object.

Overrides:
move in class Projectile
Parameters:
env - The environment that this object is moving in.
Returns:
Guess of velocity.