private Task <GridNode[]> SuccessorNodes(GridNode parent) { //TODO: Fix this nasty ass shit //-------------------------------------------------------------------------------------------------------------FIX--------------------------------------------------------------------- var tcs = new TaskCompletionSource <GridNode[]>(); List <GridNode> nodes = new List <GridNode>(4); Point pos = parent.Location.Cordinates; for (int y = -1; y < 2; y++) { var location = new Point(pos.X, pos.Y + y * (size + 1)); if (!MapData.Screen.Contains(location) || location == parent.Location.Cordinates) { continue; } bool walkable = !MapData.Obstacles.Any(obs => obs.Contains(location)); if (walkable) { var tempPoint = new GridPoint(location, walkable); var tempNode = new GridNode(parent, tempPoint); nodes.Add(tempNode); } } for (int x = -1; x < 2; x++) { var location = new Point(pos.X + x * (size + 1), pos.Y); if (!MapData.Screen.Contains(location) || location == parent.Location.Cordinates) { continue; } bool walkable = !MapData.Obstacles.Any(obs => obs.Contains(location)); if (walkable) { var tempPoint = new GridPoint(location, walkable); var tempNode = new GridNode(parent, tempPoint); nodes.Add(tempNode); } } tcs.SetResult(nodes.ToArray()); return(tcs.Task); }
public GridNode(Point startGoalPoint) { Parrent = null; Location = new GridPoint(startGoalPoint, true); }
public static bool SameValues(this GridPoint a, GridPoint b) => a.Walkable && b.Walkable && a.Cordinates.X == b.Cordinates.X && a.Cordinates.Y == b.Cordinates.Y;
public static float Pyth(GridPoint a, GridPoint b) => Pyth(a.Cordinates, b.Cordinates);