/// <summary> /// The user selected an answer. /// Set the flags, menu entry colors, and start timer. /// </summary> private void AnswerSelected(bool correctAnswer, FlashCard selectedAnswer) { QuestionStateMachine.Done(); if (!AnswerChosen) { //set flags AnswerChosen = true; AnsweredCorrect = correctAnswer; //Set all the colors of the answers to let the user know which was the correct answer foreach (var entry in Entries) { entry.QuestionAnswered = true; } if (null != QuestionAnswered) { QuestionAnswered(this, new QuestionEventArgs(AnsweredCorrect, correctQuestion, selectedAnswer)); } //start the timer to exit this screen AutoQuit.Start(1f); if (null != OverlayScreen) { OverlayScreen.ExitScreen(); } } }
public override void ExitScreen() { base.ExitScreen(); if (null != OverlayScreen) { OverlayScreen.ExitScreen(); } }
public override void UnloadContent() { base.UnloadContent(); if (null != OverlayScreen) { OverlayScreen.ExitScreen(); } if (null != soundContent) { soundContent.Unload(); soundContent.Dispose(); soundContent = null; } }
private void QuestionStateMachine_StateChangedEvent(object sender, StateMachineBuddy.StateChangeEventArgs e) { switch (e.NewState) { case (int)QuestionStateMachine.QuestionState.AskingQuestion: { //play the sound that asks the question PlaySoundEffect(QuestionSoundEffect); } break; case (int)QuestionStateMachine.QuestionState.QuestionWord: { //Make sure all the colors are rest ResetColors(); //Set the color of the word being spoken to yellow SetLabelOverride(QuestionWordLabel); //play the sound that asks the question PlaySoundEffect(QuestionWordSoundEffect, 0.4f); } break; case (int)QuestionStateMachine.QuestionState.FirstAnswer: { ResetColors(); SetLabelOverride(Entries[0].QuestionLabel); PlaySoundEffect(Entries[0].SoundEffect, 0.2f); } break; case (int)QuestionStateMachine.QuestionState.SecondAnswer: { ResetColors(); SetLabelOverride(Entries[1].QuestionLabel); PlaySoundEffect(Entries[1].SoundEffect, 0.2f); } break; case (int)QuestionStateMachine.QuestionState.ThirdAnswer: { ResetColors(); SetLabelOverride(Entries[2].QuestionLabel); PlaySoundEffect(Entries[2].SoundEffect, 0.2f); } break; case (int)QuestionStateMachine.QuestionState.FourthAnswer: { ResetColors(); SetLabelOverride(Entries[3].QuestionLabel); PlaySoundEffect(Entries[3].SoundEffect, 0.2f); } break; case (int)QuestionStateMachine.QuestionState.Done: { ResetColors(); //If the user hasn't answered the question, add the overlay screen if (!AnswerChosen) { if (null == OverlayScreen) { OverlayScreen = new OverlayScreen(this, Content); ScreenManager.AddScreen(OverlayScreen); } } } break; } }