com.badlogic.gdx.ai.pfa.Connection Java Examples

The following examples show how to use com.badlogic.gdx.ai.pfa.Connection. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Node.java    From Pacman_libGdx with MIT License 5 votes vote down vote up
public Node(AStarMap map, int x, int y) {
    this.x = x;
    this.y = y;
    this.index = x * map.getHeight() + y;
    this.isWall = false;
    this.connections = new Array<Connection<Node>>();
}
 
Example #2
Source File: Triangle.java    From GdxDemo3D with Apache License 2.0 5 votes vote down vote up
public Triangle(Vector3 a, Vector3 b, Vector3 c, int triIndex, int meshPartIndex) {
	this.a = a;
	this.b = b;
	this.c = c;
	this.triIndex = triIndex;
	this.meshPartIndex = meshPartIndex;
	this.centroid = new Vector3(a).add(b).add(c).scl(1f / 3f);
	this.connections = new Array<Connection<Triangle>>();
}
 
Example #3
Source File: IndexedAStarPathFinder.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
protected void generateConnectionPath (N startNode, GraphPath<Connection<N>> outPath) {

		// Work back along the path, accumulating connections
		// outPath.clear();
		while (current.node != startNode) {
			outPath.add(current.connection);
			current = nodeRecords[graph.getIndex(current.connection.getFromNode())];
		}

		// Reverse the path
		outPath.reverse();
	}
 
Example #4
Source File: IndexedAStarPathFinder.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
@Override
public boolean searchConnectionPath (N startNode, N endNode, Heuristic<N> heuristic, GraphPath<Connection<N>> outPath) {

	// Perform AStar
	boolean found = search(startNode, endNode, heuristic);

	if (found) {
		// Create a path made of connections
		generateConnectionPath(startNode, outPath);
	}

	return found;
}
 
Example #5
Source File: AStartPathFinding.java    From Pacman_libGdx with MIT License 5 votes vote down vote up
public AStartPathFinding(AStarMap map) {
    this.map = map;
    this.pathfinder = new IndexedAStarPathFinder<Node>(createGraph(map));
    this.connectionPath = new DefaultGraphPath<Connection<Node>>();
    this.heuristic = new Heuristic<Node>() {
        @Override
        public float estimate (Node node, Node endNode) {
            // Manhattan distance
            return Math.abs(endNode.x - node.x) + Math.abs(endNode.y - node.y);
        }
  };
}
 
Example #6
Source File: FlatTiledGraph.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
@Override
public Array<Connection<FlatTiledNode>> getConnections (FlatTiledNode fromNode) {
	return fromNode.getConnections();
}
 
Example #7
Source File: IndexedAStarPathFinderTest.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
@Override
public Array<Connection<MyNode>> getConnections (MyNode fromNode) {
	return fromNode.getConnections();
}
 
Example #8
Source File: IndexedAStarPathFinderTest.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
public Array<Connection<MyNode>> getConnections () {
	return connections;
}
 
Example #9
Source File: HierarchicalTiledNode.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
public HierarchicalTiledNode (int x, int y, int type, int index, int connectionCapacity) {
	super(x, y, type, new Array<Connection<HierarchicalTiledNode>>(connectionCapacity));
	this.index = index;
}
 
Example #10
Source File: HierarchicalTiledGraph.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
@Override
public Array<Connection<HierarchicalTiledNode>> getConnections (HierarchicalTiledNode fromNode) {
	return fromNode.getConnections();
}
 
Example #11
Source File: TiledNode.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
public Array<Connection<N>> getConnections () {
	return this.connections;
}
 
Example #12
Source File: TiledNode.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
public TiledNode (int x, int y, int type, Array<Connection<N>> connections) {
	this.x = x;
	this.y = y;
	this.type = type;
	this.connections = connections;
}
 
Example #13
Source File: FlatTiledNode.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
public FlatTiledNode (int x, int y, int type, int connectionCapacity) {
	super(x, y, type, new Array<Connection<FlatTiledNode>>(connectionCapacity));
}
 
Example #14
Source File: NavMeshGraph.java    From GdxDemo3D with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public Array<Connection<Triangle>> getConnections(Triangle fromNode) {
	return (Array<Connection<Triangle>>) (Array<?>) sharedEdges.getValueAt(fromNode.triIndex);
}
 
Example #15
Source File: Triangle.java    From GdxDemo3D with Apache License 2.0 4 votes vote down vote up
public Array<Connection<Triangle>> getConnections() {
	return connections;
}
 
Example #16
Source File: Node.java    From Pacman_libGdx with MIT License 4 votes vote down vote up
public Array<Connection<Node>> getConnections () {
    return connections;
}
 
Example #17
Source File: AStartPathFinding.java    From Pacman_libGdx with MIT License 4 votes vote down vote up
@Override
public Array<Connection<Node>> getConnections(Node fromNode) {
    return fromNode.getConnections();
}