void End(User winner, User loser) // used in 2p mode { double tpq1 = 0, tpq2 = 0; foreach (double qtime in TPQList1) { tpq1 += qtime; } tpq1 = tpq1 / TPQList1.Count; foreach (double qtime in TPQList2) { tpq2 += qtime; } tpq2 = tpq2 / TPQList2.Count; _activeUsers[0].CalcTPQ(tpq1); _activeUsers[1].CalcTPQ(tpq2); quizTimer.Stop(); questionTimer1.Stop(); questionTimer2.Stop(); winner.AddGame(quizTimer.Elapsed.TotalSeconds); loser.AddGame(); CoverLabel1.Text = CoverLabel2.Text = winner.Username + " Wins!"; CoverLabel1.ForeColor = CoverLabel2.ForeColor = Color.White; UpdateScreenTimer.Stop(); CoverLabel1.Show(); CoverLabel2.Show(); countdown = 0; EndWaitTimer.Start(); }
private void CountdownTimer_Tick(object sender, EventArgs e) { countdown--; if (countdown <= 0) { CoverLabel1.Visible = false; CoverLabel1.Text = CoverLabel2.Text = ""; if (_activeUsers.Length == 2) { CoverLabel2.Visible = false; QM2 = new QuestionMaker(); // creating this here allows the random objects in each QuestionMaker to use different seeds, as they are dependent on time } CountdownTimer.Stop(); CountdownTimer.Dispose(); quizTimer.Start(); UpdateScreenTimer_Tick(this, EventArgs.Empty);// creates a new question instantly, eliminating the possibility that a button is pressed before the timer ticks, which would cause errors UpdateScreenTimer.Start(); return; } CoverLabel1.Text = countdown.ToString(); CoverLabel2.Text = CoverLabel1.Text; if (_sfx) { SystemSounds.Beep.Play(); } }
void End() // used in 1p mode { double tpq1 = 0; foreach (double qtime in TPQList1) { tpq1 += qtime; } tpq1 = tpq1 / TPQList1.Count; _activeUsers[0].CalcTPQ(tpq1); quizTimer.Stop(); questionTimer1.Stop(); UpdateScreenTimer.Stop(); //stopping the program from checking if the user is finished _activeUsers[0].AddGame(quizTimer.Elapsed.TotalSeconds); //writing to file CoverLabel1.Text = CoverLabel2.Text = "You did it!"; CoverLabel1.ForeColor = CoverLabel2.ForeColor = Color.White; CoverLabel1.Show(); CoverLabel2.Show(); countdown = 0; EndWaitTimer.Start(); }