private void btnCheckSolution_Click(object sender, EventArgs e) { string answerString = txtAnswer.Text; if (txtAnswer.Text == "") { answerString = "0"; } int answerNumber = Convert.ToInt16(answerString); bool showPiece = questionHandler.CheckAnswer(answerNumber); if (!showPiece) { wrongAnswers++; imageList[wrongAnswers].Image = Image.FromFile(pictures[wrongAnswers]); imageList[wrongAnswers].Parent = imageList[wrongAnswers - 1]; imageList[wrongAnswers].Location = new Point(0, 0); imageList[wrongAnswers].Visible = true; CheckFinish(); } else { questionHandler.GetRandomQuestion(); currentScore++; txtCurrentScore.Text = currentScore.ToString(); } txtAnswer.Text = ""; txtAnswer.Focus(); }
private void btnCheckSolution_Click(object sender, EventArgs e) { int answerNumber, piece = 0; string answerString = txtAnswer.Text; if (txtAnswer.Text == "") { answerString = "0"; } answerNumber = Convert.ToInt16(answerString); bool showPiece = questionHandler.CheckAnswer(answerNumber); if (showPiece) { piecesShown++; score += 100; BusinessStructure.Instance.RightAnswerSound.Play(); if (puzzleSize == 1) { do { piece = random.Next(1, 13); } while (piecesIndex[piece - 1] != 0); } if (puzzleSize == 2) { do { piece = random.Next(1, 25); } while (piecesIndex[piece - 1] != 0); } piecesIndex[piece - 1] = 1; imageList[27 - piece - 1].Image = Image.FromFile(pictures[23 * piece + puzzleIndex]); imageList[27 - piece - 1].Parent = imageList[27 - oldPiece - 1]; imageList[27 - piece - 1].Location = new Point(0, 0); imageList[27 - piece - 1].Visible = true; oldPiece = piece; } else { score -= 50; BusinessStructure.Instance.WrongAnswerSound.Play(); } txtScore.Text = Convert.ToString(score); txtAnswer.Text = ""; questionHandler.GenerateQuestion(); CheckPrize(); txtAnswer.Focus(); }
// Llamada por el boton public void CheckAnswer(Answer answer, string accion) { questionHandler.CheckAnswer(answer, accion); }