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)Called once a collision has being noticesvoidbiggerDamage(boolean state)voidEndContact(CollisionInfo info)Called after the collision has being solvedvoidEnterTrigger(CollisionInfo info)MAJOR ADDITIONS 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()booleangetFreeze()intgetHealth()intgetPlunder()com.badlogic.gdx.math.Vector2getPosition()booleanisAlive()voidplunder(int money)voidsetFaction(int factionId)Associates ship with faction and orients it to the default northern direction.voidsetFreeze(boolean state)voidsetHealth(int overrideHealth)voidsetPosition(java.lang.Float x, java.lang.Float y)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)voidShipDeath()voidshoot()voidshoot(com.badlogic.gdx.math.Vector2 dir)voidshoot8Directions(boolean state)voidtempImmortality(boolean state)voidunlimitedAmmo(boolean state)-
Methods inherited from class com.mygdx.game.Entitys.Entity
addComponent, addComponents, cleanUp, getComponent, getComponent, getComponents, getName, raiseEvents, setName, update
-
-
-
-
Method Detail
-
isAlive
public boolean isAlive()
-
getAttackRange
public static float getAttackRange()
-
plunder
public void plunder(int money)
-
setFaction
public void setFaction(int factionId)
Associates ship with faction and orients it to the default northern direction.- Parameters:
factionId- the desired faction id
-
setFreeze
public void setFreeze(boolean state)
-
getFreeze
public boolean getFreeze()
-
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()
-
setHealth
public void setHealth(int overrideHealth)
-
getPlunder
public int getPlunder()
-
shoot
public void shoot(com.badlogic.gdx.math.Vector2 dir)
-
shoot
public void shoot()
-
tempImmortality
public void tempImmortality(boolean state)
-
unlimitedAmmo
public void unlimitedAmmo(boolean state)
-
shoot8Directions
public void shoot8Directions(boolean state)
-
biggerDamage
public void biggerDamage(boolean state)
-
getPosition
public com.badlogic.gdx.math.Vector2 getPosition()
- Returns:
- copy of the transform's position
-
setPosition
public void setPosition(java.lang.Float x, java.lang.Float y)
-
BeginContact
public void BeginContact(CollisionInfo info)
Description copied from interface:CollisionCallBackCalled once a collision has being notices- Specified by:
BeginContactin interfaceCollisionCallBack
-
EndContact
public void EndContact(CollisionInfo info)
Description copied from interface:CollisionCallBackCalled after the collision has being solved- Specified by:
EndContactin interfaceCollisionCallBack
-
ShipDeath
public void ShipDeath()
-
EnterTrigger
public void EnterTrigger(CollisionInfo info)
MAJOR ADDITIONS 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
-
-