Exemple #1
0
        public void ShowAllBum(MineBox[] MinB)
        {
            for (int i = 0; i < X * Y; i++)
            {
                if (BoxPole[i] == 9 && MinB[i].Enabled == true && Flags[i] != 1)
                    MinB[i].Fmine(false);
                else if (BoxPole[i] != 9 && MinB[i].Enabled == true && Flags[i] == 1)
                    MinB[i].FErrFlag();
                else if (BoxPole[i] != 9 && Flags[i] != 1)
                    MinB[i].Fnum(BoxPole[i]);

            }
        }
Exemple #2
0
 public void ShowAllV(MineBox[] MinB)
 {
     for (int i = 0; i < X * Y; i++)
     {
         if (MinB[i].Enabled == true && Flags[i] != 1)
         {
             Flags[i] = 1;
             NumFlag--;
             MinB[i].FflagSet();
         }
     }
 }
Exemple #3
0
        public void SetFlag(MineBox Box)
        {
            int i = Box.TabIndex;
            if (Flags[i] == 1)
            {
                Box.FflagDel();
                Flags[i] = 0;
                this.NumFlag += 1;
            }

            else if (Flags[i] != 1 && this.NumFlag > 0)
            {
                Box.FflagSet();
                Flags[i] = 1;
                this.NumFlag -= 1;
            }
        }
Exemple #4
0
 public int ReturnNum(MineBox Box)
 {
     int i = Box.TabIndex;
     return BoxPole[i];
 }
Exemple #5
0
 public void EmptyBox(MineBox Box, MineBox[] MBox)
 {
     int i = Box.TabIndex;
     Box.Fnum(ReturnNum(Box));
     OpenBox++;
     if (i % X != X - 1)
     {
         if (ReturnNum(MBox[i + 1]) == 0 && MBox[i + 1].Enabled == true)
         {
             EmptyBox(MBox[i + 1], MBox);
         }
         else if (MBox[i + 1].Enabled == true)
         {
             MBox[i + 1].Fnum(ReturnNum(MBox[i + 1]));
             OpenBox++;
         }
     }
     if (i + X < X * Y)
     {
         if (ReturnNum(MBox[i + X]) == 0 && MBox[i + X].Enabled == true)
             EmptyBox(MBox[i + X], MBox);
         else if (MBox[i + X].Enabled == true)
         {
             MBox[i + X].Fnum(ReturnNum(MBox[i + X]));
             OpenBox++;
         }
     }
     if (i % X != 0)
     {
         if (ReturnNum(MBox[i - 1]) == 0 && MBox[i - 1].Enabled == true)
             EmptyBox(MBox[i - 1], MBox);
         else if (MBox[i - 1].Enabled == true)
         {
             MBox[i - 1].Fnum(ReturnNum(MBox[i - 1]));
             OpenBox++;
         }
     }
     if (i - X >= 0)
     {
         if (ReturnNum(MBox[i - X]) == 0 && MBox[i - X].Enabled == true)
             EmptyBox(MBox[i - X], MBox);
         else if (MBox[i - X].Enabled == true)
         {
             MBox[i - X].Fnum(ReturnNum(MBox[i - X]));
             OpenBox++;
         }
     }
     if (i % X != X - 1 && i + X + 1 < X * Y)
     {
         if (ReturnNum(MBox[i + X + 1]) == 0 && MBox[i + X + 1].Enabled == true)
             EmptyBox(MBox[i + X + 1], MBox);
         else if (MBox[i + X + 1].Enabled == true)
         {
             MBox[i + X + 1].Fnum(ReturnNum(MBox[i + X + 1]));
             OpenBox++;
         }
     }
     if (i % X != 0 && i - X - 1 >= 0)
     {
         if (ReturnNum(MBox[i - X - 1]) == 0 && MBox[i - X - 1].Enabled == true)
             EmptyBox(MBox[i - X - 1], MBox);
         else if (MBox[i - X - 1].Enabled == true)
         {
             MBox[i - X - 1].Fnum(ReturnNum(MBox[i - X - 1]));
             OpenBox++;
         }
     }
     if (i % X != X - 1 && i - X + 1 >= 0)
     {
         if (ReturnNum(MBox[i - X + 1]) == 0 && MBox[i - X + 1].Enabled == true)
             EmptyBox(MBox[i - X + 1], MBox);
         else if (MBox[i - X + 1].Enabled == true)
         {
             MBox[i - X + 1].Fnum(ReturnNum(MBox[i - X + 1]));
             OpenBox++;
         }
     }
     if (i % X != 0 && i + X - 1 < X * Y)
     {
         if (ReturnNum(MBox[i + X - 1]) == 0 && MBox[i + X - 1].Enabled == true)
             EmptyBox(MBox[i + X - 1], MBox);
         else if (MBox[i + X - 1].Enabled == true)
         {
             MBox[i + X - 1].Fnum(ReturnNum(MBox[i + X - 1]));
             OpenBox++;
         }
     }
 }
Exemple #6
0
 public int Bum(MineBox Box, MineBox[] MBox)
 {
     int i = Box.TabIndex;
     if (Flags[i] != 1)
         if (ReturnNum(Box) == 9)
         {
             Box.Fmine(true);
             return 1;           // взрыв
         }
         else if (ReturnNum(Box) == 0)
         {
             EmptyBox(Box, MBox);   //пустая ячейка
             return 0;
         }
         else
         {
             Box.Fnum(ReturnNum(Box));    //ячейка с числом
             OpenBox++;
             return 0;
         }
     return 0;
 }
Exemple #7
0
 public void StartGame(int x, int y, int nf, int ng)
 {
     poleX = x;
     poleY = y;
     poleNM = nf;
     NumGame = ng;
     NumMineText.Text = nf.ToString();
     TimerText.Text = "00:00";
     TimerText.Location = new Point(x * 20 - 38, 0);
     NewGameBtn.Location = new Point(x * 10 - 10, 0);
     Pole.Width = x * 20 + 2;
     Pole.Height = y * 20 + 2;
     Morda.Width = x * 20 + 2;
     this.Width = x * 20 + 20;
     this.Height = y * 20 + 100;
     this.MB = new MineBox[x * y];
     int n = 0;
     for (int j = 0; j < y; j++)
         for (int i = 0; i < x; i++)
         {
             MB[n] = new MineBox();
             this.MB[n].Location = new System.Drawing.Point(20 * i, 20 * j);
             this.MB[n].Size = new System.Drawing.Size(20, 20);
             this.MB[n].Name = "MineBox " + n;
             this.MB[n].TabIndex = n;
             this.MB[n].TabStop = false;
             this.MB[n].MouseDown += new System.Windows.Forms.MouseEventHandler(Box_Click);
             Pole.Controls.Add(MB[n]);
             n++;
         }
     pole = new MinePole(x, y, nf);
 }