示例#1
0
        private void start_Click(object sender, EventArgs e)
        {
            KelasMain main = new KelasMain();

            main.Show();
            this.Hide();
        }
示例#2
0
        private void back_Click(object sender, EventArgs e)
        {
            updatenyawa();
            KelasMain main = new KelasMain();

            main.Show();
            this.Hide();
        }
示例#3
0
        private void btnjwb_Click(object sender, EventArgs e)
        {
            int    jml    = File.ReadAllLines("pertanyaan.txt").Count();
            string gambar = File.ReadAllLines("pertanyaan.txt").Skip(x).Take(x + 1).First();

            char[]   delim         = { '#' };
            string[] picture       = gambar.Split(delim);
            string   jawaban       = jwb.Text;
            bool     statusjawaban = cekJawaban(jawaban, picture); //cek apakah jawaban benar atau salah

            if (statusjawaban == true)
            {
                FileStream   fs   = new FileStream("level.txt", FileMode.Open, FileAccess.Read);
                StreamReader sr   = new StreamReader(fs);
                string       line = sr.ReadLine();
                int          cek  = Convert.ToInt16(line);
                while (line != null)
                {
                    line = sr.ReadLine();
                }
                sr.Close();
                fs.Close();
                if (x != jml - 1)
                {
                    MessageBox.Show("Your answer is correct");
                    if ((cek - 1) == x)
                    {
                        update();
                        x++;
                        SetImage();
                        KelasMain level = new KelasMain();
                        level.Show();
                        this.Close();
                    }
                    else
                    {
                        KelasMain level = new KelasMain();
                        level.Show();
                        this.Close();
                    }
                }
                else if (x == jml - 1)
                {
                    MessageBox.Show("Congratulation you won!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    var msg = MessageBox.Show("You wanna try this again", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (msg == DialogResult.Yes)
                    {
                        updatebalik();
                        Menu menu = new Menu();
                        menu.Show();
                        this.Close();
                    }
                    else
                    {
                        updatebalik();
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Your Answer is correct");
                    KelasMain level = new KelasMain();
                    level.Show();
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Your answer is incorrect");
                jwb.Text       = "";
                btnhps.Enabled = false;
                ceknyawa--; // cek nyawa
                if (ceknyawa == 3)
                {
                }
                if (ceknyawa == 2)
                {
                    updatenyawa();
                    live3.Visible = false;
                }
                if (ceknyawa == 1)
                {
                    updatenyawa();
                    live3.Visible = false;
                    live2.Visible = false;
                }
                if (ceknyawa == 0)
                {
                    updatenyawabalik();
                    live3.Visible = false;
                    live2.Visible = false;
                    live1.Visible = false;
                    MessageBox.Show("Your live exhausted!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    var ulang = MessageBox.Show("You wanna try this game again ?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (ulang == DialogResult.Yes)
                    {
                        Menu menu = new Menu();
                        menu.Show();
                        this.Close();
                    }
                    else
                    {
                        this.Close();
                    }
                }
            }
        }