Ejemplo n.º 1
0
        private void Action2(int x, int y, Button btn, int poz)
        {
            if (!Settings.GameOver)
            {
                if ((table[x, y] >= 1) && (table[x, y] <= 5))
                {
                    btn.BackColor = Color.Gainsboro;
                    btn.Text      = table[x, y].ToString();
                    btn.Enabled   = false;
                }
                else
                if (table[x, y] == 7)
                {
                    Settings.GameOver = true;
                    btn.BackColor     = Color.Firebrick;
                    Timer.Enabled     = false;
                    DeactivateButtons();
                    ShowBombs();
                    Lose l = new Lose(TimeLabel.Text);
                    l.Show();
                    Final.Enabled = true;
                }
                else
                {
                    if (table[x, y] == 0)
                    {
                        fill(x, y, poz);
                        for (int i = 0; i < Buttons.Count(); i++)
                        {
                            if (table[Buttons[i].i, Buttons[i].j] == 8)
                            {
                                Buttons[i].b.BackColor   = Color.Gainsboro;
                                Buttons[i].b.Enabled     = false;
                                Buttons[i].ButtonPressed = true;
                            }
                        }
                        for (int i = 0; i < Points.Count(); i++)
                        {
                            int    pozz = Points[i].Poz;
                            int    cx   = Points[i].X;
                            int    cy   = Points[i].Y;
                            Button bt   = Buttons[pozz].b;
                            bt.Text      = table[cx, cy].ToString();
                            bt.Enabled   = false;
                            bt.BackColor = Color.Gainsboro;
                            Buttons[pozz].ButtonPressed = true;
                        }
                    }
                }

                if (CheckWin())
                {
                    Timer.Enabled = false;
                    ShowBombs();
                    DeactivateButtons();
                    Win w = new Win(TimeLabel.Text);
                    w.Show();
                    Final.Enabled = true;
                }
            }
        }