private void Timer_2Answer_Tick(object sender, EventArgs e) { if (countDownTimer2 != 0) { lab_Anuncios.Text = Convert.ToString(countDownTimer2); countDownTimer2--; } else { countDownTimer2 = time2Answer; Timer_2Answer.Stop(); lab_correctWrong(0); // Cambio de Jugador if (turno == 1) { countDown.Start(); turno = 2; //Player 2 } else { countDown.Start(); turno = 1; //Player 1 } } }
private void btn_goToMain_Click(object sender, EventArgs e) { // para saber si el formulario existe, o sea, si está abierto o cerrado Form existe = Application.OpenForms.OfType <Form>().Where(pre => pre.Name == "P_Main").SingleOrDefault <Form>(); existe.Show(); Timer_2Answer.Stop(); sonido.Stop(); this.Close(); //Esto cierra la ventana del juego y va a Main }
void perder_Ganar() { //condicion para perder if (lifes_1 == 0 || lifes_2 == 0 || ((countUp == noRepetir_PorDificultad.Length) && (difficulty != "All"))) { Timer_2Answer.Stop(); //detener conteo reproducirSonido("game-over.wav", false); if (round == numRounds) // si es el ultimo round { Thread.Sleep(1500); //condicion para saber quien perdió if (turno == 1) { //MessageBox.Show(lab_Player1.Text + " Lose!\n\n" + lab_Player2.Text + " Wins\nLifes: " + lifes_2 + "\nScore: " + score_2); BannerStart(lab_Player2.Text + " Wins"); } else { //MessageBox.Show(lab_Player1.Text + " Lose!\n\n" + lab_Player2.Text + " Wins\nLifes: " + lifes_2 + "\nScore: " + score_2); BannerStart(lab_Player1.Text + " Wins"); } } else if (((countUp == noRepetir_PorDificultad.Length) && (difficulty != "All"))) // si se acaban las preguntas, se acaba el juego { Thread.Sleep(1500); //condicion para saber quien perdió if (score_1 == score_2) { BannerStart("It's a Draw!"); } else if (score_2 > score_1) { //MessageBox.Show(lab_Player1.Text + " Lose!\n\n" + lab_Player2.Text + " Wins\nLifes: " + lifes_2 + "\nScore: " + score_2); BannerStart(lab_Player2.Text + " Wins"); } else { //MessageBox.Show(lab_Player1.Text + " Lose!\n\n" + lab_Player2.Text + " Wins\nLifes: " + lifes_2 + "\nScore: " + score_2); BannerStart(lab_Player1.Text + " Wins"); } } else { ChangeRound(); } } }
void BannerStart(string banner) { Thread.Sleep(2000); Timer_2Answer.Stop(); sonido.Stop(); this.banner = banner; Banner = new Banners(banner); Banner.Show(); Timer_Banner.Start(); if (banner == "Round " + round) // solo se reproduce el sonido si es un cambio de round { reproducirSonido("start-ready-go.wav", false); } }
void StartAgan() { if ((round == numRounds && banner != "Round " + round) || ((countUp == noRepetir_PorDificultad.Length) && (difficulty != "All"))) // significa que el juego ha terminado { Timer_2Answer.Stop(); sonido.Stop(); DialogResult respuesta = MessageBox.Show("The Game has Finished!\nDo you want to Play Again?", "Game Over", MessageBoxButtons.YesNo); if (respuesta == DialogResult.Yes) { reproducirSonido("start-ready-go.wav", false); Thread.Sleep(700); restart = true; reset_PlayAgain(); Banner.Hide(); } else { Application.Exit(); } } }
void reset_PlayAgain() { Timer_2Answer.Stop(); //detener conteo countDownTimer = 3; countDownTimer2 = time2Answer; countDownTimer3 = 2; if (restart == true) { restart = false; i = 0; countUp = 0; enumerate = 1; // para ponerle número a las preguntas round = 1; turno = 1; wins_01 = 0; wins_02 = 0; score_1 = 0; score_2 = 0; passage = ""; lab_Rounds_Left.Text = round + "/" + numRounds; lab_Rounds_Right.Text = round + "/" + numRounds; lab_Wins_P1.Text = Convert.ToString(wins_01); lab_Wins_P2.Text = Convert.ToString(wins_02); Array.Clear(noRepetir, 0, noRepetir.Length); // vaciar arreglo Array.Clear(noRepetir_PorDificultad, 0, noRepetir_PorDificultad.Length); // vaciar arreglo } lifes_1 = 3; lifes_2 = 3; countDownComodin_1 = 3; countDownComodin_2 = 3; countDownPassage_1 = 3; countDownPassage_2 = 3; Lab_Passage_Shown_1.Text = ""; Timer_2Answer.Start(); if (banner == lab_Player1.Text + " Wins" || banner == lab_Player2.Text + " Wins" || banner == "It's a Draw!") { AfterCountDown(true); banner = "Round" + round; // resetear banner } lab_LifesNum.Text = Convert.ToString(lifes_1); lab_LifesNum2.Text = Convert.ToString(lifes_2); lab_ScoreNum.Text = Convert.ToString(score_1); lab_ScoreNum2.Text = Convert.ToString(score_2); lab_50_1.Text = "+3"; lab_50_2.Text = "+3"; pbx_50_1.Enabled = true; pbx_50_2.Enabled = true; lab_50_1.Enabled = true; lab_50_2.Enabled = true; lab_Passage_1.Text = "+3"; lab_Passage_2.Text = "+3"; pbx_Passage_1.Enabled = true; pbx_Passage_2.Enabled = true; lab_Passage_1.Enabled = true; lab_Passage_2.Enabled = true; pbx_Passage_1.Image = Properties.Resources.Passage_Mouse_Leave; pbx_Passage_2.Image = Properties.Resources.Passage_Mouse_Leave; }
private void RestartTimer_2Answer() { Timer_2Answer.Stop(); countDownTimer2 = time2Answer; }