コード例 #1
0
 public void OnAttemptsExhausted(FreeResponseMinigameDriver driver)
 {
     if (AttemptsExhausted != null)
     {
         AttemptsExhausted.Invoke();
     }
 }
コード例 #2
0
        public void SubmitAnswer(string _attempt, FreeResponseMinigameDriver driver, Action <string> onIncorrect = null)
        {
            var isCorrect = false;
            var attempt   = _attempt;

            driver.AttemptsTried++;

            if (string.IsNullOrEmpty(_attempt))
            {
                attempt = "";
            }
            attempt = attempt.Trim();

            if (driver.Quiz == null || driver.Quiz.Answer.AnswerText == null || driver.Quiz.Answer.AnswerText.Count() <= 0)
            {
                throw new MissingFieldException("Quiz has no answer text attached.");
            }

            if (driver.Quiz.Answer is StrictMatchAnswer)
            {
                var answerObj = driver.Quiz.Answer as StrictMatchAnswer;
                isCorrect = CheckStrictMatch(attempt, answerObj);
            }
            else if (driver.Quiz.Answer is LooseMatchAnswer)
            {
                // not implemented
                //var answerObj = driver.Quiz.Answer as LooseMatchAnswer;
                //isCorrect = CheckLooseMatch(attempt, answerObj);
            }
            else if (driver.Quiz.Answer is TextMustContainAnswer)
            {
                var answerObj = driver.Quiz.Answer as TextMustContainAnswer;
                isCorrect = CheckMustContainMatch(attempt, answerObj);
            }
            else
            {
                throw new Exception("Unable to cast Quiz answer.");
            }

            if (isCorrect)
            {
                OnAttemptCorrect(attempt, driver);
            }
            else
            {
                if (driver.Quiz.MaximumAttempts > 0 && driver.AttemptsTried >= driver.Quiz.MaximumAttempts)
                {
                    OnAttemptsExhausted(driver);
                }
                if (onIncorrect != null)
                {
                    onIncorrect.Invoke(attempt);
                }
            }
        }
コード例 #3
0
        //////////////////////////////////////////////////////////////
        //      FREE RESPONSE QUIZ
        //////////////////////////////////////////////////////////////
        public void Action(FreeResponseMinigameDriver quizDriver)
        {
            if (OnAction != null)
            {
                OnAction.Invoke();
            }

            ThreadHelper.Instance.CallOnMainThread(() =>
            {
                PushQuizPanel <FreeResponseMinigameDriver, FreeResponseQuizPanel>(quizDriver);
            });
        }
コード例 #4
0
        //////////////////////////////////////////////////////////////
        //      FREE RESPONSE QUIZ
        //////////////////////////////////////////////////////////////
        public void Action(FreeResponseMinigameDriver quizDriver)
        {
            if (OnAction != null)
            {
                OnAction.Invoke();
            }

            ThreadHelper.Instance.CallOnMainThread(() =>
            {
                var panel = PanelManager.Instance.GetPanel <FreeResponseQuizPanel>();
                if (panel == null)
                {
                    m_logger.Error(typeof(FreeResponseQuizPanel).ToString() + " not found.");
                    return;
                }

                PanelManager.Instance.Push(k_quizStack, panel, quizDriver);
            });
        }
コード例 #5
0
 public void OnAttemptCorrect(string _attempt, FreeResponseMinigameDriver driver)
 {
     PushSuccessPanel(driver.TaskDriver);
 }