Ejemplo n.º 1
0
        }                                            //список использованных городов

        public ManagerClass(BaseOfWords baseW)
        {
            IndexPlayer = 0;
            ListPlayers = new List <Player>();
            UsedCities  = new List <string>();
            BaseWords   = baseW;
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            int cnt_players = 0;

            foreach (CheckBox checkBox in this.Controls.OfType <CheckBox>())
            {
                if (checkBox.Checked == true)
                {
                    cnt_players++;
                }
            }
            if (cnt_players < 2)
            {
                MessageBox.Show("Игроков должно быть минимум два!");
                return;
            }

            foreach (CheckBox checkBox in this.Controls.OfType <CheckBox>())
            {
                checkBox.Enabled = false;
            }

            label1.Enabled         = false;
            label2.Enabled         = false;
            numericUpDown1.Enabled = false;
            button2.Enabled        = true;
            button4.Enabled        = true;
            button1.Enabled        = false;
            groupBox1.Enabled      = true;

            //инициализация игры
            baseWords    = new BaseOfWords();
            managerClass = new ManagerClass(baseWords);
            myTimer      = new Timer(managerClass, Convert.ToInt32(numericUpDown1.Value));
            foreach (TextBox textBox in this.Controls.OfType <TextBox>())
            {
                if (textBox.Enabled == true)
                {
                    if (textBox.Text == "")
                    {
                        managerClass.ListPlayers.Add(new Player(textBox.Name + " Player"));
                    }
                    else
                    {
                        managerClass.ListPlayers.Add(new Player(textBox.Text));
                    }
                }
            }
            label6.Text = managerClass.ListPlayers[0].Name;
            label3.Text = numericUpDown1.Value.ToString();
            label7.Text = "";

            string results = "";

            for (int i = 0; i < managerClass.ListPlayers.Count; i++)
            {
                results += managerClass.ListPlayers[i].Name + ": " + managerClass.ListPlayers[i].points.ToString() + "\n";
            }
            label9.Text = results;

            timer1.Start();

            foreach (TextBox textBox in this.Controls.OfType <TextBox>())
            {
                textBox.Enabled = false;
            }
        }