Class 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​(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b)
      Finds a sequence on locations which can be travelled to without collision
      QueueFIFO<com.badlogic.gdx.math.Vector2> findOptimisedPath​(Node a, Node b)
      Finds a sequence of locations which can be travelled to without collision
      com.badlogic.gdx.ai.pfa.GraphPath<Node> findPath​(Node start, Node goal)
      Finds the path
      com.badlogic.gdx.utils.Array<com.badlogic.gdx.ai.pfa.Connection<Node>> getConnections​(Node fromNode)  
      int getIndex​(Node node)  
      Node getNode​(float x, float y)
      Node a position (x, y)
      int getNodeCount()  
      • Methods inherited from class java.lang.Object

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

      • TileMapGraph

        public TileMapGraph​(com.badlogic.gdx.maps.tiled.TiledMap map)
        Creates a Graph from the given tilemap
        Parameters:
        map - the source tilemap
    • Method Detail

      • getNode

        public Node getNode​(float x,
                            float y)
        Node a position (x, y)
        Parameters:
        x - co-ord
        y - 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 node
        goal - 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 node
        b - 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 location
        b - destination node location
        Returns:
        queue of location to travel to in order
      • getIndex

        public int getIndex​(Node node)
        Specified by:
        getIndex in interface com.badlogic.gdx.ai.pfa.indexed.IndexedGraph<Node>
      • getNodeCount

        public int getNodeCount()
        Specified by:
        getNodeCount in interface com.badlogic.gdx.ai.pfa.indexed.IndexedGraph<Node>
      • getConnections

        public com.badlogic.gdx.utils.Array<com.badlogic.gdx.ai.pfa.Connection<Node>> getConnections​(Node fromNode)
        Specified by:
        getConnections in interface com.badlogic.gdx.ai.pfa.Graph<Node>