コード例 #1
0
    //bound to event PostTimerElapsed
    private void EvaluateAnswerIfProvided()
    {
        //check again after time is up
        if (ProblemState == Problem_State.ANSWER_PENDING)
        {
            gameTexts[1].text = user_answer.ToString();
            //evaluate if answer is right or wrong
            ProblemState = (user_answer == product) ? Problem_State.CORRECT_ANSWER : Problem_State.WRONG_ANSWER;
        }

        if (ProblemState == Problem_State.CORRECT_ANSWER)
        {
            gameTexts[1].text  = user_answer.ToString();
            gameTexts[1].color = Color.green;
            // Debug.Log("My AnswerC: " + user_answer.ToString());
            // Debug.Log("The AnswerC: " + product.ToString());
        }
        else
        {
            //Debug.Log("My Answer: " + user_answer.ToString());
            // Debug.Log("The Answer: " + product.ToString());
            gameTexts[1].text  = product.ToString();
            gameTexts[1].color = Color.red;
        }

        product = NO_PRODUCT;
    }
コード例 #2
0
 //bound to event PreTimerElapsed
 private void InitializeNewQuestion()
 {
     int[] values = RandomNumbers(0, 12);
     product            = Product(values);
     questionText       = string.Format("{0}  x  {1}  =  ", values[0], values[1]);
     answerText         = "?";
     gameTexts[0].text  = questionText;
     gameTexts[1].text  = answerText;
     gameTexts[1].color = Color.white;
     user_answer        = NO_ANSWER;
     ProblemState       = Problem_State.NO_ANSWER;
 }
コード例 #3
0
    private void Awake()
    {
        user_answer     = NO_ANSWER;
        UpdateDuration  = updateDuration;
        UpdateFrequency = updateFrequency;
        DisplayDelay    = displayDelay;
        elapsedTime     = 0.0f;
        ProblemState    = Problem_State.NO_ANSWER;

        multiplicationQuestion = GameObject.Find("MultiplicationQuestion");
        Debug.Assert(multiplicationQuestion != null);

        gameTexts = multiplicationQuestion.GetComponentsInChildren <TextMeshProUGUI>();
        Debug.Assert(gameTexts.Length != 0);
    }