Class Map


  • public class Map
    extends java.lang.Object
    A class which houses methods related to Region and Map.
    Since:
    11/22/14
    • Constructor Summary

      Constructors 
      Constructor Description
      Map()
      Deprecated.
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static void addObstacleActions​(java.lang.String... actions)
      Adds obstacle actions which will be used in getObstacleLocations() to determine which objects are obstacles.
      static boolean canReach​(Tile destination)
      Determines if the given destination tile is reachable from your current local players position, and not blocked by any objects/obstacles.
      static boolean canReach​(Tile destination, boolean offsetDestination)
      Determines if the given destination tile reachable from your current local players position, and not blocked by any objects/obstacles.
      static boolean canReach​(Tile start, Tile destination)
      Determines if the given destination tile reachable from the given start tile, and not blocked by any objects/obstacles.
      static boolean canReach​(Tile start, Tile destination, boolean offsetDestination)
      Determines if the given destination tile reachable from the given start tile, and not blocked by any objects/obstacles.
      static boolean canReach​(Entity destination)
      Determines if the given destination Entity is reachable from your current local players position, and not blocked by any objects/obstacles.
      static int costToTile​(int startX, int startY, int destinationX, int destinationY, boolean offsetDestination)  
      static int exactDistance​(Tile destination)
      Calculates the exact distance (number of tiles) your current player is away from destination.
      static int exactDistance​(Tile destination, boolean offsetDestination)
      Determines if the given destination tile reachable from your current local players position, and not blocked by any objects/obstacles.
      static int exactDistance​(Tile start, Tile destination)
      Determines if the given destination tile reachable from the given start tile, and not blocked by any objects/obstacles.
      static int exactDistance​(Tile start, Tile destination, boolean offsetDestination)
      Determines if the given destination tile reachable from the given start tile, and not blocked by any objects/obstacles.
      static int exactDistance​(Entity destination)
      Calculates the exact distance (number of tiles) your current player is away from destination.
      static java.awt.Rectangle getBounds​(Tile tile)
      Gets the on screen rectangle bounds of the given tile.
      static int getFlag​(Tile tile)
      Gets collision flag for the given tile.
      static Tile getGridLocation​(Tile tile)
      Gets the grid location of the tile.
      static int getGridX​(Tile tile)
      Gets the x location of a tile on the region grid.
      static int getGridY​(Tile tile)
      Gets the grid y value of a tile
      static Map getMap()
      Deprecated.
      static MiniMapTileDestination getMiniMapDestination​(Tile tile)
      Gets the mini map Destination for the given tile.
      static java.awt.Shape getMinimapShape()
      Gets a generated shape reference for the minimap widget.
      static GameObject[] getObjectsAtTile​(Tile tile)
      Gets the GameObjects at the given tile.
      static GameObject[] getObjectsAtTile​(Tile tile, boolean cachedResults)
      Gets the GameObjects at the given tile.
      static java.util.List<java.lang.String> getObstacleActions()
      Gets the list of obstacles actions which to use to find local obstacles.
      static java.util.HashMap<Tile,​TileObstacle> getObstacleLocations()
      Gets all local obstacles as determined by getObstacleActions().
      static java.awt.Polygon getPolygon​(Tile tile)
      Gets the on screen polygon of the given tile.
      static TileReference[][] getTileGrid​(int plane)
      Get the reference of the given tile object.
      static int getTileHeight​(Tile tile)
      Gets the height of a tile.
      static TileReference getTileReference​(Tile tile)
      Get the reference of the given tile object.
      static java.awt.Point[] getVertices​(Tile tile)
      Gets an array of points which represent the bounds of a tile.
      static Tile getWalkable​(Tile tile)
      Gets a walkable tile which is closest the given tile.
      static boolean interact​(Tile tile)
      Interacts with the given tile on the map by left clicking.
      static boolean interact​(Tile tile, java.lang.String action)
      Interacts with the given tile on the map using the given action.
      static boolean isLocal​(Tile tile)
      Determines if given tile is local.
      static boolean isTileOnMap​(Tile tile)
      Determines if the given tile is current visible on the mini map.
      static boolean isTileOnScreen​(Tile tile)
      Is tile on screen.
      static boolean isVisible​(Tile tile)
      Checks if the Tile is visible on the main screen.
      static void removeObstacleActions​(java.lang.String... actions)
      Removes obstacle actions which will be used in getObstacleLocations() to determine which objects are obstacles.
      static java.awt.Point tileToMiniMap​(Tile tile)
      Gets the given tile location on the mini map.
      static java.awt.Point tileToScreen​(Tile tile)
      Gets the current screen position of the given tile.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Map

        @Deprecated
        public Map()
        Deprecated.
    • Method Detail

      • getMap

        @Deprecated
        public static Map getMap()
        Deprecated.
      • isVisible

        public static boolean isVisible​(Tile tile)
        Checks if the Tile is visible on the main screen.
        Parameters:
        tile - to check visibly of.
        Returns:
        True if visible, else False
      • getWalkable

        public static Tile getWalkable​(Tile tile)
        Gets a walkable tile which is closest the given tile.
        Parameters:
        tile - the tile to find closest walkable tile for.
        Returns:
        the walkable tile, nearest to the given tile.
      • getTileReference

        public static TileReference getTileReference​(Tile tile)
        Get the reference of the given tile object.
        Parameters:
        tile - the tile you wish to get the reference for.
        Returns:
        the tile reference for the given object.
      • getTileGrid

        public static TileReference[][] getTileGrid​(int plane)
        Get the reference of the given tile object.
        Returns:
        the tile reference for the given object.
      • getMinimapShape

        public static java.awt.Shape getMinimapShape()
        Gets a generated shape reference for the minimap widget.
        Returns:
        the minimap shape object.
      • getTileHeight

        public static int getTileHeight​(Tile tile)
        Gets the height of a tile.
        Parameters:
        tile - the tile you wish to get the height of.
        Returns:
        height of the given tile.
      • getGridX

        public static int getGridX​(Tile tile)
        Gets the x location of a tile on the region grid.
        Parameters:
        tile - the tile to get the grid x position of.
        Returns:
        the x location of the tile on the region grid.
      • getGridY

        public static int getGridY​(Tile tile)
        Gets the grid y value of a tile
        Parameters:
        tile - the tile
        Returns:
        The grid y value.
      • getGridLocation

        public static Tile getGridLocation​(Tile tile)
        Gets the grid location of the tile.
        Parameters:
        tile - the tile you wish to get the grid position of.
        Returns:
        The grid location of the tile.
      • getVertices

        public static java.awt.Point[] getVertices​(Tile tile)
        Gets an array of points which represent the bounds of a tile.
        Parameters:
        tile - the tile you wish to get the points of.
        Returns:
        array of points which represent the bounds of the tile.
      • getBounds

        public static java.awt.Rectangle getBounds​(Tile tile)
        Gets the on screen rectangle bounds of the given tile.
        Parameters:
        tile - the tile you wish to get the bounds of.
        Returns:
        the rectangle bounds of the given tile.
      • getPolygon

        public static java.awt.Polygon getPolygon​(Tile tile)
        Gets the on screen polygon of the given tile.
        Parameters:
        tile - the tile you wish to get the polygon of.
        Returns:
        the polygon of the given tile.
      • isLocal

        public static boolean isLocal​(Tile tile)
        Determines if given tile is local.
        Parameters:
        tile - the tile to check.
        Returns:
        true if tile is local(in region), otherwise false.
      • getObjectsAtTile

        public static GameObject[] getObjectsAtTile​(Tile tile)
        Gets the GameObjects at the given tile.
        Parameters:
        tile - the tile to get the objects with.
        Returns:
        the array of GameObjects located at the given tile.
      • getObjectsAtTile

        public static GameObject[] getObjectsAtTile​(Tile tile,
                                                    boolean cachedResults)
        Gets the GameObjects at the given tile.
        Parameters:
        tile - the tile to get the objects with.
        cachedResults - true if you'd like to use the cache, false otherwise
        Returns:
        the array of GameObjects located at the given tile.
      • getMiniMapDestination

        public static MiniMapTileDestination getMiniMapDestination​(Tile tile)
        Gets the mini map Destination for the given tile.
        Parameters:
        tile - the tile to get the mini map destination of.
        Returns:
        the mini map destination for the given tile.
      • tileToMiniMap

        public static java.awt.Point tileToMiniMap​(Tile tile)
        Gets the given tile location on the mini map.
        Parameters:
        tile - the tile to get the mini map location of.
        Returns:
        the point of the tile location on the mini map.
      • tileToScreen

        public static java.awt.Point tileToScreen​(Tile tile)
        Gets the current screen position of the given tile.
        Parameters:
        tile - the tile to get the screen position from.
        Returns:
        the point of the tile location on the screen.
      • isTileOnMap

        public static boolean isTileOnMap​(Tile tile)
        Determines if the given tile is current visible on the mini map.
        Parameters:
        tile - the tile to check location of.
        Returns:
        False if on a different Z as your player, true if given tile is located on the mini map, otherwise false.
      • isTileOnScreen

        public static boolean isTileOnScreen​(Tile tile)
        Is tile on screen.
        Parameters:
        tile - the tile
        Returns:
        the boolean
      • getFlag

        public static int getFlag​(Tile tile)
        Gets collision flag for the given tile.
        Parameters:
        tile - the tile to get the collision flag for.
        Returns:
        the collision flag for the given tile.
      • interact

        public static boolean interact​(Tile tile)
        Interacts with the given tile on the map by left clicking.
        Parameters:
        tile - the tile tp interact with.
        Returns:
        true if successfully interacted, otherwise false.
      • interact

        public static boolean interact​(Tile tile,
                                       java.lang.String action)
        Interacts with the given tile on the map using the given action.
        Parameters:
        tile - the tile tp interact with.
        action - the action you wish to preform.
        Returns:
        true if successfully interacted, otherwise false.
      • canReach

        public static boolean canReach​(Entity destination)
        Determines if the given destination Entity is reachable from your current local players position, and not blocked by any objects/obstacles.
        Parameters:
        destination - the destination entity you want to determine reachable.
        Returns:
        true if your player is able to reach the destination, otherwise false.
      • canReach

        public static boolean canReach​(Tile destination)
        Determines if the given destination tile is reachable from your current local players position, and not blocked by any objects/obstacles.
        Parameters:
        destination - the destination tile you want to determine reachable.
        Returns:
        true if your player is able to reach the destination, otherwise false.
      • canReach

        public static boolean canReach​(Tile start,
                                       Tile destination)
        Determines if the given destination tile reachable from the given start tile, and not blocked by any objects/obstacles.
        Parameters:
        start - the tile you wish start your search from.
        destination - the destination tile you want to determine reachable.
        Returns:
        true if the destination tile is reachable from the start tile, otherwise false.
      • canReach

        public static boolean canReach​(Tile destination,
                                       boolean offsetDestination)
        Determines if the given destination tile reachable from your current local players position, and not blocked by any objects/obstacles.
        Parameters:
        destination - the destination tile you want to determine reachable.
        offsetDestination - if true, will search for any walkable surrounding tile in the event the destination is not walkable.
        Returns:
        true if your player is able to reach the destination, otherwise false.
      • canReach

        public static boolean canReach​(Tile start,
                                       Tile destination,
                                       boolean offsetDestination)
        Determines if the given destination tile reachable from the given start tile, and not blocked by any objects/obstacles.
        Parameters:
        start - the tile you wish start your search from.
        destination - the destination tile you want to determine reachable.
        offsetDestination - if true, will search for any walkable surrounding tile in the event the destination is not walkable.
        Returns:
        true if the destination tile is reachable from the start tile, otherwise false.
      • exactDistance

        public static int exactDistance​(Entity destination)
        Calculates the exact distance (number of tiles) your current player is away from destination. If the path is blocked the method will return -1.
        Parameters:
        destination - the destination entity you want to calculate tile distance of.
        Returns:
        the exact distance away (number of tiles) if your player is able to reach the destination, otherwise -1.
      • exactDistance

        public static int exactDistance​(Tile destination)
        Calculates the exact distance (number of tiles) your current player is away from destination.
        Parameters:
        destination - the destination entity you want to calculate tile distance of.
        Returns:
        the exact distance away (number of tiles) if your player is able to reach the destination, otherwise -1.
      • exactDistance

        public static int exactDistance​(Tile start,
                                        Tile destination)
        Determines if the given destination tile reachable from the given start tile, and not blocked by any objects/obstacles.
        Parameters:
        start - the tile you wish start your search from.
        destination - the destination entity you want to calculate tile distance of.
        Returns:
        the exact distance away (number of tiles) from the start tile if it is able to reach the destination, otherwise -1.
      • exactDistance

        public static int exactDistance​(Tile destination,
                                        boolean offsetDestination)
        Determines if the given destination tile reachable from your current local players position, and not blocked by any objects/obstacles.
        Parameters:
        destination - the destination entity you want to calculate tile distance of.
        offsetDestination - if true, will search for any walkable surrounding tile in the event the destination is not walkable.
        Returns:
        the exact distance away (number of tiles) from the start tile if it is able to reach the destination, otherwise -1.
      • exactDistance

        public static int exactDistance​(Tile start,
                                        Tile destination,
                                        boolean offsetDestination)
        Determines if the given destination tile reachable from the given start tile, and not blocked by any objects/obstacles.
        Parameters:
        start - the tile you wish start your search from.
        destination - the destination entity you want to calculate tile distance of.
        offsetDestination - if true, will search for any walkable surrounding tile in the event the destination is not walkable.
        Returns:
        the exact distance away (number of tiles) from the start tile if it is able to reach the destination, otherwise -1.
      • getObstacleActions

        public static java.util.List<java.lang.String> getObstacleActions()
        Gets the list of obstacles actions which to use to find local obstacles.
        Returns:
        the list of acceptable obstacle actions.
      • addObstacleActions

        public static void addObstacleActions​(java.lang.String... actions)
        Adds obstacle actions which will be used in getObstacleLocations() to determine which objects are obstacles.
        Parameters:
        actions - the actions you wish to add to the accepted actions list.
      • removeObstacleActions

        public static void removeObstacleActions​(java.lang.String... actions)
        Removes obstacle actions which will be used in getObstacleLocations() to determine which objects are obstacles.
        Parameters:
        actions - the actions you wish to remove from the accepted actions list.
      • costToTile

        public static int costToTile​(int startX,
                                     int startY,
                                     int destinationX,
                                     int destinationY,
                                     boolean offsetDestination)