using UnityEngine;
using System.Collections;

public class Key : MonoBehaviour 
{
	
	public int keyNumber;

	private AudioSource audio;

	void Awake()
	{
		audio = GetComponent<AudioSource> () as AudioSource;
	}

	void OnTriggerEnter(Collider other)
	{


		if(other.gameObject.tag == "Player")
		{

			Debug.Log("Presa la key");
			KeyManager.key.increaseCaughtKey();
			KeyManager.key.SetActiveKey(keyNumber);			
			gameObject.GetComponent<BoxCollider>().enabled = false;
			//gameObject.GetComponent<MeshRenderer>().enabled = false;
			gameObject.GetComponentInChildren<SpriteRenderer>().enabled = false;
			gameObject.GetComponentInChildren<MeshRenderer>().enabled = false;

			audio.Play();
		}
	}
}
