コード例 #1
0
ファイル: Form1.cs プロジェクト: Just-Supp0rt/trat
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(comboBox1.Text))
            {
                MessageBox.Show("Musíte si vybrat auto");
            }
            else if (string.IsNullOrEmpty(textBox1.Text))
            {
                if (comboBox1.Text == "LOGO DPE3" || comboBox1.Text == "Auto")
                {
                    MessageBox.Show("TBA");
                }

                else
                {
                    Hide();
                    if (comboBox1.Text == "Auto")
                    {
                        proměnná = "Auto";
                    }

                    if (comboBox1.Text == "LOGO DPE3")
                    {
                        proměnná = "Logo";
                    }

                    if (comboBox1.Text == "Mašinka tomáš")
                    {
                        proměnná = "Mašinka";
                    }
                    Form2 secondForm = new Form2(proměnná);


                    secondForm.ShowDialog();
                    Close();
                }
            }
            else
            {
                if (comboBox1.Text == "LOGO DPE3" || comboBox1.Text == "Auto")
                {
                    MessageBox.Show("TBA");
                }

                else
                {
                    if (textBox1.Text == "svíčka") // level 3
                    {
                        Hide();
                        if (comboBox1.Text == "Auto")
                        {
                            proměnná = "Auto";
                        }
                        if (comboBox1.Text == "LOGO DPE3")
                        {
                            proměnná = "LOGO DPE3";
                        }
                        if (comboBox1.Text == "Mašinka tomáš")
                        {
                            proměnná = "Mašinka";
                        }
                        Form3 thirdForm = new Form3(proměnná);
                        thirdForm.ShowDialog();
                        Close();
                    }
                    if (textBox1.Text == "Civ") // level 4
                    {
                        Hide();
                        if (comboBox1.Text == "Auto")
                        {
                            proměnná = "Auto";
                        }
                        if (comboBox1.Text == "LOGO DPE3")
                        {
                            proměnná = "LOGO DPE3";
                        }
                        if (comboBox1.Text == "Mašinka tomáš")
                        {
                            proměnná = "Mašinka";
                        }
                        Form4 FourthForm = new Form4(proměnná);
                        FourthForm.ShowDialog();
                        Close();
                    }
                    if (!string.IsNullOrEmpty(textBox1.Text))
                    {
                        MessageBox.Show("Špatný kód");
                    }
                }
            }
        }
コード例 #2
0
        private void Form2_Paint(object sender, PaintEventArgs e)
        {
            if (proměnn == "Auto")
            {
                obrazek = Resources.E3;
            }

            else if (proměnn == "Mašinka")
            {
                obrazek = Resources.train;
            }
            Graphics k = e.Graphics;

            Rectangle image      = new Rectangle(x + 1, y + 1, 49, 49); //obdelnik pod obrazkem
            Rectangle Obstacle   = new Rectangle(100, 100, 1, 150);     //záčatek startu dolu
            Rectangle Obstacle2  = new Rectangle(100, 100, 100, 1);
            Rectangle Obstacle3  = new Rectangle(100, 250, 100, 1);
            Rectangle Obstacle4  = new Rectangle(200, 250, 400, 1); //spodní dlouhá
            Rectangle Obstacle5  = new Rectangle(600, 100, 1, 150); //finish
            Rectangle Obstacle6  = new Rectangle(200, 100, 1, 150); //start
            Rectangle Obstacle7  = new Rectangle(200, 100, 400, 1); //horní dlouhá
            Rectangle Obstacle8  = new Rectangle(600, 100, 100, 1);
            Rectangle Obstacle9  = new Rectangle(700, 100, 1, 150);
            Rectangle Obstacle10 = new Rectangle(600, 250, 100, 1);



            k.DrawRectangle(Pens.Transparent, image);
            k.DrawRectangle(Pens.Blue, Obstacle);
            k.DrawRectangle(Pens.Blue, Obstacle2);
            k.DrawRectangle(Pens.Blue, Obstacle2);
            k.DrawRectangle(Pens.Blue, Obstacle3);
            k.DrawRectangle(Pens.Blue, Obstacle4);
            k.DrawRectangle(Pens.Red, Obstacle5);
            k.DrawRectangle(Pens.Red, Obstacle6);
            k.DrawRectangle(Pens.Blue, Obstacle7);
            k.DrawRectangle(Pens.Blue, Obstacle8);
            k.DrawRectangle(Pens.Blue, Obstacle9);
            k.DrawRectangle(Pens.Blue, Obstacle10);

            k.DrawImage(obrazek, x, y, 50, 50);
            if (image.IntersectsWith(Obstacle) || image.IntersectsWith(Obstacle2) || image.IntersectsWith(Obstacle3) || image.IntersectsWith(Obstacle4) || image.IntersectsWith(Obstacle7) || image.IntersectsWith(Obstacle8) || image.IntersectsWith(Obstacle9) || image.IntersectsWith(Obstacle10))
            {
                x      = 130;
                y      = 150;
                xposun = 0;
                yposun = 0;
                if (hudba == "nebude nikdy hrát")
                {
                }
                else
                {
                    hudba = "nehraje";
                }
                _soundPlayer.Stop();
                MessageBox.Show("Vážně jsi nezvládl tu nejlhečí trať?");
            }

            if (image.IntersectsWith(Obstacle5))
            {
                x     = 130;
                y     = 150;
                hudba = "nehraje";
                _soundPlayer.Stop();
                xposun = 0;
                yposun = 0;
                MessageBox.Show("Zvládnul jsi první level");
                Hide();
                Form3 thirdForm = new Form3(proměnn);
                thirdForm.ShowDialog();
                Close();
            }
        }