Ejemplo n.º 1
0
    void Judge(GameObject button)   //judge the button that user have just selected
    {
        if (Time.time - lastTime < 5)
        {
            return;
        }
        rightAnswers = ReadFromXml.ReadRightAnswers(id);
        if (rightAnswers.Count == 1)
        {
            string myAns = button.GetComponentInChildren <Text>().text;
            if (myAns == rightAnswers[0])  //if the answer is right
            {
                score.text = "That's right!";
                Destroy("Button");

                id++;
                ShowQuestion.Show();                             //show the next question and options
                rightAnswers = ReadFromXml.ReadRightAnswers(id); //update the right answer
                Init();
            }
            else
            {
                score.text = "Try Again";  //if not right then print try again
            }
            lastTime = Time.time;
            updateOn = true;
        }
    }
Ejemplo n.º 2
0
 void Judge(GameObject[] toggles)
 {
     if (Time.time - lastTime < 5)
     {
         return;
     }
     rightAnswers = ReadFromXml.ReadRightAnswers(id);
     if (toggles.Length == rightAnswers.Count)
     {
         foreach (GameObject toggle in toggles)
         {
             if (!rightAnswers.Contains(toggle.GetComponent <Text>().text))
             {
                 score.text = "Try again";
                 return;
             }
         }
         score.text = "That's right!";
         Destroy("Toggle");
         id++;
         ShowQuestion.Show();                             //show the next question and options
         rightAnswers = ReadFromXml.ReadRightAnswers(id); //update the right answer
         Init();
         return;
     }
     score.text = "Try again";
     lastTime   = Time.time;
     updateOn   = true;
 }