void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.CompareTag("KeyDoor"))
     {
         if (checkHasKey())
         {
             audio.clip = open;
             audio.Play();
             coll.gameObject.GetComponent <OpenDoor> ().Open();
             //remove key
             GameObject popped = (GameObject)keys.Pop();
             popped.SetActive(false);
         }
         else
         {
             // bump into door sound
             audio.clip = bump;
             audio.Play();
         }
     }
     else if (coll.gameObject.CompareTag("ColourDoor"))
     {
         print("Colour door checker called");
         // TODO: this
         ChangeColour.changeColor(renderer.color);
         ColourDoorManager.TryOpen(renderer.color, coll.gameObject.GetComponent <SpriteRenderer>().color, coll);
     }
 }
Пример #2
0
 //Wanna try out SendMessage as a means of passing values between objects.
 //In the player body's script implement a method GetColor that takes in a Color object
 //And change the body colour accordingly
 //Also, in the method that determines killing, call this method using sendMessage
 //and pass in the player GameObject
 void GetKilled(GameObject killer)
 {
     ChangeColour.changeColor(color);
     Die();
 }