Esempio n. 1
0
        public IEnumerable <Cell> GetNeighbours(Cell cell)
        {
            var result = new List <Cell>();

            for (var row = cell.X - 1; row <= cell.X + 1; row++)
            {
                for (var col = cell.Y - 1; col <= cell.Y + 1; col++)
                {
                    if (CellHelpers.IsValidCell(row, col, size) && (row != cell.X || col != cell.Y))
                    {
                        result.Add(GetCell(row, col));
                    }
                }
            }
            return(result);
        }
Esempio n. 2
0
        public void ComputeWarnCount(Cell[,] cells, int size)
        {
            foreach (var cell in cells)
            {
                if (cell.IsMine)
                {
                    continue;
                }

                for (var row = cell.X - 1; row <= cell.X + 1; row++)
                {
                    for (var col = cell.Y - 1; col <= cell.Y + 1; col++)
                    {
                        if (CellHelpers.IsValidCell(row, col, size) && cells[row, col].IsMine)
                        {
                            cell.WarnCount++;
                        }
                    }
                }
            }
        }