robocode.naval
Class WeaponComponent

java.lang.Object
  extended by robocode.naval.ComponentBase
      extended by robocode.naval.WeaponComponent
All Implemented Interfaces:
Serializable, IComponent

public class WeaponComponent
extends ComponentBase

A class that resembles a weapon component for on a ship.

Since:
1.9.2.2
Version:
1.1
Author:
Thales B.V. / Jiri Waning / Thomas Hakkers
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class robocode.naval.ComponentBase
ComponentBase.HiddenComponentHelper
 
Field Summary
static double BLIND_SPOT_ANGLE
          The half and full blind arc angle for any weapon.
static double HALF_BLIND_SPOT_ANGLE
          The half and full blind arc angle for any weapon.
 
Fields inherited from class robocode.naval.ComponentBase
angle, lastHeading, type
 
Constructor Summary
WeaponComponent(double x, double y, ComponentType type)
          Creates a new weapon component for the ship.
WeaponComponent(double x, double y, ComponentType type, double start, double extent)
          Creates a new weapon component for the ship.
WeaponComponent(Point2D pivot, ComponentType type, double start, double extent)
          Creates a new weapon component for the ship.
 
Method Summary
 void coolDown(double coolingRate)
          Cool down the weapon.
 void fire(ITransformable peer)
          Deprecated. 
 boolean getAtBlindSpot()
           
 Color getBulletColor()
           
 BlindSpot getCopyOfBlindSpot()
           
 double getFireAngle(ITransformable peer)
          Get the angle towards which the bullet gets fired.
 double getFirePower()
          Get the fire power of the weapon.
 double getGunHeat()
          Get the gun heat.
 byte getSerializeType()
           
 double getTypeOffset()
          Get the angular offset in radians based upon the weapon type.
 void setAngle(double turnRemaining)
          Set the angle of the component; in radians.
 void setAngleDegrees(double angle)
          Set the angle of the component; in degrees.
 void setBulletColor(Color color)
           
 void setFirePower(double energy, double power)
          Set the fire power of the weapon.
 double turnRadians(double turnRemaining)
          Attempts to turn the component.
 void updateGunHeat(double gunHeat)
           
 
Methods inherited from class robocode.naval.ComponentBase
equals, getAngle, getAngleDegrees, getColor, getLastAngle, getOrigin, getPivot, getType, setColor, setLastAngle, setType, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BLIND_SPOT_ANGLE

public static final double BLIND_SPOT_ANGLE
The half and full blind arc angle for any weapon. These can be used to determine if a weapon is currently at the minimum/maximum allowed angle. (160° & 80°)

See Also:
Constant Field Values

HALF_BLIND_SPOT_ANGLE

public static final double HALF_BLIND_SPOT_ANGLE
The half and full blind arc angle for any weapon. These can be used to determine if a weapon is currently at the minimum/maximum allowed angle. (160° & 80°)

See Also:
Constant Field Values
Constructor Detail

WeaponComponent

public WeaponComponent(double x,
                       double y,
                       ComponentType type)
Creates a new weapon component for the ship.

When the arcSize is zero there will be no blind arc.

Parameters:
x - The X-coordinate of the pivot point of the component.
y - The Y-coordinate of the pivot point of the component.
type - The type of weapon component.

WeaponComponent

public WeaponComponent(double x,
                       double y,
                       ComponentType type,
                       double start,
                       double extent)
Creates a new weapon component for the ship.

When the arcSize is zero there will be no blind arc.

Parameters:
x - The X-coordinate of the pivot point of the component.
y - The Y-coordinate of the pivot point of the component.
type - The type of weapon component.
start - The starting angle (in degrees) of the blind arc.
extent - The size of the blind arc as an angle(in degrees) that the weapon can not cover. (Negative means to the left of the starting angle/positive means to the right.)

WeaponComponent

public WeaponComponent(Point2D pivot,
                       ComponentType type,
                       double start,
                       double extent)
Creates a new weapon component for the ship.

When the arcSize is zero there will be no blind arc.

Parameters:
pivot - The pivot point of the component.
type - The type of weapon component.
start - The starting angle (in degrees) of the blind arc.
extent - The size of the blind arc as an angle(in degrees) that the weapon can not cover. (Negative means to the left of the starting angle/positive means to the right.)
Method Detail

setFirePower

public void setFirePower(double energy,
                         double power)
Set the fire power of the weapon.

Parameters:
energy - The energy the robot has left.
power - The fire power of the weapon.

getFirePower

public double getFirePower()
Get the fire power of the weapon.

Returns:
The fire power of the weapon.

updateGunHeat

public void updateGunHeat(double gunHeat)

fire

@Deprecated
public void fire(ITransformable peer)
Deprecated. 

Fire the weapon.

Parameters:
peer - The owner of the weapon.

getGunHeat

public double getGunHeat()
Get the gun heat.

Specified by:
getGunHeat in interface IComponent
Overrides:
getGunHeat in class ComponentBase
Returns:
The heat value of this weapon.

coolDown

public void coolDown(double coolingRate)
Cool down the weapon. This is required to fire once more.

Parameters:
coolingRate - The rate at which to cool down the weapon.

getFireAngle

public double getFireAngle(ITransformable peer)
Get the angle towards which the bullet gets fired.

Parameters:
peer - The ship that fired the bullet.
Returns:
The angle towards which the bullet gets fired.

getCopyOfBlindSpot

public BlindSpot getCopyOfBlindSpot()

setBulletColor

public void setBulletColor(Color color)

getBulletColor

public Color getBulletColor()

getTypeOffset

public double getTypeOffset()
Get the angular offset in radians based upon the weapon type. THOMA_NOTE: Basically makes sure that back cannons are facing south and that front cannons are facing north. (Returns PI/2 for front cannon and 3PI/2 for back cannon)

Returns:
The angular offset in radians based upon the weapon type.

setAngle

public void setAngle(double turnRemaining)
Set the angle of the component; in radians.

Specified by:
setAngle in interface IComponent
Overrides:
setAngle in class ComponentBase
Parameters:
turnRemaining - The angle to which to set the component.

setAngleDegrees

public void setAngleDegrees(double angle)
Set the angle of the component; in degrees.

Specified by:
setAngleDegrees in interface IComponent
Overrides:
setAngleDegrees in class ComponentBase
Parameters:
angle - The angle to which to set the component.

getAtBlindSpot

public boolean getAtBlindSpot()

turnRadians

public double turnRadians(double turnRemaining)
Description copied from interface: IComponent
Attempts to turn the component.

Specified by:
turnRadians in interface IComponent
Specified by:
turnRadians in class ComponentBase
Parameters:
turnRemaining - The angle in RADIANS the component still has to turn.
Returns:
The turnRemaining after the turning has been done.

getSerializeType

public byte getSerializeType()
Specified by:
getSerializeType in interface IComponent
Overrides:
getSerializeType in class ComponentBase


Copyright © 2015 Robocode. All Rights Reserved.