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 voidBeginContact(CollisionInfo info)`unused`voidEndContact(CollisionInfo info)`unused`voidEnterTrigger(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 thingvoidExitTrigger(CollisionInfo info)if called on a Player against anything else call it on the other thingstatic floatgetAttackRange()FactiongetFaction()Added for Assessment 2intgetHealth()intgetPlunder()intgetPoints()com.badlogic.gdx.math.Vector2getPosition()floatgetValue(java.lang.String key)// New for assessment 2 // Get a Pirate value.booleanisAlive()voidplunder(int money)voidpoints(int increment)voidresetToDefault(java.lang.String key)// New for assessment 2 // Reset a Pirate value to what it originally was.voidsetFaction(int factionId)Associates ship with faction and orients it to the default northern direction.voidsetShipDirection(com.badlogic.gdx.math.Vector2 dir)will rotate the ship to face the direction (just changes the sprite doesn't actually rotate)voidsetShipDirection(java.lang.String direction)will rotate the ship to face the direction (just changes the sprite doesn't actually rotate)voidshoot()Calls shoot method with the current direction as parametervoidshoot(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:
EnterTriggerin interfaceCollisionCallBack
-
ExitTrigger
public void ExitTrigger(CollisionInfo info)
if called on a Player against anything else call it on the other thing- Specified by:
ExitTriggerin interfaceCollisionCallBack
-
BeginContact
public void BeginContact(CollisionInfo info)
`unused`- Specified by:
BeginContactin interfaceCollisionCallBack
-
EndContact
public void EndContact(CollisionInfo info)
`unused`- Specified by:
EndContactin interfaceCollisionCallBack
-
-