using UnityEngine;
using System.Collections;

public class Eyes : MonoBehaviour {
	Room room;
	GameController gc;
	
	// Use this for initialization
	void Start () {
		gc = GameController.instance;
		room = FindObjectOfType<Room>();
	}

	void OnTriggerEnter2D(){
		StartCoroutine (Ouch ());
	}
	
	IEnumerator Ouch(){
		Destroy (collider2D);
		room.player.rigidbody2D.velocity = Vector2.zero;
		Destroy(room.player);
		room.SendMessage ("ShowMessage","Waaaaaaaaaa! Monsters under my bed!");
		yield return new WaitForSeconds(room.msgTime +room.msgFadeTime);
		gc.SendMessage ("ClearChildItems");
		Application.LoadLevel("ChildLandingUp");
	}
}
