Ejemplo n.º 1
0
        private IEnumerable <XElement> GetSaveElements()
        {
            if (DX11_StructureAddress?.Any() == true)
            {
                yield return(new XElement("DX11",
                                          new XElement("StructureAddress",
                                                       string.Join(",", DX11_StructureAddress.Select(x => x.ToString("X", CultureInfo.InvariantCulture)))),
                                          new XElement("ZoomCurrent", DX11_ZoomCurrent.ToString("X", CultureInfo.InvariantCulture)),
                                          new XElement("ZoomMax", DX11_ZoomMax.ToString("X", CultureInfo.InvariantCulture)),
                                          new XElement("FovCurrent", DX11_FovCurrent.ToString("X", CultureInfo.InvariantCulture)),
                                          new XElement("FovMax", DX11_FovMax.ToString("X", CultureInfo.InvariantCulture))
                                          ));
            }

            yield return(new XElement("LastUpdate", LastUpdate));

            yield return(new XElement("AutoApply", AutoApply.ToString(CultureInfo.InvariantCulture)));

            yield return(new XElement("AutoQuit", AutoQuit.ToString(CultureInfo.InvariantCulture)));

            yield return(new XElement("DesiredZoom", DesiredZoom.ToString(CultureInfo.InvariantCulture)));

            yield return(new XElement("DesiredFov", DesiredFov.ToString(CultureInfo.InvariantCulture)));

            yield return(new XElement("OffsetUpdateLocation", OffsetUpdateLocation));
        }
Ejemplo n.º 2
0
        /// <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();
                }
            }
        }
Ejemplo n.º 3
0
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            //update the timers
            AutoQuit.Update(gameTime);

            //check if we been here long enough
            if (IsActive)
            {
                QuestionStateMachine.Update(gameTime);

                if (!AutoQuit.Paused && !AutoQuit.HasTimeRemaining)
                {
                    //has the user picked an answer?
                    if (!AnswerChosen)
                    {
                        //the timer ran out but the user hadn't picked an answer.  That counts as "wrong"
                        AnswerSelected(false, correctQuestion);

                        //play the "wrong" sound effect
                        WrongAnswerSound.Play();

                        TimeRanOut = true;
                    }
                    else
                    {
                        //holla at the combat engine
                        ExitScreen();
                    }
                }
            }

            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
        }
Ejemplo n.º 4
0
        private IEnumerable <XElement> GetSaveElements()
        {
            yield return(new XElement("DX9",
                                      new XElement("StructureAddress", string.Join(",", DX9_StructureAddress.Select(x => x.ToString("X", CultureInfo.InvariantCulture)))),
                                      new XElement("ZoomCurrent", DX9_ZoomCurrent.ToString("X", CultureInfo.InvariantCulture)),
                                      new XElement("ZoomMax", DX9_ZoomMax.ToString("X", CultureInfo.InvariantCulture)),
                                      new XElement("FovCurrent", DX9_FovCurrent.ToString("X", CultureInfo.InvariantCulture)),
                                      new XElement("FovMax", DX9_FovMax.ToString("X", CultureInfo.InvariantCulture))
                                      ));

            yield return(new XElement("DX11",
                                      new XElement("StructureAddress", string.Join(",", DX11_StructureAddress.Select(x => x.ToString("X", CultureInfo.InvariantCulture)))),
                                      new XElement("ZoomCurrent", DX11_ZoomCurrent.ToString("X", CultureInfo.InvariantCulture)),
                                      new XElement("ZoomMax", DX11_ZoomMax.ToString("X", CultureInfo.InvariantCulture)),
                                      new XElement("FovCurrent", DX11_FovCurrent.ToString("X", CultureInfo.InvariantCulture)),
                                      new XElement("FovMax", DX11_FovMax.ToString("X", CultureInfo.InvariantCulture))
                                      ));

            yield return(new XElement("LastUpdate", LastUpdate));

            if ((Control.ModifierKeys & (Keys.Control | Keys.Alt | Keys.Shift)) != 0)
            {
                yield break;
            }
            yield return(new XElement("AutoApply", AutoApply.ToString(CultureInfo.InvariantCulture)));

            yield return(new XElement("AutoQuit", AutoQuit.ToString(CultureInfo.InvariantCulture)));

            yield return(new XElement("DesiredZoom", DesiredZoom.ToString(CultureInfo.InvariantCulture)));

            yield return(new XElement("DesiredFov", DesiredFov.ToString(CultureInfo.InvariantCulture)));

            yield return(new XElement("OffsetUpdateLocation", OffsetUpdateLocation));
        }
Ejemplo n.º 5
0
        public override async Task LoadContent()
        {
            try
            {
                await base.LoadContent();

                if (null == FontSmall)
                {
                    FontSmall = new FontBuddyPlus();
                    FontSmall.LoadContent(Content, StyleSheet.SmallFontResource, StyleSheet.UseFontPlus, StyleSheet.SmallFontSize);
                }

                if (null == FontMedium)
                {
                    FontMedium = new FontBuddyPlus();
                    FontMedium.LoadContent(Content, StyleSheet.MediumFontResource, StyleSheet.UseFontPlus, StyleSheet.MediumFontSize);
                }

                //create the stack layout to hold the question and words
                var questionStack = new StackLayout(StackAlignment.Top)
                {
                    Vertical         = VerticalAlignment.Bottom,
                    Horizontal       = HorizontalAlignment.Center,
                    Highlightable    = false,
                    TransitionObject = new WipeTransitionObject(TransitionWipeType.PopTop),
                };

                //Add the text asking a question
                questionStack.AddItem(new Label($"What is the", FontSmall)
                {
                    Vertical         = VerticalAlignment.Center,
                    Horizontal       = HorizontalAlignment.Center,
                    Highlightable    = false,
                    TransitionObject = new WipeTransitionObject(TransitionWipeType.PopTop),
                });
                questionStack.AddItem(new Shim(0, 8));
                questionStack.AddItem(new Label($"{correctAnswer.Language} for:", FontSmall)
                {
                    Vertical         = VerticalAlignment.Center,
                    Horizontal       = HorizontalAlignment.Center,
                    Highlightable    = false,
                    TransitionObject = new WipeTransitionObject(TransitionWipeType.PopTop),
                });
                questionStack.AddItem(new Shim(0, 8));

                //Add all the translations
                foreach (var translation in correctQuestion.Translations)
                {
                    if (translation.Language != correctAnswer.Language)
                    {
                        CreateTranslationLabel(FontMedium, questionStack, translation);
                    }
                }

                questionStack.Position = new Point(Resolution.ScreenArea.Center.X, (int)((Resolution.TitleSafeArea.Height * 0.2f) - (questionStack.Rect.Height * 0.4f)));
                AddItem(questionStack);

                //create the correct menu entry
                CorrectAnswerEntry          = CreateQuestionMenuEntry(correctAnswer.Word, correctQuestion, true, FontMedium);
                CorrectAnswerEntry.OnClick += CorrectAnswerSelected;
                Entries.Add(CorrectAnswerEntry);

                //Add exactly three wrong answers
                for (int i = 0; i < 3; i++)
                {
                    //get a random wrong answer
                    int index = _rand.Next(wrongAnswers.Count);

                    //create a menu entry for that answer
                    var wrongMenuEntry = CreateQuestionMenuEntry(wrongAnswers[index].Word, wrongQuestions[index], false, FontMedium);
                    wrongMenuEntry.OnClick += WrongAnswerSelected;
                    Entries.Add(wrongMenuEntry);

                    //remove the wrong answer from the list so it wont be added again
                    wrongAnswers.RemoveAt(index);
                    wrongQuestions.RemoveAt(index);
                }

                //shuffle the answers
                Entries.Shuffle(_rand);

                //create the stack layout to hold the possible answers
                var answersStack = new StackLayout(StackAlignment.Top)
                {
                    Name             = "AnswerStack",
                    Vertical         = VerticalAlignment.Center,
                    Horizontal       = HorizontalAlignment.Center,
                    Highlightable    = false,
                    TransitionObject = new WipeTransitionObject(TransitionWipeType.PopBottom),
                    Position         = new Point(Resolution.ScreenArea.Center.X, (int)(Resolution.TitleSafeArea.Height * 0.5f))
                };

                //add all the question entries to the menu
                foreach (var entry in Entries)
                {
                    answersStack.AddItem(entry);
                }
                AddItem(answersStack);

                //load the sound effect to play when time runs out on a question
                WrongAnswerSound = Content.Load <SoundEffect>("WrongAnswer");

                AutoQuit.Stop();
            }
            catch (Exception ex)
            {
                await ScreenManager.ErrorScreen(ex);
            }

            //Try to load the sound effects
            soundContent = new ContentManager(ScreenManager.Game.Services, "Content");
            try
            {
                QuestionSoundEffect = soundContent.Load <SoundEffect>($"TTS/{correctAnswer.Language}Question");
            }
            catch (Exception ex)
            {
                //ignore for now
            }

            //load the correct answer sound effect
            try
            {
                QuestionWordSoundEffect = CorrectQuestion.LoadSoundEffect(correctQuestion.OtherLanguage(correctAnswer.Language), soundContent);
            }
            catch (Exception ex)
            {
                //ignore for now
            }

            //load the sound effect for each question
            for (int i = 0; i < Entries.Count; i++)
            {
                try
                {
                    Entries[i].LoadSoundEffect(correctAnswer.Language, soundContent);
                }
                catch (Exception ex)
                {
                    //ignore for now
                }
            }

            QuestionStateMachine = new QuestionStateMachine();
            QuestionStateMachine.StartTimer(Transition.OnTime + 0.1f);
            QuestionStateMachine.StateChangedEvent += QuestionStateMachine_StateChangedEvent;
        }