Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void BtnGuessNhor_Click(object sender, EventArgs e)
- {
- int minNhor = Convert.ToInt32(txbMinNumberNhor.Text);
- int maxNhor = Convert.ToInt32(txbMaxNumberNhor.Text);
- try
- {
- lblAnswerPrevGuessNhor.Text = guessNhor.ToString();
- answerNhor = Convert.ToInt32(lblAnsMysNumNhor.Text);
- guessNhor = Convert.ToInt32(txbMyGuessNhor.Text);
- }
- catch (Exception)
- {
- MessageBox.Show("Please fill in numbers");
- }
- if (guessNhor == answerNhor)
- {
- //play audio
- mciSendString("open \"" + Application.StartupPath
- + "\\..\\..\\Music\\"
- + "zapsplat_multimedia_game_sound_mallet_positive_advance_003_40873.mp3\" "
- + "type mpegvideo alias MediaFile",
- null, 0, IntPtr.Zero);
- mciSendString("play MediaFile", null, 0, IntPtr.Zero);
- attemptsWinNhor++;
- DialogResult = MessageBox.Show("You won! \nwins/losses: " + attemptsWinNhor + "/" + attemptsLoseNhor + "\nPlay again? ", "Winner", MessageBoxButtons.YesNo);
- }
- else if (guessNhor < answerNhor)
- {
- differenceNhor = answerNhor - guessNhor;
- }
- else if (guessNhor > answerNhor)
- {
- differenceNhor = guessNhor - answerNhor;
- }
- trbNhor.Maximum = maxNhor;
- trbNhor.Value = (maxNhor - differenceNhor);
- if (guessNhor < minNhor || guessNhor > maxNhor)
- {
- MessageBox.Show("Guessed number not between the min and max number");
- }
- pgbGuessesNhor.Value--;
- lblAnswerLeftNhor.Text = pgbGuessesNhor.Value.ToString();
- if (pgbGuessesNhor.Value == 0)
- {
- //play audio
- mciSendString("open \"" + Application.StartupPath
- + "\\..\\..\\Music\\"
- + "zapsplat_multimedia_game_sound_mallet_fall_descend_002_40840.mp3\" "
- + "type mpegvideo alias MediaFile",
- null, 0, IntPtr.Zero);
- mciSendString("play MediaFile", null, 0, IntPtr.Zero);
- attemptsLoseNhor++;
- DialogResult = MessageBox.Show("Game over!\nthe answer was " + lblAnsMysNumNhor.Text + "\nwins/losses: " + attemptsWinNhor + "/" + attemptsLoseNhor + "\nPlay Again?", "Loser", MessageBoxButtons.YesNo);
- }
- lblAnsDiffNhor.Text = differenceNhor.ToString();
- if (DialogResult == DialogResult.Yes)
- {
- RestartNhor();
- }
- else if (DialogResult == DialogResult.No)
- {
- this.Close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement