Package com.mygdx.game.Components
Class Pirate
- java.lang.Object
-
- com.mygdx.game.Components.Component
-
- com.mygdx.game.Components.Pirate
-
public class Pirate extends Component
Gives the concepts of health plunder, etc. Allows for firing of cannonballs, factions, death, targets
-
-
Constructor Summary
Constructors Constructor Description Pirate()
Creates the base Pirate Component, setting up its initial values
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPlunder(int money)
void
addPoints(int increment)
void
addTarget(Ship target)
boolean
canAttack()
if dst to target is less than attack range target will be null if not in aggro rangeint
getAmmo()
java.lang.Float
getAttackDmg()
Added for Assessment 2Faction
getFaction()
int
getHealth()
int
getPlunder()
int
getPoints()
Ship
getTarget()
QueueFIFO<Ship>
getTargets()
float
getValue(java.lang.String key)
// New for assessment 2 // Get a Pirate value.boolean
isAggro()
if dst to target is >= attack range target will be null if not in aggro rangeboolean
isAlive()
void
kill()
Kill its selfvoid
multValue(java.lang.String key, float mult)
// New for assessment 2 // Multiply a value for Pirate while holding reference to what it was originally.void
removeTarget()
void
resetToDefault(java.lang.String key)
// New for assessment 2 // Reset a Pirate value to what it originally was.void
setAmmo(int ammo)
void
setFactionId(int factionId)
void
setInfiniteAmmo(boolean status)
Added for Assessment 2, sets whether the pirate can ignore ammo costs for firingvoid
setValue(java.lang.String key, float value)
// New for assessment 2 // Set a new value for Pirate while holding reference to what it was originally.void
shoot(com.badlogic.gdx.math.Vector2 direction)
Changed for Assessment 2: - Removed functionality and replaced with function call to a different function, to allow for differentiation between when a start position is or isn't provided.void
shoot(com.badlogic.gdx.math.Vector2 startPos, com.badlogic.gdx.math.Vector2 direction)
Added for Assessment 2 Will shoot a cannonball from the startPos in the direction, assigning this.Parent as the cannonball's parentvoid
takeDamage(float dmg)
Deducts damage taken from Pirate's health and kills the pirate if that reduces health to less than or equal to 0
-
-
-
Method Detail
-
getValue
public float getValue(java.lang.String key)
// New for assessment 2 // Get a Pirate value.- Parameters:
key
- The value to get- Returns:
- The value
-
setValue
public void setValue(java.lang.String key, float value)
// New for assessment 2 // Set a new value for Pirate while holding reference to what it was originally.- Parameters:
key
- The value to set tovalue
- The float to apply
-
multValue
public void multValue(java.lang.String key, float mult)
// New for assessment 2 // Multiply a value for Pirate while holding reference to what it was originally.- Parameters:
key
- The value to multiplymult
- The multiplication factor
-
resetToDefault
public void resetToDefault(java.lang.String key)
// New for assessment 2 // Reset a Pirate value to what it originally was.- Parameters:
key
- The value to reset
-
addTarget
public void addTarget(Ship target)
- Parameters:
target
- The Ship to be added to the list of potential targets
-
getPlunder
public int getPlunder()
- Returns:
- the plunder value attached to this pirate
-
getPoints
public int getPoints()
- Returns:
- the points value attached to this pirate
-
addPlunder
public void addPlunder(int money)
- Parameters:
money
- The integer value to be added to the pirate's stored plunder amount
-
addPoints
public void addPoints(int increment)
- Parameters:
increment
- The integer value to be added to the pirate's stored point amount
-
getFaction
public Faction getFaction()
- Returns:
- the Faction value attached to this pirate
-
setFactionId
public void setFactionId(int factionId)
- Parameters:
factionId
- The ID of the faction to set this pirate to
-
setInfiniteAmmo
public void setInfiniteAmmo(boolean status)
Added for Assessment 2, sets whether the pirate can ignore ammo costs for firing- Parameters:
status
- boolean value to set infiniteAmmo to
-
getAttackDmg
public java.lang.Float getAttackDmg()
Added for Assessment 2- Returns:
- the damage dealt by attacks from this unit
-
takeDamage
public void takeDamage(float dmg)
Deducts damage taken from Pirate's health and kills the pirate if that reduces health to less than or equal to 0- Parameters:
dmg
- The float value to be removed from this pirate's health total
-
shoot
public void shoot(com.badlogic.gdx.math.Vector2 direction)
Changed for Assessment 2: - Removed functionality and replaced with function call to a different function, to allow for differentiation between when a start position is or isn't provided.- Parameters:
direction
- the direction to shoot in
-
shoot
public void shoot(com.badlogic.gdx.math.Vector2 startPos, com.badlogic.gdx.math.Vector2 direction)
Added for Assessment 2 Will shoot a cannonball from the startPos in the direction, assigning this.Parent as the cannonball's parent- Parameters:
direction
- the direction to shoot in
-
getHealth
public int getHealth()
- Returns:
- the health value attached to this pirate
-
canAttack
public boolean canAttack()
if dst to target is less than attack range target will be null if not in aggro range
-
isAggro
public boolean isAggro()
if dst to target is >= attack range target will be null if not in aggro range
-
getTarget
public Ship getTarget()
- Returns:
- the current target value attached to this pirate
-
isAlive
public boolean isAlive()
- Returns:
- the boolean alive value attached to this pirate
-
kill
public void kill()
Kill its self
-
setAmmo
public void setAmmo(int ammo)
- Parameters:
ammo
- The integer to be added to the amount of ammo this pirate has access to
-
getAmmo
public int getAmmo()
- Returns:
- the ammo value attached to this pirate
-
removeTarget
public void removeTarget()
-
-