Exemplo n.º 1
0
    void OnTriggerStay2D(Collider2D c)
    {
        if (!dragging && c.tag == "category_quiz")
        {
            string    cat  = c.gameObject.GetComponentInChildren <Text> ().text;
            WordArray wa   = GameObject.FindGameObjectWithTag("GameController").GetComponent <WordArray>();
            string    word = this.gameObject.GetComponentInChildren <Text> ().text;
            string    corr = wa.GetCategoryOfWord(word);
            //Debug.Log ("CATEGORY IS " + corr);
            CategoryReaction cr = c.gameObject.GetComponent <CategoryReaction>();
            if (cr != null)
            {
                if (corr == cat)
                {
                    cr.CorrectActivation();
                    Destroy(this.gameObject);
                }
                else
                {
                    cr.WrongActivation();
                    pnael_exp = GameObject.FindGameObjectWithTag("explanation");
                    Color cc = explanation.GetComponent <Image>().color;
                    explanation.GetComponent <Image>().color = new Color(cc.r, cc.g, cc.b, 0.5f);
                    cc = explanation.GetComponentInChildren <Text>().color;
                    explanation.GetComponentInChildren <Text>().color = new Color(cc.r, cc.g, cc.b, 0.75f);
                    pnael_exp.GetComponentInChildren <Text> ().text   = wa.GetDescriptionOfWord(word);


                    StartCoroutine(Wait());
                    this.gameObject.transform.position = new Vector3(1000, 1000, 0);
                }
            }
        }
    }
Exemplo n.º 2
0
 void RobotPlay()
 {
     if (firstEntry)
     {
         allWords   = GameObject.FindGameObjectsWithTag("word_quiz");
         firstEntry = false;
     }
     if (!moving && (allWords.Length != 0))
     {
         firstEntry = false;
         allWords   = GameObject.FindGameObjectsWithTag("word_quiz");
         if (allWords.Length == 0)
         {
             robotCanMove = false;
         }
         int index = rnd.Next() % allWords.Length;
         movingIndex = index;
         string correct_category = wa.GetCategoryOfWord(allWords[index].GetComponentInChildren <Text>().text);
         foreach (GameObject go in categoriesQuiz)
         {
             if (needPoints > robotScore)
             {
                 if (go.GetComponentInChildren <Text>().text == correct_category)
                 {
                     target = go.transform;
                     break;
                 }
             }
             else if (robotScore >= needPoints)
             {
                 if (go.GetComponentInChildren <Text>().text != correct_category)
                 {
                     target = go.transform;
                     break;
                 }
             }
         }
         moving = true;
     }
     else
     {
         if (allWords[movingIndex] != null)
         {
             float step = robotSpeed * Time.deltaTime;
             allWords[movingIndex].transform.position = Vector3.MoveTowards(allWords[movingIndex].transform.position, target.position, step);
         }
         else
         {
             moving = false;
         }
     }
 }