Package com.mygdx.game.AI
Class TileMapGraph
- java.lang.Object
-
- com.mygdx.game.AI.TileMapGraph
-
- All Implemented Interfaces:
com.badlogic.gdx.ai.pfa.Graph<Node>,com.badlogic.gdx.ai.pfa.indexed.IndexedGraph<Node>
public class TileMapGraph extends java.lang.Object implements com.badlogic.gdx.ai.pfa.indexed.IndexedGraph<Node>
The Graphical representation of the tilemap with each cell being bidirectionally to the adjacent nodes.
-
-
Constructor Summary
Constructors Constructor Description TileMapGraph(com.badlogic.gdx.maps.tiled.TiledMap map)Creates a Graph from the given tilemap
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QueueFIFO<com.badlogic.gdx.math.Vector2>findOptimisedPath(float x1, float y1, float x2, float y2)Finds a sequence on locations which can be travelled to without collisionQueueFIFO<com.badlogic.gdx.math.Vector2>findOptimisedPath(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b)Finds a sequence on locations which can be travelled to without collisionQueueFIFO<com.badlogic.gdx.math.Vector2>findOptimisedPath(Node a, Node b)Finds a sequence of locations which can be travelled to without collisioncom.badlogic.gdx.ai.pfa.GraphPath<Node>findPath(Node start, Node goal)Finds the pathcom.badlogic.gdx.utils.Array<com.badlogic.gdx.ai.pfa.Connection<Node>>getConnections(Node fromNode)intgetIndex(Node node)NodegetNode(float x, float y)Node a position (x, y)intgetNodeCount()
-
-
-
Method Detail
-
getNode
public Node getNode(float x, float y)
Node a position (x, y)- Parameters:
x- co-ordy- co-ord- Returns:
- Node at (x, y) or null
-
findPath
public com.badlogic.gdx.ai.pfa.GraphPath<Node> findPath(Node start, Node goal)
Finds the path- Parameters:
start- the starting nodegoal- the ending node- Returns:
- a queue of the nodes to visit null if no path id found
-
findOptimisedPath
public QueueFIFO<com.badlogic.gdx.math.Vector2> findOptimisedPath(Node a, Node b)
Finds a sequence of locations which can be travelled to without collision- Parameters:
a- starting nodeb- destination node- Returns:
- queue of location to travel to in order
-
findOptimisedPath
public QueueFIFO<com.badlogic.gdx.math.Vector2> findOptimisedPath(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b)
Finds a sequence on locations which can be travelled to without collision- Parameters:
a- starting node locationb- destination node location- Returns:
- queue of location to travel to in order
-
findOptimisedPath
public QueueFIFO<com.badlogic.gdx.math.Vector2> findOptimisedPath(float x1, float y1, float x2, float y2)
Finds a sequence on locations which can be travelled to without collision- Parameters:
x1- starting node x co-ords tile spacey1- starting node y co-ords tile spacex2- destination node x co-ords tile spacey2- destination node y co-ords tile space- Returns:
- queue of location to travel to in order
-
getIndex
public int getIndex(Node node)
- Specified by:
getIndexin interfacecom.badlogic.gdx.ai.pfa.indexed.IndexedGraph<Node>
-
getNodeCount
public int getNodeCount()
- Specified by:
getNodeCountin interfacecom.badlogic.gdx.ai.pfa.indexed.IndexedGraph<Node>
-
-