private void lblHint_Click(object sender, EventArgs e) { HintLimit--; if (HintLimit >= 0) { lblHint.Enabled = false; } if (Point > 0) { Point -= 2; } lblPoint.Text = "Point: " + Point; int count = 0; QuestionGeneration qgObject = new QuestionGeneration(); for (int i = 0; i < qgObject.Answer.Length; i++) { if (qgObject.Answer[i] == ' ' && count != 2) { count++; lblHintWord.Text = "Hint: " + qgObject.Answer.Substring(0, i + 1); } } }
private void QuestionLoading() { lblHintWord.Text = null; QuestionGeneration qgObject = new QuestionGeneration(); qgObject.GetQuestion(); txtQuestion.Text = null; for (int i = 0; i < qgObject.ArrQuestion.Count; i++) { txtQuestion.Text += (i + 1) + ". " + qgObject.ArrQuestion[i] + "\r\n"; } txtQuestion.Text.TrimEnd(); }
private void CheckQuestion() { QuestionGeneration qgObject = new QuestionGeneration(); string s = null; s = txtAnswer.Text.TrimStart(); if (s.TrimEnd() == qgObject.Answer) { if (IsSoundOn()) { sound = new SoundPlayer("win.wav"); sound.Play(); } Point += ModeSettings.WinPoint; WinTimes++; TotalWin++; lblPoint.Text = "Point: " + Point; lblWinTimes.Text = "Total Win: " + TotalWin; txtAnswer.Clear(); progBonus.PerformStep(); //Increment 10 if (WinTimes == ModeSettings.WinTimesToBonus) { WinTimes = 0; progBonus.Value = 0; Bonus += ModeSettings.BonusPoint; lblBonus.Text = "Bonus: " + Bonus; } QuestionLoading(); TimeLimit = WordJumble.Properties.Settings.Default.TimeLimited; } else { if (Missed < ModeSettings.WrongTimesLimit) { if (IsSoundOn()) { sound = new SoundPlayer("lose.wav"); sound.Play(); } if (point > 0) { Point -= ModeSettings.SubtractPoint; } Missed++; WinTimes = 0; progBonus.Value = 0; lblMissed.Text = "Missed: " + Missed; lblPoint.Text = "Point: " + Point; MessageBox.Show("Please try again"); } else { DialogResult dg = MessageBox.Show("You lose. Are you wanna try again", "WordJumble", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dg == DialogResult.Yes) { ResetData(); } else { WordJumblePro fMain = new WordJumblePro(); fMain.Show(); } } } }