Class Ship

    • 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.
    • Field Detail

      • shipDirections

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

      • Ship

        public Ship()
        Creates a ship entity, containing Transform, Renderable, RigidBody, and Pirate components.
    • 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 interface CollisionCallBack