Beispiel #1
0
 void OnTriggerEnter(Collider other)
 {
     if (!other.gameObject.CompareTag("Player"))
     {
         if (!other.gameObject.CompareTag("EndZone"))
         {
             if (gameObject.CompareTag("Collected"))
             {
                 primeColor = other.gameObject.GetComponent <MeshRenderer> ().material.name == gameObject.GetComponent <MeshRenderer> ().material.name;
                 primeShape = (other.gameObject.GetComponent <MeshFilter> ().mesh.name == gameObject.GetComponent <MeshFilter> ().mesh.name&& !other.gameObject.CompareTag("Boundary"));
                 primeBoth  = primeColor && primeShape;
                 primed     = primeColor || primeShape;
                 if (primed)
                 {
                     pair = other.gameObject;
                 }
                 gameObject.tag = "Stopped";
                 GetComponent <Rigidbody> ().velocity = new Vector3(0, 0, 0);
             }
             else if (primed)
             {
                 bool tempprimeColor = other.gameObject.GetComponent <MeshRenderer> ().material.name == gameObject.GetComponent <MeshRenderer> ().material.name;
                 bool tempprimeShape = other.gameObject.GetComponent <MeshFilter> ().mesh.name == gameObject.GetComponent <MeshFilter> ().mesh.name;
                 bool tempprimeBoth  = primeColor && primeShape;
                 if (tempprimeBoth && primeBoth)
                 {
                     gamecontrol.updateScore(scoreBoth);
                     DestroyTrio(other);
                     return;
                 }
                 else if (tempprimeColor && primeColor)
                 {
                     gamecontrol.updateScore(scoreColor);
                     DestroyTrio(other);
                     return;
                 }
                 else if (tempprimeShape && primeShape)
                 {
                     gamecontrol.updateScore(scoreShape);
                     DestroyTrio(other);
                     return;
                 }
             }
         }
     }
 }