using UnityEngine;
using System.Collections;

public class Obsticle : MonoBehaviour {

	void OnTriggerEnter(Collider c)
	{
		if(c.tag == "PlayerCollision")
		{
			if(!c.gameObject.transform.parent.gameObject.GetComponent<Player>().isDead)
			{

				c.gameObject.transform.parent.gameObject.GetComponent<Player>().isDead = true;
				Application.LoadLevel(2);
				//StartCoroutine("EndGame");

			}
		}
	}
	 IEnumerator EndGame()
	{
		yield return new WaitForEndOfFrame();

		GameObject.Find("World").GetComponent<World>().EndWorld(); //destory the world
		GameObject.Find("Manager").SendMessage("RemakeGame",SendMessageOptions.RequireReceiver); 

		//GameObject.Find("Overlay").GetComponent<Overlay>().Exit();//change our ui to the title screen
	}
}
