private void gameForm_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Escape) { timer.Stop(); WMP.Ctlcontrols.stop(); this.Close(); } if (timer.Enabled) { if (!players[0] && e.KeyData == Keys.A) { PauseGame(); PauseVisualization(); messageForm message = new messageForm(); message.Text = "Player #1"; if (message.ShowDialog() == DialogResult.Yes) { score1Label.Text = (int.Parse(score1Label.Text) + 1).ToString(); MakeMusic(); musicCountLabel.Text = Quiz.musicList.Count.ToString(); } players[0] = true; ResumeGame(); ResumeVisualization(); } if (!players[1] && e.KeyData == Keys.P) { PauseGame(); PauseVisualization(); messageForm message = new messageForm(); message.Text = "Player #2"; if (message.ShowDialog() == DialogResult.Yes) { score2Label.Text = (int.Parse(score2Label.Text) + 1).ToString(); MakeMusic(); musicCountLabel.Text = Quiz.musicList.Count.ToString(); } players[1] = true; ResumeGame(); ResumeVisualization(); } } }
private void answer(string player) { pauseGame(); messageForm mf = new messageForm(); mf.setPlayer(player); mf.setRightAnswer(currentMelody); if (mf.ShowDialog() == DialogResult.Yes) { SoundPlayer sound = new SoundPlayer("Resources\\Yes.wav"); sound.Play(); changeScore(player, 1); makeMusic(); } else { SoundPlayer sound = new SoundPlayer("Resources\\No.wav"); sound.Play(); } continueGame(); }