public bool hashRoute(Point aStartPoint, Point aEndPoint, movedirs aMovedir) { for (int i = 0; i < iRoutes.GetLength(0); i++) { for (int j = 0; j < iRoutes.GetLength(1); j++) { iRoutes[i, j].CheckingRoutes = false; } } int xindex = aStartPoint.X - iSearchPoint.X; int yindex = aStartPoint.Y - iSearchPoint.Y; return(iRoutes[xindex, yindex].Enabled && iRoutes[xindex, yindex].IsRouteTo(aEndPoint, aMovedir)); }
public bool IsRouteTo(Point aPoint, movedirs aMovedir) { if (aPoint.X == -1 || aPoint.X == iLocation.X) if (aPoint.Y == -1 || aPoint.Y == iLocation.Y) return true; bool result = false; if (!iCheckingNeighbours) { iCheckingNeighbours = true; foreach (Node node in iNeighbours) { if ((aMovedir & movedirs.upleft) != 0 && (node.Location.Y >= iLocation.Y || node.Location.X >= iLocation.X)) continue; else if ((aMovedir & movedirs.upright) != 0 && (node.Location.Y >= iLocation.Y || node.Location.X <= iLocation.X)) continue; else if ((aMovedir & movedirs.downright) != 0 && (node.Location.Y <= iLocation.Y || node.Location.X <= iLocation.X)) continue; if (aMovedir != movedirs.upleft && aMovedir != movedirs.upright && aMovedir != movedirs.downright) { if ((aMovedir & movedirs.left) == 0 && node.Location.X < iLocation.X) continue; if ((aMovedir & movedirs.right) == 0 && node.Location.X > iLocation.X) continue; if ((aMovedir & movedirs.up) == 0 && node.Location.Y < iLocation.Y) continue; if ((aMovedir & movedirs.down) == 0 && node.Location.Y > iLocation.Y) continue; } if (node.IsRouteTo(aPoint, aMovedir)) { result = true; break; } } } return result; }
public bool hashRoute(Point aStartPoint, Point aEndPoint, movedirs aMovedir) { for (int i = 0; i < iRoutes.GetLength(0); i++) for (int j = 0; j < iRoutes.GetLength(1); j++) iRoutes[i, j].CheckingRoutes = false; int xindex = aStartPoint.X - iSearchPoint.X; int yindex = aStartPoint.Y - iSearchPoint.Y; return iRoutes[xindex, yindex].Enabled && iRoutes[xindex, yindex].IsRouteTo(aEndPoint, aMovedir); }
public bool IsRouteTo(Point aPoint, movedirs aMovedir) { if (aPoint.X == -1 || aPoint.X == iLocation.X) { if (aPoint.Y == -1 || aPoint.Y == iLocation.Y) { return(true); } } bool result = false; if (!iCheckingNeighbours) { iCheckingNeighbours = true; foreach (Node node in iNeighbours) { if ((aMovedir & movedirs.upleft) != 0 && (node.Location.Y >= iLocation.Y || node.Location.X >= iLocation.X)) { continue; } else if ((aMovedir & movedirs.upright) != 0 && (node.Location.Y >= iLocation.Y || node.Location.X <= iLocation.X)) { continue; } else if ((aMovedir & movedirs.downright) != 0 && (node.Location.Y <= iLocation.Y || node.Location.X <= iLocation.X)) { continue; } if (aMovedir != movedirs.upleft && aMovedir != movedirs.upright && aMovedir != movedirs.downright) { if ((aMovedir & movedirs.left) == 0 && node.Location.X < iLocation.X) { continue; } if ((aMovedir & movedirs.right) == 0 && node.Location.X > iLocation.X) { continue; } if ((aMovedir & movedirs.up) == 0 && node.Location.Y < iLocation.Y) { continue; } if ((aMovedir & movedirs.down) == 0 && node.Location.Y > iLocation.Y) { continue; } } if (node.IsRouteTo(aPoint, aMovedir)) { result = true; break; } } } return(result); }