private void DepthFirstSearch(ICell currentCell, ref int counter) { if (currentCell.ChangeState()) { counter++; } if (currentCell.MinesNumber > 0 || currentCell.HasMine) { return; } currentCell.HasVisited = true; foreach (ICell cell in currentCell.CellsAround) { if (!cell.HasVisited) { DepthFirstSearch(cell, ref counter); } } }