Example #1
0
 public void MyActionRightClick(Celda c)
 {
     if (c.ShowFlag == Visibility.Hidden && c.ShowQuestion == Visibility.Hidden)
     {
         c.ShowFlag = Visibility.Visible;
     }
     else if (c.ShowFlag == Visibility.Visible)
     {
         c.ShowFlag = Visibility.Hidden;
         c.ShowQuestion = Visibility.Visible;
     }
     else if (c.ShowQuestion == Visibility.Visible)
     {
         c.ShowQuestion = Visibility.Hidden;
     }
 }
Example #2
0
        private void NuevoJuego()
        {
            List<Celda> lstCeldas = new List<Celda>();
            for (int i = 0; i < NumDificultad; i++)
                for (int j = 0; j < NumDificultad; j++)
                {
                    Celda c = new Celda();
                    c.Row = i;
                    c.Column = j;
                    c.Text = "";
                    c.Mina = false;
                    lstCeldas.Add(c);
                }

            Random r = new Random();
            for (int i = 0; i < NumMinas; i++)
            {
                int x = r.Next(0, lstCeldas.Count);
                if (lstCeldas[x].Mina)
                    i--;
                lstCeldas[x].Mina = true;
            }

            Celdas = lstCeldas;
        }
Example #3
0
        public void MyActionLeftClick(Celda c)
        {
            if (c.Mina)
            {
                c.Text = "M";
                c.ShowBomb = Visibility.Visible;
                MessageBox.Show("Game Over");
                NuevoJuego();
            }
            else
            {
                int n = GetNumMinasAlrededorCelda(c.Row, c.Column);
                c.Text = n.ToString();
                if (n == 0)
                {
                    DespejarCeldasAlrededor(c.Row, c.Column);
                }

                if (GetNumCeldasSinAbrir() == NumMinas)
                {
                    MessageBox.Show("You Win");
                    NuevoJuego();
                }
            }
        }