コード例 #1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "box")
     {
         char[] letter = new char[word.Length];
         letter = word.ToCharArray();
         if (i < letter.Length)
         {
             if (other.gameObject.name == "Cube " + letter[i])
             {
                 FindObjectOfType <AudioManagerSystem>().PlaySound("correct");
                 alphabetBox = listofalphabet[i];
                 alphabetBox.GetComponent <Text>().text = letter[i].ToString();
                 goParticalEffect.GetComponent <ParticleSystem>().Play();
                 Destroy(other.gameObject);
                 i++;
                 if (i == letter.Length)
                 {
                     gamemanager.WinLevel();
                 }
             }
             else
             {
                 FindObjectOfType <AudioManagerSystem>().PlaySound("wrong");
                 //Addforce(other.gameObject);
             }
         }
     }
 }
コード例 #2
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "box")
        {
            switch (other.gameObject.GetComponent <CubesController>().hand)
            {
            case 1:
                GameObject.Find("HandLeft").GetComponent <ObjectDetectionLeftHand>().isSelected = false;
                break;

            case 2:
                GameObject.Find("HandRight").GetComponent <ObjectDetectionRightHand>().isSelected = false;
                break;
            }
            char[] letter = new char[word.Length];
            letter = word.ToCharArray();
            if (other.gameObject.name == "Cube " + letter[i])
            {
                FindObjectOfType <AudioManagerSystem>().PlaySound("correct");
                alphabetBox = listofalphabet[i];
                alphabetBox.GetComponent <Text>().text = letter[i].ToString();
                StartCoroutine(AfterTime(1f, alphabetBox.transform.parent.gameObject.transform.parent.gameObject));
                goParticalEffect.GetComponent <ParticleSystem>().Play();
                Destroy(other.gameObject);
                i++;
                if (i == letter.Length)
                {
                    gamemanager.WinLevel();
                }
            }
            else
            {
                FindObjectOfType <AudioManagerSystem>().PlaySound("wrong");
                Addforce(other.gameObject);
            }
        }
    }