Exemplo n.º 1
0
 public void MyActionRightClick(Celda c)
 {
     if (c.ShowFlag == Visibility.Collapsed && c.ShowQuestion == Visibility.Collapsed)
     {
         c.ShowFlag = Visibility.Visible;
     }
     else if (c.ShowFlag == Visibility.Visible)
     {
         c.ShowFlag     = Visibility.Collapsed;
         c.ShowQuestion = Visibility.Visible;
     }
     else if (c.ShowQuestion == Visibility.Visible)
     {
         c.ShowQuestion = Visibility.Collapsed;
     }
 }
Exemplo n.º 2
0
 public void MyActionLeftClick(Celda c)
 {
     viewModelBase.MyActionLeftClick(c);
 }
Exemplo n.º 3
0
 public void MyActionLeftClick(Celda c)
 {
     viewModelBase.MyActionLeftClick(c);
 }
Exemplo n.º 4
0
        public async void MyActionLeftClick(Celda c)
        {
            if (c.Mina)
            {
                c.Text = "M";
                c.ShowBomb = Visibility.Visible;
                c.ShowButton = Visibility.Collapsed;

                MessageDialog msgbox = new MessageDialog("Game Over");
                var res = await msgbox.ShowAsync();
                NuevoJuego();
            }
            else
            {
                int n = GetNumMinasAlrededorCelda(c.Row, c.Column);
                c.Text = n.ToString();
                if (n == 0)
                {
                    DespejarCeldasAlrededor(c.Row, c.Column);
                }

                if (GetNumCeldasSinAbrir() == NumMinas)
                {
                    MessageDialog msgbox = new MessageDialog("You Win");
                    var res = await msgbox.ShowAsync();
                    NuevoJuego();
                }
            }
        }
Exemplo n.º 5
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;
                    c.ViewModelBase = this;
                    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;
        }
Exemplo n.º 6
0
 public void MyActionRightClick(Celda c)
 {
     if (c.ShowFlag == Visibility.Collapsed && c.ShowQuestion == Visibility.Collapsed)
     {
         c.ShowFlag = Visibility.Visible;
     }
     else if (c.ShowFlag == Visibility.Visible)
     {
         c.ShowFlag = Visibility.Collapsed;
         c.ShowQuestion = Visibility.Visible;
     }
     else if (c.ShowQuestion == Visibility.Visible)
     {
         c.ShowQuestion = Visibility.Collapsed;
     }
 }