Beispiel #1
0
        private void button9_Click(object sender, EventArgs e)
        {
            string name = name_player.Text;



            if (name_player.Text == "")
            {
                MessageBox.Show("u must fill that text ");
            }
            else
            {
                player p = new player();


                counter_of_players--;
                dice d = new dice();

                int a = d.roll_dice();
                int b = d.roll_dice();

                int sum = a + b;



                p.set_name(name);
                p.set_position(sum);
                //
                map.Add(p);
                if (a == 6)
                {
                    panel54.BackgroundImage = Image.FromFile(@"dices\dice(6).png");
                }
                else if (a == 5)
                {
                    panel54.BackgroundImage = Image.FromFile(@"dices\dice(5).png");
                }
                else if (a == 4)
                {
                    panel54.BackgroundImage = Image.FromFile(@"dices\dice(4).png");
                }
                else if (a == 3)
                {
                    panel54.BackgroundImage = Image.FromFile(@"dices\dice(3).png");
                }
                else if (a == 2)
                {
                    panel54.BackgroundImage = Image.FromFile(@"dices\dice(2).png");
                }
                else if (a == 1)
                {
                    panel54.BackgroundImage = Image.FromFile(@"dices\dice(1).png");
                }


                if (b == 6)
                {
                    panel55.BackgroundImage = Image.FromFile(@"dices\dice(6).png");
                }
                else if (b == 5)
                {
                    panel55.BackgroundImage = Image.FromFile(@"dices\dice(5).png");
                }
                else if (b == 4)
                {
                    panel55.BackgroundImage = Image.FromFile(@"dices\dice(4).png");
                }
                else if (b == 3)
                {
                    panel55.BackgroundImage = Image.FromFile(@"dices\dice(3).png");
                }
                else if (b == 2)
                {
                    panel55.BackgroundImage = Image.FromFile(@"dices\dice(2).png");
                }
                else if (b == 1)
                {
                    panel55.BackgroundImage = Image.FromFile(@"dices\dice(1).png");
                }
                view_list = new ListViewItem(name_player.Text);
                view_list.SubItems.Add(sum.ToString());

                listView1.Items.Add(view_list);
            }

            name_player.Text = "";



            if (counter_of_players == 0)
            {
                map.Sort();
                for (int i = 0; i < map.Count; i++)
                {
                    map[i].set_position(0);
                    map[i].set_money(1200);
                    map[i].set_first_time_to_roll_done(false);
                    map[i].set_In_jail_now(false);
                    map[i].set_Was_in_jail(false);
                }
                game.first_initialize(map);
                if (map.Count == 2)
                {
                    pictureBox1.Location = new Point(x, y);
                    pictureBox2.Location = new Point(x, y);
                    pictureBox3.Visible  = false;
                    pictureBox4.Visible  = false;
                    pictureBox5.Visible  = false;
                    pictureBox6.Visible  = false;
                    pictureBox7.Visible  = false;
                    pictureBox8.Visible  = false;
                }
                else if (map.Count == 3)
                {
                    pictureBox1.Location = new Point(x, y);
                    pictureBox2.Location = new Point(x, y);
                    pictureBox3.Location = new Point(x, y);
                    pictureBox4.Visible  = false;
                    pictureBox5.Visible  = false;
                    pictureBox6.Visible  = false;
                    pictureBox7.Visible  = false;
                    pictureBox8.Visible  = false;
                }
                else if (map.Count == 4)
                {
                    pictureBox1.Location = new Point(x, y);
                    pictureBox2.Location = new Point(x, y);
                    pictureBox3.Location = new Point(x, y);
                    pictureBox4.Location = new Point(x, y);
                    pictureBox5.Visible  = false;
                    pictureBox6.Visible  = false;
                    pictureBox7.Visible  = false;
                    pictureBox8.Visible  = false;
                }
                else if (map.Count == 5)
                {
                    pictureBox1.Location = new Point(x, y);
                    pictureBox2.Location = new Point(x, y);
                    pictureBox3.Location = new Point(x, y);
                    pictureBox4.Location = new Point(x, y);
                    pictureBox5.Location = new Point(x, y);
                    pictureBox6.Visible  = false;
                    pictureBox7.Visible  = false;
                    pictureBox8.Visible  = false;
                }
                else if (map.Count == 6)
                {
                    pictureBox1.Location = new Point(x, y);
                    pictureBox2.Location = new Point(x, y);
                    pictureBox3.Location = new Point(x, y);
                    pictureBox4.Location = new Point(x, y);
                    pictureBox5.Location = new Point(x, y);
                    pictureBox6.Location = new Point(x, y);
                    pictureBox7.Visible  = false;
                    pictureBox8.Visible  = false;
                }
                else if (map.Count == 7)
                {
                    pictureBox1.Location = new Point(x, y);
                    pictureBox2.Location = new Point(x, y);
                    pictureBox3.Location = new Point(x, y);
                    pictureBox4.Location = new Point(x, y);
                    pictureBox5.Location = new Point(x, y);
                    pictureBox6.Location = new Point(x, y);
                    pictureBox7.Location = new Point(x, y);
                    pictureBox8.Visible  = false;
                }
                else if (map.Count == 8)
                {
                    pictureBox1.Location = new Point(x, y);
                    pictureBox2.Location = new Point(x, y);
                    pictureBox3.Location = new Point(x, y);
                    pictureBox4.Location = new Point(x, y);
                    pictureBox5.Location = new Point(x, y);
                    pictureBox6.Location = new Point(x, y);
                    pictureBox7.Location = new Point(x, y);
                    pictureBox8.Location = new Point(x, y);
                }
                button10.Visible    = true;
                label22.Visible     = false;
                name_player.Visible = false;
                button9.Visible     = false;
                panel54.Visible     = false;
                panel55.Visible     = false;
            }
        }