public void Results(bool levelCleared) { int score; timer1.Stop(); TimeLeft.Stop(); if (levelCleared == true) { score = correct * time * stats.Accuracy / 100; MessageBox.Show("Level Cleared Successfully!!\nCorrect: " + correct + "\nWrong: " + wrong + "\nAccuracy: " + stats.Accuracy + "\nHighScore: " + score, "Level Cleared!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { score = score = correct * time * stats.Accuracy / 100; MessageBox.Show("Level Not Cleared\nCorrect: " + correct + "\nWrong: " + wrong + "\nAccuracy: " + stats.Accuracy + "\nHighScore: " + score, "LEVEL NOT CLEARED!", MessageBoxButtons.OK, MessageBoxIcon.Information); } highscore(score); this.Visible = false; }
public void EndGame() { bool levelCleared; if (txtDisp == txtTarget) { levelCleared = true; } else { levelCleared = false; } TimeLeft.Stop(); Results(levelCleared); }
public void keyboard_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == richTextBox1.Text[0]) { temp.Push(richTextBox1.Text[0]); richTextBox1.Text = richTextBox1.Text.Remove(0, 1); activeColor = Color.Yellow; stats.Update(true); } else { wrong++; stats.Update(false); activeColor = Color.Red; if (displayMsg.Text != "" && e.KeyChar != Convert.ToChar(Keys.Back)) { displayMsg.Text = displayMsg.Text.Remove(0, 1); } } if (e.KeyChar == Convert.ToChar(Keys.Back) && temp.Count != 0) { richTextBox1.Text = richTextBox1.Text.Insert(0, Convert.ToString(temp.Pop())); } if (e.KeyChar == Convert.ToChar(Keys.Menu) || e.KeyChar == Convert.ToChar(Keys.Tab) || e.KeyChar == Convert.ToChar(Keys.ControlKey) || e.KeyChar == Convert.ToChar(Keys.Enter) || e.KeyChar == Convert.ToChar(Keys.Escape) || e.KeyChar == Convert.ToChar(Keys.Back)) { wrong--; activeColor = Color.Yellow; } if (richTextBox1.Text == "") { richTextBox1.Text = GetRandomWord(); displayMsg.Text = ""; correct++; TimeLeft.Stop(); TimeLeft.Start(); } CorrectLbl.Text = "Correct: " + correct; WrongLbl.Text = "Health: " + (20 - wrong); AccuracyLbl.Text = "Accuracy: " + stats.Accuracy + "%"; }
private void Pause(object sender, EventArgs e) { timer1.Stop(); TimeLeft.Stop(); }