Class Tile

  • All Implemented Interfaces:
    Locatable

    public class Tile
    extends java.lang.Object
    implements Locatable
    • Constructor Summary

      Constructors 
      Constructor Description
      Tile()  
      Tile​(int x, int y)  
      Tile​(int x, int y, int z)  
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      Tile clone()  
      double distance()
      Gets the distance between the current Tile and your player.
      double distance​(Tile tile)
      Gets the distance between the current Tile and specified Tile
      double distance​(Entity entity)
      Gets the distance of the current Tile to the Entity
      boolean equals​(java.lang.Object obj)  
      Area getArea​(int radius)
      Creates a square area from this tile with a given radius.
      int getGridX()
      Gets grid (local) X coordinate of the given object.
      int getGridY()
      Gets grid (local) Y coordinate of the given object.
      java.awt.Polygon getPolygon()
      Gets the onscreen polygon for this tile
      Tile getRandomized()
      Gets a new instance of a random tile with a deviation of a guassian random with a mean of 2 and a sigma of 1
      Tile getRandomized​(int deviation)
      Gets a new instance of a random tile within a given deviation.
      Tile getRandomizedTile()
      Deprecated.
      Tile getRandomizedTile​(int deviation)
      Deprecated.
      Tile getTile()
      Gets tile of the object.
      TileReference getTileReference()
      Gets tile reference of the given object.
      int getX()
      Gets the X coordinate of the Tile
      int getY()
      Gets the Y coordinate of the Tile
      int getZ()
      Gets the Z coordinate of the tile
      int hashCode()  
      void setX​(int x)
      Sets the X coordinate for a Tile
      void setY​(int y)
      Sets the Y coordinate of the Tile
      void setZ​(int z)
      Sets the Z coordinate of the tile
      java.lang.String toString()  
      Tile translate​(int x, int y)
      Translates this Tile reference's location by the specified amount and returns itself
      Tile translate​(Tile tile)
      Translates this Tile's location by the specified amount and returns then this Tile with the updated location.
      double walkingDistance​(Tile tile)
      Walking distance based on pathfinding to the given tile.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Tile

        public Tile()
      • Tile

        public Tile​(int x,
                    int y)
      • Tile

        public Tile​(int x,
                    int y,
                    int z)
    • Method Detail

      • translate

        public Tile translate​(Tile tile)
        Translates this Tile's location by the specified amount and returns then this Tile with the updated location.
        Parameters:
        tile - the tile which to translate.
        Returns:
        this tile with the translated location.
      • translate

        public Tile translate​(int x,
                              int y)
        Translates this Tile reference's location by the specified amount and returns itself
        Parameters:
        x - x by which to translate.
        y - y by which to translate.
        Returns:
        this tile with the translated location.
      • getX

        public int getX()
        Gets the X coordinate of the Tile
        Specified by:
        getX in interface Locatable
        Returns:
        X coordinate of Tile
      • setX

        public void setX​(int x)
        Sets the X coordinate for a Tile
        Parameters:
        x - X coordinate
      • getY

        public int getY()
        Gets the Y coordinate of the Tile
        Specified by:
        getY in interface Locatable
        Returns:
        Y coordinate of the tile
      • setY

        public void setY​(int y)
        Sets the Y coordinate of the Tile
        Parameters:
        y - Y coordinate
      • getGridX

        public int getGridX()
        Description copied from interface: Locatable
        Gets grid (local) X coordinate of the given object.
        Specified by:
        getGridX in interface Locatable
        Returns:
        the grid X coordinate of the object.
      • getGridY

        public int getGridY()
        Description copied from interface: Locatable
        Gets grid (local) Y coordinate of the given object.
        Specified by:
        getGridY in interface Locatable
        Returns:
        the grid Y coordinate of the object.
      • getZ

        public int getZ()
        Gets the Z coordinate of the tile
        Specified by:
        getZ in interface Locatable
        Returns:
        Z coordinate
      • setZ

        public void setZ​(int z)
        Sets the Z coordinate of the tile
        Parameters:
        z - Z coordinate
      • getTileReference

        public TileReference getTileReference()
        Description copied from interface: Locatable
        Gets tile reference of the given object.
        Specified by:
        getTileReference in interface Locatable
        Returns:
        the object tile reference.
      • distance

        public double distance​(Entity entity)
        Gets the distance of the current Tile to the Entity
        Parameters:
        entity - Entity to check
        Returns:
        Distance between tile and entity, Integer.MAX_VALUE if the entity is null
      • clone

        public Tile clone()
      • getTile

        public Tile getTile()
        Description copied from interface: Locatable
        Gets tile of the object.
        Specified by:
        getTile in interface Locatable
        Returns:
        the object tile.
      • distance

        public double distance​(Tile tile)
        Gets the distance between the current Tile and specified Tile
        Specified by:
        distance in interface Locatable
        Parameters:
        tile - the tile to check distance from.
        Returns:
        from the given location.
      • walkingDistance

        public double walkingDistance​(Tile tile)
        Description copied from interface: Locatable
        Walking distance based on pathfinding to the given tile.

        This is a more expensive call than Locatable.distance(Tile), and should be used sparingly.

        Specified by:
        walkingDistance in interface Locatable
        Parameters:
        tile - the destination tile.
        Returns:
        return the path distance movement cost from the given tile as a double. If there isn't a path to the tile, it will return 3 times the as the crow flies distance.
      • getPolygon

        public java.awt.Polygon getPolygon()
        Gets the onscreen polygon for this tile
      • distance

        public double distance()
        Gets the distance between the current Tile and your player.
        Returns:
        from the given location.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • getRandomizedTile

        @Deprecated
        public Tile getRandomizedTile()
        Deprecated.
      • getRandomized

        public Tile getRandomized()
        Gets a new instance of a random tile with a deviation of a guassian random with a mean of 2 and a sigma of 1
      • getRandomizedTile

        @Deprecated
        public Tile getRandomizedTile​(int deviation)
        Deprecated.
      • getRandomized

        public Tile getRandomized​(int deviation)
        Gets a new instance of a random tile within a given deviation.
        Parameters:
        deviation -
        Returns:
      • getArea

        public Area getArea​(int radius)
        Creates a square area from this tile with a given radius.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object