Exemplo n.º 1
0
        private void NextQuestion()
        {
            if (questionCounter >= questions.Count)
            {
                OnRoundEnd?.Invoke();
                return;
            }

            Question q = questions[questionCounter];

            currentQuestion = q;

            MediaAnswer answer = new MediaAnswer();

            if (q.AnswerVideoPath != null)
            {
                answer.AnswerVideoPath = q.AnswerVideoPath;
                answer.Kind            = AnswerKind.WithVideo;
            }
            else if (q.AnswerImagePath != null)
            {
                answer.AnswerImagePath = q.AnswerImagePath;
                answer.Kind            = AnswerKind.WithImage;
            }
            else
            {
                answer.Kind = AnswerKind.Simple;
            }

            if (q.VideoPath != null)
            {
                Extensions.ExcecuteWithAppIdleDispatcher(() => OnNewQuestion?.Invoke(q.Id, q.QuestionText, q.RightAnswer, q.TimeToAnswer, QuestionKind.WithVideo, null, q.VideoPath, answer));
            }
            else if (q.ImagePath != null)
            {
                Extensions.ExcecuteWithAppIdleDispatcher(() => OnNewQuestion?.Invoke(q.Id, q.QuestionText, q.RightAnswer, q.TimeToAnswer, QuestionKind.WithImage, null, q.ImagePath, answer));
            }
            else if (q.Answers != null)
            {
                Extensions.ExcecuteWithAppIdleDispatcher(() => OnNewQuestion?.Invoke(q.Id, q.QuestionText, q.RightAnswer, q.TimeToAnswer, QuestionKind.WithAnswers, q.Answers, null, answer));
            }
            else
            {
                Extensions.ExcecuteWithAppIdleDispatcher(() => OnNewQuestion?.Invoke(q.Id, q.QuestionText, q.RightAnswer, q.TimeToAnswer, QuestionKind.Simple, null, null, answer));
            }

            questionCounter++;
            isQuestionAnswered = true;
            isWrongAnswer      = false;
            isWrongPlayer      = false;
        }
Exemplo n.º 2
0
 /// <summary>
 ///    Printing question and answers to the screen
 /// </summary>
 public void GetQuestionAndAnswers()
 {
     OnNewQuestion?.Invoke(this, Text);
     LoadData.WriteToScreen(Text);
     if (Answers == null)
     {
         return;
     }
     /// ze słownika wyciągam nazwę po numerze żeby mieć dostęp do parametrów buttona
     foreach (var button in LoadData.IdButton)
     {
         if (button.Key <= Answers.Length)
         {
             OnNewAnswer?.Invoke(this, button.Value, Answers[button.Key - 1].Text);
             LoadData.WriteToScreen(Answers[button.Key - 1].Text);
         }
         else
         {
             OnInactiveButton?.Invoke(this, button.Value);
         }
     }
 }
Exemplo n.º 3
0
 protected override void OnMessage(ActiveQuestion obj)
 {
     OnNewQuestion?.Invoke(obj);
 }