Exemple #1
0
 public void VecinoClickeado(ButtonsGrid buttonsGrid)
 {
     if (this.number == 0 && !clicked)
     {
         clicked = true;
         var neighbors = buttonsGrid.GetNeighbors(this.pos[0], this.pos[1]);
         foreach (Model_button neighbor in neighbors)
         {
             neighbor.VecinoClickeado(buttonsGrid);
         }
     }
     else
     {
         SetClick();
     }
 }
Exemple #2
0
        public void setNumber(ButtonsGrid buttonsGrid)
        {
            if (number == -1)
            {
                return;
            }
            int n         = 0;
            var neighbors = buttonsGrid.GetNeighbors(this.pos[0], this.pos[1]);

            foreach (Model_button neighbor in neighbors)
            {
                if (neighbor.isBomb())
                {
                    n += 1;
                }
            }
            this.number = n;
        }
Exemple #3
0
 public bool Click(bool isLeftClick, ButtonsGrid buttonsGrid)
 {
     if (isLeftClick)
     {
         if (isBomb())
         {
             return(true);
         }
         else
         {
             if (flag == 1)
             {
                 return(false);
             }
             if (!clicked)
             {
                 clicked = true;
                 flag    = 0;
                 if (number == 0)
                 {
                     var neighbors = buttonsGrid.GetNeighbors(this.pos[0], this.pos[1]);
                     foreach (Model_button neighbor in neighbors)
                     {
                         neighbor.VecinoClickeado(buttonsGrid);
                     }
                 }
             }
         }
     }
     else
     {
         if (!isClicked())
         {
             flag = flag == 2 ? 0 : flag + 1;
         }
     }
     return(false);
 }
Exemple #4
0
 public Model(int filas, int columnas, int bombas)
 {
     buttonsGrid = new ButtonsGrid(filas, columnas, bombas);
 }