using UnityEngine;
using System.Collections;

public class Die : MonoBehaviour
{

	private AudioSource audio;
		// Use this for initialization
		void Awake ()
		{
		audio = GetComponent<AudioSource> () as AudioSource;
		}
	
		// Update is called once per frame
		void Update ()
		{
		if ((Input.GetAxis ("Vertical") > 0 || Input.GetAxis ("Horizontal") > 0) && !audio.isPlaying)
						audio.Play ();
		}
	
		public void OnTriggerEnter (Collider coll)
		{
				if (coll.tag == "ghost") 
				{
						Debug.Log("ATTACCATO DA UN GHOST");
						transform.position = KeyManager.key.GetSpawnCoordinate();
						transform.LookAt (new Vector3 (transform.position.x, transform.position.y, transform.position.z + 1));
				}
				if (coll.tag == "Key") {
				}		
	
		}
}
