/// <summary> /// Find the shortest path to the destination using the A* algorithm. /// </summary> /// <param name="map"></param> /// <param name="player"></param> /// <param name="destinationX">The destination x (in "pixels").</param> /// <param name="destinationY">The destination y (in "pixels").</param> /// <exception cref="InvalidOperationException">Thrown if the target destination /// is unreachable.</exception> public Path FindPath(Map map, Player player, int destinationX, int destinationY) { MinotaurPathfinder.Pathfinder pathfinder = new MinotaurPathfinder.Pathfinder(map); pathfinder.Pathfind(map, player, destinationX, destinationY); Path path = new Path(); foreach (MinotaurPathfinder.MetaCompleteSquare square in pathfinder.FullPath()) { path.AppendNode(new Node(square.X, square.Y)); } pathfinder.Dispose(); return path; }
/// <summary> /// Find the shortest path to the destination using the A* algorithm. /// </summary> /// <param name="map"></param> /// <param name="player"></param> /// <param name="destinationX">The destination x (in "pixels").</param> /// <param name="destinationY">The destination y (in "pixels").</param> /// <exception cref="InvalidOperationException">Thrown if the target destination /// is unreachable.</exception> public Path FindPath(Map map, Player player, int destinationX, int destinationY) { MinotaurPathfinder.Pathfinder pathfinder = new MinotaurPathfinder.Pathfinder(map); pathfinder.Pathfind(map, player, destinationX, destinationY); Path path = new Path(); foreach (MinotaurPathfinder.MetaCompleteSquare square in pathfinder.FullPath()) { path.AppendNode(new Node(square.X, square.Y)); } pathfinder.Dispose(); return(path); }