private void GetNearbyNumbersByConnected(int x, int y, int number) { if (x + 1 < FillBusinessLogic.tempFillArray.GetLength(0)) { if ((Genes.Exists(z => z.X == x + 1 && z.Y == y && z.Number == number) || FillBusinessLogic.tempFillArray[x + 1, y].Number == number) && nearbyPoints.Count < number - 1 && !nearbyPoints.Exists(z => z.X == x + 1 && z.Y == y)) { nearbyValue--; nearbyPoints.Add(new Point(x + 1, y)); GetNearbyNumbersByConnected(x + 1, y, number); } } if (y + 1 < FillBusinessLogic.tempFillArray.GetLength(1)) { if (Genes.Exists(z => z.X == x && z.Y == y + 1 && z.Number == number || FillBusinessLogic.tempFillArray[x, y + 1].Number == number) && nearbyPoints.Count < number - 1 && !nearbyPoints.Exists(z => z.X == x && z.Y == y + 1)) { nearbyValue--; nearbyPoints.Add(new Point(x, y + 1)); GetNearbyNumbersByConnected(x, y + 1, number); } } if (x - 1 >= 0) { if (Genes.Exists(z => z.X == x - 1 && z.Y == y && z.Number == number || FillBusinessLogic.tempFillArray[x - 1, y].Number == number) && nearbyPoints.Count < number - 1 && !nearbyPoints.Exists(z => z.X == x - 1 && z.Y == y)) { nearbyValue--; nearbyPoints.Add(new Point(x - 1, y)); GetNearbyNumbersByConnected(x - 1, y, number); } } if (y - 1 >= 0) { if (Genes.Exists(z => z.X == x && z.Y == y - 1 && z.Number == number || FillBusinessLogic.tempFillArray[x, y - 1].Number == number) && nearbyPoints.Count < number - 1 && !nearbyPoints.Exists(z => z.X == x && z.Y == y - 1)) { nearbyValue--; nearbyPoints.Add(new Point(x, y - 1)); GetNearbyNumbersByConnected(x, y - 1, number); } } }