Package com.mygdx.game.Entitys
Class Ship
- java.lang.Object
-
- com.mygdx.game.Entitys.Entity
-
- com.mygdx.game.Entitys.Ship
-
- All Implemented Interfaces:
CollisionCallBack
public class Ship extends Entity implements CollisionCallBack
Base class for game ships, Player & NPC.
-
-
Field Summary
Fields Modifier and Type Field Description static com.badlogic.gdx.utils.ObjectMap<com.badlogic.gdx.math.Vector2,java.lang.String>
shipDirections
-
Constructor Summary
Constructors Constructor Description Ship()
Creates a ship entity, containing Transform, Renderable, RigidBody, and Pirate components.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
BeginContact(CollisionInfo info)
`unused`void
EndContact(CollisionInfo info)
`unused`void
EnterTrigger(CollisionInfo info)
Amended for Assessment 2 (added functionality for when attacked by cannonball) if called on a Player against anything else call it on the other thingvoid
ExitTrigger(CollisionInfo info)
if called on a Player against anything else call it on the other thingstatic float
getAttackRange()
Faction
getFaction()
Added for Assessment 2int
getHealth()
int
getPlunder()
int
getPoints()
com.badlogic.gdx.math.Vector2
getPosition()
float
getValue(java.lang.String key)
// New for assessment 2 // Get a Pirate value.boolean
isAlive()
void
plunder(int money)
void
points(int increment)
void
resetToDefault(java.lang.String key)
// New for assessment 2 // Reset a Pirate value to what it originally was.void
setFaction(int factionId)
Associates ship with faction and orients it to the default northern direction.void
setShipDirection(com.badlogic.gdx.math.Vector2 dir)
will rotate the ship to face the direction (just changes the sprite doesn't actually rotate)void
setShipDirection(java.lang.String direction)
will rotate the ship to face the direction (just changes the sprite doesn't actually rotate)void
shoot()
Calls shoot method with the current direction as parametervoid
shoot(com.badlogic.gdx.math.Vector2 dir)
Calls shoot method of internal component-
Methods inherited from class com.mygdx.game.Entitys.Entity
addComponent, addComponents, cleanUp, dispose, getComponent, getComponent, getName, raiseEvents, setName, update
-
-
-
-
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
-
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
-
isAlive
public boolean isAlive()
- Returns:
- the boolean value of life attached to the Pirate Component
-
getAttackRange
public static float getAttackRange()
- Returns:
- the range at which this ship can attack
-
plunder
public void plunder(int money)
- Parameters:
money
- the integer to be added to the money value attached to the Pirate Component
-
points
public void points(int increment)
- Parameters:
increment
- the integer to be added to the points value attached to the Pirate Component
-
setFaction
public void setFaction(int factionId)
Associates ship with faction and orients it to the default northern direction.- Parameters:
factionId
- the desired faction id
-
setShipDirection
public void setShipDirection(com.badlogic.gdx.math.Vector2 dir)
will rotate the ship to face the direction (just changes the sprite doesn't actually rotate)- Parameters:
dir
- the dir to face (used to get the correct sprite from the texture atlas
-
setShipDirection
public void setShipDirection(java.lang.String direction)
will rotate the ship to face the direction (just changes the sprite doesn't actually rotate)- Parameters:
direction
- the dir to face (used to get the correct sprite from the texture atlas
-
getHealth
public int getHealth()
- Returns:
- the health attached to the Pirate Component
-
getPlunder
public int getPlunder()
- Returns:
- the plunder attached to the Pirate Component
-
getPoints
public int getPoints()
- Returns:
- the points attached to the Pirate Component
-
shoot
public void shoot()
Calls shoot method with the current direction as parameter
-
shoot
public void shoot(com.badlogic.gdx.math.Vector2 dir)
Calls shoot method of internal component
-
getPosition
public com.badlogic.gdx.math.Vector2 getPosition()
- Returns:
- copy of the transform's position
-
getFaction
public Faction getFaction()
Added for Assessment 2- Returns:
- The Faction of the Pirate Component attached to this entity
-
EnterTrigger
public void EnterTrigger(CollisionInfo info)
Amended for Assessment 2 (added functionality for when attacked by cannonball) if called on a Player against anything else call it on the other thing- Specified by:
EnterTrigger
in interfaceCollisionCallBack
-
ExitTrigger
public void ExitTrigger(CollisionInfo info)
if called on a Player against anything else call it on the other thing- Specified by:
ExitTrigger
in interfaceCollisionCallBack
-
BeginContact
public void BeginContact(CollisionInfo info)
`unused`- Specified by:
BeginContact
in interfaceCollisionCallBack
-
EndContact
public void EndContact(CollisionInfo info)
`unused`- Specified by:
EndContact
in interfaceCollisionCallBack
-
-