/// <summary> /// See <see cref="BaseGraphSearchPathfinder{TNode,TMap}.OnPerformAlgorithm"/> for more details. /// </summary> protected override void OnPerformAlgorithm(AStarNode currentNode, AStarNode neighborNode, Point neighborPoint, Point endPoint, StopFunction stopFunction) { Point jumpPoint; if (TryJump(neighborPoint, currentNode.Point, endPoint, stopFunction, out jumpPoint)) { AStarNode jumpNode = Map[jumpPoint.X, jumpPoint.Y]; int distance = HeuristicHelper.FastEuclideanDistance(currentNode.Point, jumpPoint); int jumpScore = currentNode.Score + distance; if (jumpNode == null) { Map.OpenNode(jumpPoint, currentNode, jumpScore, jumpScore + HeuristicHelper.FastEuclideanDistance(jumpPoint, endPoint)); } else if (jumpScore < jumpNode.Score) { if (jumpNode.IsClosed) { return; } jumpNode.Update(jumpScore, jumpScore + HeuristicHelper.FastEuclideanDistance(jumpPoint, endPoint), currentNode); } } }
/// <summary> /// See <see cref="BaseGraphSearchPathfinder{TNode,TMap}.OnPerformAlgorithm"/> for more details. /// </summary> protected override void OnPerformAlgorithm(DijkstraNode currentNode, DijkstraNode neighborNode, Point neighborPoint, Point endPoint, StopFunction stopFunction) { int neighborScore = HeuristicHelper.FastEuclideanDistance(neighborPoint, endPoint); if (neighborNode == null) { Map.OpenNode(neighborPoint, currentNode, neighborScore); } else if (neighborScore < neighborNode.Score) { neighborNode.Update(neighborScore, currentNode); } }
/// <summary> /// See <see cref="BaseGraphSearchPathfinder{TNode,TMap}.OnPerformAlgorithm"/> for more details. /// </summary> protected override void OnPerformAlgorithm(AStarNode currentNode, AStarNode neighborNode, Vector2 neighborPosition, Vector2 endPosition, StopFunction <Vector2> stopFunction) { Int32 neighborScore = currentNode.Score + GetNeighborDistance(currentNode.Value, neighborPosition); // opens node at this position if (neighborNode == null) { Map.OpenNode(neighborPosition, currentNode, neighborScore, neighborScore + HeuristicHelper.FastEuclideanDistance(neighborPosition, endPosition)); } else if (neighborScore < neighborNode.Score) { neighborNode.Update(neighborScore, neighborScore + HeuristicHelper.FastEuclideanDistance(neighborPosition, endPosition), currentNode); } }
/// <summary> /// See <see cref="BaseGraphSearchPathfinder{TNode,TMap}.OnPerformAlgorithm"/> for more details. /// </summary> protected override void OnPerformAlgorithm(AStarNode currentNode, AStarNode neighborNode, Point neighborPoint, Point endPoint, StopFunction stopFunction) { int neighborScore = currentNode.Score + NeighborDistance(currentNode.Point, neighborPoint); // opens node at this position if (neighborNode == null) { Map.OpenNode(neighborPoint, currentNode, neighborScore, neighborScore + HeuristicHelper.FastEuclideanDistance(neighborPoint, endPoint)); } else if (neighborScore < neighborNode.Score) { neighborNode.Update(neighborScore, neighborScore + HeuristicHelper.FastEuclideanDistance(neighborPoint, endPoint), currentNode); } }
/// <summary> /// See <see cref="BaseGraphSearchMap{TNode}.OnCreateFirstNode"/> for more details. /// </summary> protected override AStarNode OnCreateFirstNode(Vector2 startPosition, Vector2 endPosition) { return(new AStarNode(startPosition, null, 0, HeuristicHelper.FastEuclideanDistance(startPosition, endPosition))); }
/// <summary> /// See <see cref="BaseGraphSearchMap{TNode}.OnCreateFirstNode"/> for more details. /// </summary> protected override AStarNode OnCreateFirstNode(Point startPoint, Point endPoint) { return(new AStarNode(startPoint, null, 0, HeuristicHelper.FastEuclideanDistance(startPoint, endPoint))); }