group1.model.gameobject.enemy
Class Enemy

java.lang.Object
  extended by group1.model.gameobject.GameObj
      extended by group1.model.gameobject.LivingObj
          extended by group1.model.gameobject.enemy.Enemy
Direct Known Subclasses:
ContactEnemy, Goomba

public class Enemy
extends LivingObj

Enemy is a living enemy in the game. Unlike Jeff, who moves based on user input, an Enemy moves based on its own personal desires determined by a random value generator.


Field Summary
 
Fields inherited from class group1.model.gameobject.LivingObj
contactDamageMultiplier, curr_hp, fireDamageMultiplier, katanaDamageMultiplier, laserDamageMultiplier, max_hp, ourFacingDirection, tomahawkDamageMultiplier, VALID_WEAPON_CODES
 
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
Enemy()
          Default constructor.
Enemy(double x, double y, double w, double h, int hp, PictureList p, boolean useStandardRegions, double attackPower)
          Constructor designed for greater control over enemy size and hp.
Enemy(double x, double y, PictureList p)
          Constructor.
 
Method Summary
 double attackPower()
          The default attack power.
 int attackProbabilityDenominator()
          The probability that this Enemy will attack at a particular time step is attackProbabilityNumerator() out of attackProbabilityDenominator().
 int attackProbabilityNumerator()
          The probability that this Enemy will attack at a particular time step is attackProbabilityNumerator() out of attackProbabilityDenominator().
 int changeWeaponProbabilityDenominator()
          The probability that this Enemy will change weapons at a particular time step is changeWeaponProbabilityNumerator() out of changeWeaponProbabilityDenominator().
 int changeWeaponProbabilityNumerator()
          The probability that this Enemy will change weapons at a particular time step is changeWeaponProbabilityNumerator() out of changeWeaponProbabilityDenominator().
protected  void die()
          An overridable method that defines exactly what happens to an Enemy when it dies.
 java.util.Random getRandomGenerator()
          Returns the random value generator that this Enemy is using.
protected  void makeStandardEnemyRegions(double attackPower)
          Create the object regions special for a standard enemy, such as a Goomba.
 double maxRunSpeed()
          The maximum running speed.
 double maxWalkSpeed()
          The maximum walking speed.
 XYPair move(Environment env)
          Movement function that should be called by the Environment at each time click.
 double projectileSpeed()
          The default speed of projectiles created by this Enemy.
 double runAcceleration()
          The acceleration while running.
protected  void setPointValue(int pointValue)
          Set the number of points this enemy is worth.
 void setRandomGenerator(java.util.Random newGenerator)
          Set this Enemy object to use another random value generator.
protected  boolean shouldBeMoving(Environment env)
          In the interest of not letting enemies run around on their own (and into pits, even), we might choose to only move an enemy if they've come within a set distance to Jeff.
static int startingHP()
          Enemy's starting maximum hit points.
 double walkAcceleration()
          The acceleration while walking.
 double walkSpeed()
          The default walk speed.
 
Methods inherited from class group1.model.gameobject.LivingObj
changeDirectionFacing, changeWeapon, decrementInvincibilityCounter, facingWhichDirection, getCurrentWeapon, getCurrHP, getMaxHP, hasFireball, hasKatana, hasLaser, hasTomahawk, hasWeapon, hasWeaponIndex, isInvincible, setInvincibilityPeriod, setVulnerable, takeDamage
 
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

Enemy

public Enemy(double x,
             double y,
             PictureList p)
Constructor.

Parameters:
x - The x-coordinate of the position.
y - The y-coordinate of the position.

Enemy

public Enemy(double x,
             double y,
             double w,
             double h,
             int hp,
             PictureList p,
             boolean useStandardRegions,
             double attackPower)
Constructor designed for greater control over enemy size and hp. Also allows for better ObjRegion definition. (I left the old one for the sake of not breaking Jeff C's code.)

Parameters:
x - The x-coordinate of the position.
y - The y-coordinate of the position.
w - The width of the enemy.
h - The height of the enemy.
hp - The max hp of the enemy.
p - The picture list.
useStandardRegions - Whether or not to use the "standard enemy" regions. (See makeStandardEnemyRegions method.)
attackPower - The attack power of the enemy. (May be null if the subclass is not using the standard regions.)

Enemy

public Enemy()
Default constructor.

Method Detail

startingHP

public static int startingHP()
Enemy's starting maximum hit points. The maximum number of hit points may change over the course of the game.


attackProbabilityNumerator

public int attackProbabilityNumerator()
The probability that this Enemy will attack at a particular time step is attackProbabilityNumerator() out of attackProbabilityDenominator().


attackProbabilityDenominator

public int attackProbabilityDenominator()
The probability that this Enemy will attack at a particular time step is attackProbabilityNumerator() out of attackProbabilityDenominator().


changeWeaponProbabilityNumerator

public int changeWeaponProbabilityNumerator()
The probability that this Enemy will change weapons at a particular time step is changeWeaponProbabilityNumerator() out of changeWeaponProbabilityDenominator().


changeWeaponProbabilityDenominator

public int changeWeaponProbabilityDenominator()
The probability that this Enemy will change weapons at a particular time step is changeWeaponProbabilityNumerator() out of changeWeaponProbabilityDenominator().


maxWalkSpeed

public double maxWalkSpeed()
The maximum walking speed.


maxRunSpeed

public double maxRunSpeed()
The maximum running speed.


walkAcceleration

public double walkAcceleration()
The acceleration while walking.


runAcceleration

public double runAcceleration()
The acceleration while running.


walkSpeed

public double walkSpeed()
The default walk speed. Can be either changed here or overridden.


attackPower

public double attackPower()
The default attack power. Can be either changed here or overridden.


projectileSpeed

public double projectileSpeed()
The default speed of projectiles created by this Enemy. Can be either changed here or overridden.


getRandomGenerator

public java.util.Random getRandomGenerator()
Returns the random value generator that this Enemy is using.


setRandomGenerator

public void setRandomGenerator(java.util.Random newGenerator)
Set this Enemy object to use another random value generator. For best results, construct ONE random value generator for the whole program and set ALL Enemy's to use it. But the default behavior of each Enemy using its own personal random generator also works.


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.

makeStandardEnemyRegions

protected void makeStandardEnemyRegions(double attackPower)
Create the object regions special for a standard enemy, such as a Goomba. The top region doesn't give damage. (Because Jeff can safely jump on enemies.) All other regions both take and give damage. Note, the individual enemies MUST do one of the following: 1.) Use the appropriate constructor parameters to use this method automatically. 2.) Call this function manually. 3.) Create their own regions.


shouldBeMoving

protected boolean shouldBeMoving(Environment env)
In the interest of not letting enemies run around on their own (and into pits, even), we might choose to only move an enemy if they've come within a set distance to Jeff. Such enemies can find out whether or not they should be moving from this method.

Parameters:
env - The environment the enemy and Jeff are in.
Returns:
Whether or not this enemy should be moving.

setPointValue

protected void setPointValue(int pointValue)
Set the number of points this enemy is worth.

Parameters:
pointValue - The amount of points gained for defeating this enemy.

die

protected void die()
An overridable method that defines exactly what happens to an Enemy when it dies.

Default: Whatever LivingObj.java specifies (should be just removing the object), and awarding the point value of this enemy to the player.

Overrides:
die in class LivingObj