public GameCell RightClickCell(GameCell gc) { GameCell gameCell = GameCells.Find(cell => cell.X == gc.X && cell.Y == gc.Y); gameCell.FlagCell(); return(gameCell); }
public void SetNeighbors() { foreach (GameCell currentCell in GameCells) { GameCell northNeighbor = GameCells.Find(cell => cell.X == currentCell.X - 1 && cell.Y == currentCell.Y); GameCell eastNeighbor = GameCells.Find(cell => cell.X == currentCell.X && cell.Y == currentCell.Y - 1); GameCell southNeighbor = GameCells.Find(cell => cell.X == currentCell.X + 1 && cell.Y == currentCell.Y); GameCell westNeighbor = GameCells.Find(cell => cell.X == currentCell.X && cell.Y == currentCell.Y + 1); currentCell.Neighbors = new Neighbors(northNeighbor, eastNeighbor, southNeighbor, westNeighbor); } }
public void ActivateCells() { int cellCount = BoardSize.Size * BoardSize.Size; int numberOfActiveCells = (int)(cellCount * Difficulty.Difficulty); Random rnd = new Random(); for (int i = 0; i < numberOfActiveCells; i++) { int x = rnd.Next(1, BoardSize.Size + 1); int y = rnd.Next(1, BoardSize.Size + 1); GameCell result = GameCells.Find(cell => cell.X == x && cell.Y == y && !cell.Live); while (result == null) { x = rnd.Next(1, BoardSize.Size + 1); y = rnd.Next(1, BoardSize.Size + 1); result = GameCells.Find(cell => cell.X == x && cell.Y == y && !cell.Live); } result.Live = true; } }