public void RevealCells(int x, int y)
        {
            Cell cellTemp = grid[y][x];

            if (!cellTemp.isMine)
            {
                SafeCell cell = (SafeCell)cellTemp;

                if (!cell.clicked)
                {
                    List <int> validX = new List <int>();
                    List <int> validY = new List <int>();

                    validX.Add(x);
                    validY.Add(y);

                    if (y != 0)
                    {
                        validY.Add(y - 1);
                    }

                    if (y != gridHeight - 1)
                    {
                        validY.Add(y + 1);
                    }

                    if (x != 0)
                    {
                        validX.Add(x - 1);
                    }

                    if (x != gridWidth - 1)
                    {
                        validX.Add(x + 1);
                    }

                    cell.Reveal();

                    if (!cell.flagged)
                    {
                        revealedCells++;
                        cell.clicked = true;
                    }


                    if (cell.bombsNearby == 0)
                    {
                        foreach (int posY in validY)
                        {
                            foreach (int posX in validX)
                            {
                                if (!(posY == y && posX == x))
                                {
                                    RevealCells(posX, posY);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                lost = true;
                Mine mine = (Mine)cellTemp;
                mine.clicked  = true;
                mine.exploded = true;
            }
        }
        private void CountMines()
        {
            foreach (List <Cell> row in grid) //RESETEAR LAS MINAS A 0
            {
                foreach (Cell cell in row)
                {
                    if (!cell.isMine)
                    {
                        SafeCell safecell = (SafeCell)cell;
                        safecell.bombsNearby = 0;
                    }
                }
            }

            List <int> validX = new List <int>();
            List <int> validY = new List <int>();

            for (int y = 0; y < gridHeight; y++)
            {
                for (int x = 0; x < gridWidth; x++)
                {
                    if (grid[y][x].isMine)
                    {
                        validX.Add(x);
                        validY.Add(y);

                        if (y != 0)
                        {
                            validY.Add(y - 1);
                        }

                        if (y != gridHeight - 1)
                        {
                            validY.Add(y + 1);
                        }
                        if (x != 0)
                        {
                            validX.Add(x - 1);
                        }

                        if (x != gridWidth - 1)
                        {
                            validX.Add(x + 1);
                        }

                        foreach (int posX in validX)
                        {
                            foreach (int posY in validY)
                            {
                                if (!(posY == y && posX == x))
                                {
                                    Cell cell = grid[posY][posX];
                                    if (!cell.isMine)
                                    {
                                        SafeCell safeCell = (SafeCell)cell;
                                        safeCell.bombsNearby++;
                                    }
                                }
                            }
                        }

                        validX = new List <int>();
                        validY = new List <int>();
                    }
                }
            }
        }