Class Ship

java.lang.Object
com.mygdx.game.Entitys.Entity
com.mygdx.game.Entitys.Ship
All Implemented Interfaces:
CollisionCallBack
Direct Known Subclasses:
NPCShip, Player

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

    Modifier and Type Method Description
    void BeginContact​(CollisionInfo info)
    Called once a collision has being notices
    void EndContact​(CollisionInfo info)
    Called after the collision has being solved
    void EnterTrigger​(CollisionInfo info)
    if called on a Player against anything else call it on the other thing
    void ExitTrigger​(CollisionInfo info)
    if called on a Player against anything else call it on the other thing
    static float getAttackRange()  
    int getHealth()  
    int getPlunder()  
    com.badlogic.gdx.math.Vector2 getPosition()  
    boolean isAlive()  
    void plunder​(int money)  
    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()  
    void shoot​(com.badlogic.gdx.math.Vector2 dir)  

    Methods inherited from class com.mygdx.game.Entitys.Entity

    addComponent, addComponents, cleanUp, getComponent, getComponent, getComponents, getName, raiseEvents, setName, update

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • shipDirections

      public static com.badlogic.gdx.utils.ObjectMap<com.badlogic.gdx.math.Vector2,​java.lang.String> shipDirections
  • Constructor Details

    • Ship

      public Ship()
      Creates a ship entity, containing Transform, Renderable, RigidBody, and Pirate components.
  • Method Details

    • 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
    • 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()
    • getPlunder

      public int getPlunder()
    • shoot

      public void shoot​(com.badlogic.gdx.math.Vector2 dir)
    • shoot

      public void shoot()
    • getPosition

      public com.badlogic.gdx.math.Vector2 getPosition()
      Returns:
      copy of the transform's position
    • BeginContact

      public void BeginContact​(CollisionInfo info)
      Description copied from interface: CollisionCallBack
      Called once a collision has being notices
      Specified by:
      BeginContact in interface CollisionCallBack
    • EndContact

      public void EndContact​(CollisionInfo info)
      Description copied from interface: CollisionCallBack
      Called after the collision has being solved
      Specified by:
      EndContact in interface CollisionCallBack
    • EnterTrigger

      public void EnterTrigger​(CollisionInfo info)
      if called on a Player against anything else call it on the other thing
      Specified by:
      EnterTrigger in interface CollisionCallBack
    • ExitTrigger

      public void ExitTrigger​(CollisionInfo info)
      if called on a Player against anything else call it on the other thing
      Specified by:
      ExitTrigger in interface CollisionCallBack