vooga.examples.networking.zombies.weapons
Class Weapon

java.lang.Object
  extended by vooga.examples.networking.zombies.weapons.Weapon
Direct Known Subclasses:
AssaultRifle, Pistol, ShotGun

public abstract class Weapon
extends java.lang.Object

Weapon class. Sets up the basic functions of a weapon and allows for customization in how a weapon produces bullets.


Constructor Summary
Weapon(Shooter shooter, int ammo)
           
Weapon(Shooter shooter, int ammo, int dmg, double speed, int delay)
           
 
Method Summary
 void addAmmo(int ammo)
          Add ammo.
 void fire()
          Checks if there's ammo left.
protected abstract  void fireBullets()
          Specifies how and how many bullets are created every time the weapon fires.
 int getAmmo()
          Get the remaining ammo.
 double getDamage()
          Get the weapon damage.
 double getOrientation()
          Get the orientation of the player/weapon
protected  void makeBullet(double angle)
          Creates a bullet whose orientation is specified by angle
 void setBulletSpeed(double speed)
          Set bullet speed
 void setDamage(int weaponDamage)
          Set weapon damage
 void setFiringDelay(int delay)
          Set firing delay
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Weapon

public Weapon(Shooter shooter,
              int ammo)

Weapon

public Weapon(Shooter shooter,
              int ammo,
              int dmg,
              double speed,
              int delay)
Method Detail

addAmmo

public void addAmmo(int ammo)
Add ammo. Used for bonuses

Parameters:
ammo - additional ammo

getAmmo

public int getAmmo()
Get the remaining ammo. Used for display

Returns:
number of remaining ammo

setDamage

public void setDamage(int weaponDamage)
Set weapon damage

Parameters:
weaponDamage -

setFiringDelay

public void setFiringDelay(int delay)
Set firing delay

Parameters:
delay -

setBulletSpeed

public void setBulletSpeed(double speed)
Set bullet speed

Parameters:
speed -

getOrientation

public double getOrientation()
Get the orientation of the player/weapon

Returns:
orientation of the player/weapon

getDamage

public double getDamage()
Get the weapon damage. Used for damage calculations in the game.

Returns:
weapon damage

fire

public void fire()
Checks if there's ammo left. If so, fire weapon and subtract from ammoCount


fireBullets

protected abstract void fireBullets()
Specifies how and how many bullets are created every time the weapon fires. To be overwritten in subclasses


makeBullet

protected void makeBullet(double angle)
Creates a bullet whose orientation is specified by angle

Parameters:
angle - orientation of the bullet to be created