private void fGame_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData == Keys.A) { GamePause(); fMessage fm = new fMessage(); fm.label1.Text = "Player 1"; if (fm.ShowDialog() == DialogResult.Yes) { lblCounter1.Text = Convert.ToString(Convert.ToInt32(lblCounter1.Text) + 1); MakeMusic(); } GamePlay(); } if (e.KeyData == Keys.P) { fMessage fm = new fMessage(); fm.label1.Text = "Player 2"; if (fm.ShowDialog() == DialogResult.Yes) { lblCounter2.Text = Convert.ToString(Convert.ToInt32(lblCounter2.Text) + 1); MakeMusic(); } GamePlay(); } }
private void fGame_KeyDown(object sender, KeyEventArgs e) { if (!timer1.Enabled) { return; } if (answerEnabled[0] && e.KeyData == (Keys)GameEngine.answerKey1) { GamePause(); fMessage fm = new fMessage(); fm.lblPlayerName.Text = GameEngine.playerName1; answerEnabled[0] = false; if (fm.ShowDialog() == DialogResult.Yes) { lblPlayerPoint1.Text = Convert.ToString(Convert.ToInt32(lblPlayerPoint1.Text) + 1); MakeMusic(); } GamePlay(); } if (answerEnabled[1] && e.KeyData == (Keys)GameEngine.answerKey2) { GamePause(); fMessage fm = new fMessage(); fm.lblPlayerName.Text = GameEngine.playerName2; answerEnabled[1] = false; if (fm.ShowDialog() == DialogResult.Yes) { lblPlayerPoint2.Text = Convert.ToString(Convert.ToInt32(lblPlayerPoint2.Text) + 1); MakeMusic(); } GamePlay(); } }
private void fGame_KeyDown(object sender, KeyEventArgs e) { if (!timer1.Enabled) { return; } if (players[0] == false && e.KeyData == Keys.A) { GamePause(); players[0] = true; fMessage fm = new fMessage(); fm.lblMessage.Text = "Is Player 1 right?"; if (fm.ShowDialog() == DialogResult.Yes) { lblCounter1.Text = Convert.ToString(Convert.ToInt32(lblCounter1.Text) + 1); MakeMusic(); } GamePlay(); } if (players[1] == false && e.KeyData == Keys.L) { GamePause(); players[1] = true; fMessage fm = new fMessage(); fm.lblMessage.Text = "Is Player 2 right?"; if (fm.ShowDialog() == DialogResult.Yes) { lblCounter2.Text = Convert.ToString(Convert.ToInt32(lblCounter2.Text) + 1); MakeMusic(); } GamePlay(); } }
private void fGame_KeyDown(object sender, KeyEventArgs e) { if (!timer1.Enabled) { return; } if (players[0] == false && e.KeyData == Keys.A) { GamePause(); fMessage fm = new fMessage(); fm.lblMessage.Text = "Игрок 1 угадал?"; players[0] = true; if (fm.ShowDialog() == DialogResult.Yes) { lblCounter1.Text = Convert.ToString(Convert.ToInt64(lblCounter1.Text) + 1); if (Buffer.list.Count == 0) { play1 = Convert.ToString(Convert.ToInt64(play1) + 1); } MakeMusic(); } GamePlay(); } if (players[1] == false && e.KeyData == Keys.L) { GamePause(); fMessage fm = new fMessage(); fm.lblMessage.Text = "Игрок 2 угадал?"; players[1] = true; if (fm.ShowDialog() == DialogResult.Yes) { lblCounter2.Text = Convert.ToString(Convert.ToInt64(lblCounter2.Text) + 1); if (Buffer.list.Count == 0) { play2 = Convert.ToString(Convert.ToInt64(play2) + 1); } MakeMusic(); } GamePlay(); } play1 = lblCounter1.Text; play2 = lblCounter2.Text; }
private void fGame_KeyDown(object sender, KeyEventArgs e) { if (!timer1.Enabled) { return; } if (players[0] == false && e.KeyData == Keys.A) { GamePause(); fMessage fm = new fMessage(); fm.lblMessage.Text = "Игрок 1"; //SoundPlayer sp = new SoundPlayer("Resources\\Windows_Background.wav"); //sp.PlaySync(); players[0] = true; if (fm.ShowDialog() == DialogResult.Yes) { lblCounter1.Text = Convert.ToString(Convert.ToInt32(lblCounter1.Text) + 1); MakeMusic(); players[0] = false; players[1] = false; } GamePlay(); } if (players[1] == false && e.KeyData == Keys.P) { GamePause(); fMessage fm = new fMessage(); fm.lblMessage.Text = "Игрок 2"; //SoundPlayer sp = new SoundPlayer("Resources\\Windows_Foreground.wav"); //sp.PlaySync(); players[1] = true; if (fm.ShowDialog() == DialogResult.Yes) { lblCounter2.Text = Convert.ToString(Convert.ToInt32(lblCounter2.Text) + 1); MakeMusic(); players[0] = false; players[1] = false; } GamePlay(); } }
// когда на клавеатуре нажимаем на любую кнопку, при этом окно программы должно быть активным private void fGame_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData == Keys.A) { if (timer.Enabled == false) { return; } GamePause(); fMessage fm = new fMessage(); fm.label_player.Text = "Player 1"; if (fm.ShowDialog() == DialogResult.Yes) { label_firstPlayer.Text = Convert.ToString(Convert.ToInt32(label_firstPlayer.Text) + 1); MakeMusic(); } GamePlay(); } if (e.KeyData == Keys.P) { if (timer.Enabled == false) { return; } GamePause(); fMessage fm = new fMessage(); fm.label_player.Text = "Player 2"; if (fm.ShowDialog() == DialogResult.Yes) // инкрементируем счетчик очков у данного игрока { label_secondPlayer.Text = Convert.ToString(Convert.ToInt32(label_secondPlayer.Text) + 1); MakeMusic(); } GamePlay(); } }
private void fGame_KeyDown(object sender, KeyEventArgs e) { if (!timer1.Enabled) return; if (answerEnabled[0] && e.KeyData == (Keys)GameEngine.answerKey1) { GamePause(); fMessage fm = new fMessage(); fm.lblPlayerName.Text = GameEngine.playerName1; answerEnabled[0] = false; if (fm.ShowDialog() == DialogResult.Yes) { lblPlayerPoint1.Text = Convert.ToString(Convert.ToInt32(lblPlayerPoint1.Text) + 1); MakeMusic(); } GamePlay(); } if (answerEnabled[1] && e.KeyData == (Keys)GameEngine.answerKey2) { GamePause(); fMessage fm = new fMessage(); fm.lblPlayerName.Text = GameEngine.playerName2; answerEnabled[1] = false; if (fm.ShowDialog() == DialogResult.Yes) { lblPlayerPoint2.Text = Convert.ToString(Convert.ToInt32(lblPlayerPoint2.Text) + 1); MakeMusic(); } GamePlay(); } }