Esempio n. 1
0
        private void InitialNewGame()
        {
            timer.Stop();
            isStart = false;
            score   = 0;
            ScoreStatusLabel.Text      = "Score: " + score.ToString();
            ScoreStatusLabel.BackColor = default(Color);
            actualClicks             = 0;
            MyBottons.PushedButtons  = new List <int>();
            MyBottons.NotUsedButtoms = new List <int>();


            buttons = new MyBottons[boardSize * boardSize];
            tableLayoutPanel1.Controls.Clear();
            tableLayoutPanel1.ColumnCount = boardSize;
            tableLayoutPanel1.ColumnStyles.Clear();
            tableLayoutPanel1.RowStyles.Clear();
            for (int i = 0; i < boardSize; i++)
            {
                for (int j = 0; j < boardSize; j++)
                {
                    buttons[i * boardSize + j] = new MyBottons(i * boardSize + j, round);
                    tableLayoutPanel1.Controls.Add(buttons[i * boardSize + j], i, j);
                    buttons[i * boardSize + j].Click += MyBottons_Click;
                    //MyBottons.NotUsedButtoms.Add(i * boardSize + j);
                }
                tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 1));
                tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 1));
            }
            buttonStart.Text = "Start";
        }
Esempio n. 2
0
        public void MyBottons_Click(object sender, EventArgs e)
        {
            if (!isStart)
            {
                return;
            }
            MyBottons mb = (MyBottons)sender;

            if (mb.BackColor == Color.Blue)
            {
                score       += 50;
                mb.BackColor = Color.AliceBlue;
                MyBottons.PushedButtons.Remove(mb.number);
                MyBottons.NotUsedButtoms.Add(mb.number);
                ScoreStatusLabel.BackColor = default(Color);
            }
            else
            {
                score -= 100;
                ScoreStatusLabel.BackColor = Color.Red;
            }
            ScoreStatusLabel.Text = "Score: " + score.ToString();
            if (++actualClicks >= clicksToEnd)
            {
                EndOfGame();
            }
        }