com.b3dgs.lionengine.game.map
Class AbstractPathMap<TTile extends AbstractPathTile>

java.lang.Object
  extended by com.b3dgs.lionengine.game.map.AbstractTileMap<TTile>
      extended by com.b3dgs.lionengine.game.map.AbstractPathMap<TTile>
Type Parameters:
TTile - tile type used.
All Implemented Interfaces:
PathBasedMap<TTile>, TileBasedMap<TTile>

public abstract class AbstractPathMap<TTile extends AbstractPathTile>
extends AbstractTileMap<TTile>
implements PathBasedMap<TTile>

Abstract representation of a path based map, used for pathfinding.


Field Summary
 
Fields inherited from class com.b3dgs.lionengine.game.map.AbstractTileMap
heightInTile, screenHeight, theme, tileHeight, tilesDir, tileWidth, widthInTile
 
Constructor Summary
AbstractPathMap(java.lang.String tilesDir, int tileWidth, int tileHeight, int screenHeight)
          Create a new path map.
 
Method Summary
 boolean blocked(Pathfindable mover, int v, int h, boolean ignoreRef)
          Check if current location is blocking or not.
 boolean checkFreePlace(int tx, int ty, int w, int h, int id)
          Check if area if unused.
 void create(int widthInTile, int heightInTile)
          Create and prepare map memory area.
 void createMiniMap()
          Generate the minimap from the current map.
 java.awt.Graphics2D createMiniMapGraphics()
          Get minimap graphics reference.
 java.util.List<Point2D> getAllFreePlaceArround(int tx, int ty, int w, int h, int id, int radius)
          Search list of free area from this area.
 float getCost(Pathfindable mover, int sx, int sy, int tx, int ty)
          Get the cost of the complete path, from start till end.
 Point2D getFreePlaceArround(int tx, int ty, int w, int h, int id, int radius)
          Search a free area from this area.
 int getRef(int v, int h)
          Get ref id.
 TTile getTileArround(Pathfindable mover, int v, int h, int width, int height)
          Search the first unblocking tile arround location (clock way).
 void load(XMLNode root)
          Load a map from a specified file as xml.
 void pathFinderVisited(int v, int h)
          Mark the tile as visited.
 void render(java.awt.Graphics2D g, Camera camera, int inTileWidth, int inTileHeight)
          Deprecated. use render(Graphics2D g, StrategyCamera camera, int inTileWidth, int inTileHeight) instead.
 void render(java.awt.Graphics2D g, StrategyCamera camera, int inTileWidth, int inTileHeight)
          Render map from camera viewpoint, showing a specified area.
 void renderMiniMap(java.awt.Graphics2D g, int x, int y)
          Render minimap on graphic output at specified location.
protected  void renderTile(java.awt.Graphics2D g, TTile tile, int x, int y, int tx, int ty)
          Render a specific tile from specified location.
 void setRef(int v, int h, int id)
          Set ref id.
 
Methods inherited from class com.b3dgs.lionengine.game.map.AbstractTileMap
checkDefaultCollision, clear, createTile, createTile, getCollision, getHeightInTiles, getMiniMap, getPattern, getPatterns, getPatternsNumber, getTheme, getTile, getTileHeight, getTilePixelColor, getTilesNumber, getTileWidth, getWidthInTiles, load, loadPatterns, readCollisions, render, render, render, renderTile, save, save, setTile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.b3dgs.lionengine.game.map.TileBasedMap
getHeightInTiles, getPatternsNumber, getTile, getTileHeight, getTileWidth, getWidthInTiles, renderTile
 

Constructor Detail

AbstractPathMap

public AbstractPathMap(java.lang.String tilesDir,
                       int tileWidth,
                       int tileHeight,
                       int screenHeight)
Create a new path map.

Parameters:
tilesDir - tiles directory.
tileWidth - tile width.
tileHeight - tile height.
screenHeight - screen height.
Method Detail

create

public void create(int widthInTile,
                   int heightInTile)
Description copied from class: AbstractTileMap
Create and prepare map memory area. Must be called before assigning tiles.

Overrides:
create in class AbstractTileMap<TTile extends AbstractPathTile>
Parameters:
widthInTile - map width in tile.
heightInTile - map height in tile.

render

@Deprecated
public void render(java.awt.Graphics2D g,
                              Camera camera,
                              int inTileWidth,
                              int inTileHeight)
Deprecated. use render(Graphics2D g, StrategyCamera camera, int inTileWidth, int inTileHeight) instead.

Description copied from class: AbstractTileMap
Render map from camera viewpoint, showing a specified area.

Overrides:
render in class AbstractTileMap<TTile extends AbstractPathTile>
Parameters:
g - graphic output.
camera - camera viewpoint.
inTileWidth - number of rendered tiles in width.
inTileHeight - number of rendered tiles in height.

render

public void render(java.awt.Graphics2D g,
                   StrategyCamera camera,
                   int inTileWidth,
                   int inTileHeight)
Render map from camera viewpoint, showing a specified area.

Parameters:
g - graphic output.
camera - camera viewpoint.
inTileWidth - number of rendered tiles in width.
inTileHeight - number of rendered tiles in height.

renderTile

protected void renderTile(java.awt.Graphics2D g,
                          TTile tile,
                          int x,
                          int y,
                          int tx,
                          int ty)
Description copied from class: AbstractTileMap
Render a specific tile from specified location.

Overrides:
renderTile in class AbstractTileMap<TTile extends AbstractPathTile>
Parameters:
g - graphic output.
tile - tile to render.
x - location x.
y - location y.
tx - current h tile.
ty - current v tile.

pathFinderVisited

public void pathFinderVisited(int v,
                              int h)
Description copied from interface: PathBasedMap
Mark the tile as visited.

Specified by:
pathFinderVisited in interface PathBasedMap<TTile extends AbstractPathTile>
Parameters:
v - vertical location.
h - horizontal location.

getTileArround

public TTile getTileArround(Pathfindable mover,
                            int v,
                            int h,
                            int width,
                            int height)
Description copied from interface: PathBasedMap
Search the first unblocking tile arround location (clock way).

Specified by:
getTileArround in interface PathBasedMap<TTile extends AbstractPathTile>
Parameters:
mover - object searching path.
v - vertical location.
h - horizontal location.
width - number of horizontal tiles to search.
height - number of vertical tiles to search.
Returns:
unblocking tile found.

blocked

public boolean blocked(Pathfindable mover,
                       int v,
                       int h,
                       boolean ignoreRef)
Description copied from interface: PathBasedMap
Check if current location is blocking or not.

Specified by:
blocked in interface PathBasedMap<TTile extends AbstractPathTile>
Parameters:
mover - object moving on map.
v - vertical location.
h - horizontal location.
ignoreRef - ignore map ref array checking.
Returns:
true if blocking, false else.

getCost

public float getCost(Pathfindable mover,
                     int sx,
                     int sy,
                     int tx,
                     int ty)
Description copied from interface: PathBasedMap
Get the cost of the complete path, from start till end.

Specified by:
getCost in interface PathBasedMap<TTile extends AbstractPathTile>
Parameters:
mover - object moving on map.
sx - starting location x.
sy - starting location y.
tx - ending location x.
ty - ending location y.
Returns:
total cost.

setRef

public void setRef(int v,
                   int h,
                   int id)
Description copied from interface: PathBasedMap
Set ref id.

Specified by:
setRef in interface PathBasedMap<TTile extends AbstractPathTile>
Parameters:
v - vertical index.
h - horizontal index.
id - id to store.

getRef

public int getRef(int v,
                  int h)
Description copied from interface: PathBasedMap
Get ref id.

Specified by:
getRef in interface PathBasedMap<TTile extends AbstractPathTile>
Parameters:
v - vertical index.
h - horizontal index.
Returns:
id found.

getFreePlaceArround

public Point2D getFreePlaceArround(int tx,
                                   int ty,
                                   int w,
                                   int h,
                                   int id,
                                   int radius)
Description copied from interface: PathBasedMap
Search a free area from this area.

Specified by:
getFreePlaceArround in interface PathBasedMap<TTile extends AbstractPathTile>
Parameters:
tx - horizontal location.
ty - vertical location.
w - width in tile.
h - height in tile.
id - id to ignore.
radius - search size.
Returns:
free place found.

getAllFreePlaceArround

public java.util.List<Point2D> getAllFreePlaceArround(int tx,
                                                      int ty,
                                                      int w,
                                                      int h,
                                                      int id,
                                                      int radius)
Description copied from interface: PathBasedMap
Search list of free area from this area.

Specified by:
getAllFreePlaceArround in interface PathBasedMap<TTile extends AbstractPathTile>
Parameters:
tx - horizontal location.
ty - vertical location.
w - width in tile.
h - height in tile.
id - id to ignore.
radius - search size.
Returns:
list of free places found.

checkFreePlace

public boolean checkFreePlace(int tx,
                              int ty,
                              int w,
                              int h,
                              int id)
Description copied from interface: PathBasedMap
Check if area if unused.

Specified by:
checkFreePlace in interface PathBasedMap<TTile extends AbstractPathTile>
Parameters:
tx - horizontal location.
ty - vertical location.
w - width in tile.
h - height in tile.
id - id to ignore.
Returns:
true if area is free (area id = 0).

load

public void load(XMLNode root)
Description copied from class: AbstractTileMap
Load a map from a specified file as xml. Data are loaded this way (see save(file) order):
 (String) theme
 (short) width in tiles
 (short) height in tiles
 (byte) tile width
 (byte) tile height
 (short) tiles number
 for n = 0 to tileNumber
        create blank tile
        call tile.load(file)
        call this.setTile(...) to update map with this new tile
 

Overrides:
load in class AbstractTileMap<TTile extends AbstractPathTile>
Parameters:
root - input node.

createMiniMap

public void createMiniMap()
Description copied from class: AbstractTileMap
Generate the minimap from the current map.

Overrides:
createMiniMap in class AbstractTileMap<TTile extends AbstractPathTile>

renderMiniMap

public void renderMiniMap(java.awt.Graphics2D g,
                          int x,
                          int y)
Description copied from class: AbstractTileMap
Render minimap on graphic output at specified location.

Overrides:
renderMiniMap in class AbstractTileMap<TTile extends AbstractPathTile>
Parameters:
g - graphic output.
x - location x.
y - location y.

createMiniMapGraphics

public java.awt.Graphics2D createMiniMapGraphics()
Get minimap graphics reference.

Returns:
minimap graphics reference.