org.deken.game.pathfinding
Class FindPathsFourWay

java.lang.Object
  extended by org.deken.game.pathfinding.FindPathsFourWay

public class FindPathsFourWay
extends java.lang.Object

Title: FindPaths

Description: Performs pathfinding for a map that all paths are based on one of four directions. (Cardinal directions are used)

Copyright: Copyright (c) Feb 11, 2012

Version:
1.0
Author:
Gary Deken

Nested Class Summary
static class FindPathsFourWay.TARGETING
           
 
Constructor Summary
FindPathsFourWay(MapElement[][][] tiles, MapSize mapSize, PathFinding pathFinding)
           
FindPathsFourWay(MapElement[][][] tiles, MapSize mapSize, PathFinding pathFinding, FindPathsFourWay.TARGETING targeting)
           
FindPathsFourWay(MapElement[][][] tiles, PathFinding pathFinding, FindPathsFourWay.TARGETING targeting, int startX, int startY, int endX, int endY)
          Creates a FindPathsFourWay, that will uses the tiles as the map starting at location startX, startY to endX, endY to build a Node map.
FindPathsFourWay(MapElement[][][] tiles, PathFinding pathFinding, int startX, int startY, int endX, int endY)
           
 
Method Summary
 java.util.List<Node> getNearestNodes(int x, int y)
          This returns one or two nodes.
 Node getNode(int x, int y)
           
 NodeLink getNodeLinkIfOnSamePath(int firstX, int firstY, int secondX, int secondY)
           
 java.util.Map<java.lang.String,Node> getNodes()
           
 java.util.List<java.lang.String> getPathKeysToTarget(int startX, int startY, int targetX, int targetY)
          Gets the PathKeys from the start location (x & Y) to the target (targetX & targetY) location.
 java.util.List<java.lang.String> getPathKeysToTarget(int startX, int startY, int targetX, int targetY, int excludeX, int excludeY)
          Gets the PathKeys from the start location (x & Y) to the target (targetX & targetY) location.
 FindPathsFourWay.TARGETING getTargeting()
           
 boolean isAtNode(int x, int y)
           
 void setPathFinding(PathFinding pathFinding)
           
 void setTargeting(FindPathsFourWay.TARGETING targeting)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FindPathsFourWay

public FindPathsFourWay(MapElement[][][] tiles,
                        MapSize mapSize,
                        PathFinding pathFinding)

FindPathsFourWay

public FindPathsFourWay(MapElement[][][] tiles,
                        MapSize mapSize,
                        PathFinding pathFinding,
                        FindPathsFourWay.TARGETING targeting)

FindPathsFourWay

public FindPathsFourWay(MapElement[][][] tiles,
                        PathFinding pathFinding,
                        int startX,
                        int startY,
                        int endX,
                        int endY)

FindPathsFourWay

public FindPathsFourWay(MapElement[][][] tiles,
                        PathFinding pathFinding,
                        FindPathsFourWay.TARGETING targeting,
                        int startX,
                        int startY,
                        int endX,
                        int endY)
Creates a FindPathsFourWay, that will uses the tiles as the map starting at location startX, startY to endX, endY to build a Node map. The node map is based on any location that has three or more adjacent tiles.

Parameters:
tiles -
pathFinding -
targeting -
startX -
startY -
endX -
endY -
Method Detail

getNearestNodes

public java.util.List<Node> getNearestNodes(int x,
                                            int y)
This returns one or two nodes. If the parameters are on a Node, that Node is returned. Otherwise, two Nodes are returned. A path can only be between two nodes.

Parameters:
x -
y -
Returns:

getNode

public Node getNode(int x,
                    int y)

getNodeLinkIfOnSamePath

public NodeLink getNodeLinkIfOnSamePath(int firstX,
                                        int firstY,
                                        int secondX,
                                        int secondY)

getNodes

public java.util.Map<java.lang.String,Node> getNodes()

getPathKeysToTarget

public java.util.List<java.lang.String> getPathKeysToTarget(int startX,
                                                            int startY,
                                                            int targetX,
                                                            int targetY)
Gets the PathKeys from the start location (x & Y) to the target (targetX & targetY) location. This is a Node to Target path.

Parameters:
startX -
startY -
targetX -
targetY -
Returns:
List

getPathKeysToTarget

public java.util.List<java.lang.String> getPathKeysToTarget(int startX,
                                                            int startY,
                                                            int targetX,
                                                            int targetY,
                                                            int excludeX,
                                                            int excludeY)
Gets the PathKeys from the start location (x & Y) to the target (targetX & targetY) location. This is a Node to Target path. This excludes the location (excludeX & excludeY) passed in, unless it is where the target is.

Parameters:
startX -
startY -
targetX -
targetY -
excludeX -
excludeY -
Returns:
List

getTargeting

public FindPathsFourWay.TARGETING getTargeting()

isAtNode

public boolean isAtNode(int x,
                        int y)

setPathFinding

public void setPathFinding(PathFinding pathFinding)

setTargeting

public void setTargeting(FindPathsFourWay.TARGETING targeting)