using UnityEngine;
using System.Collections;

public class Creak : Item {

	void OnTriggerEnter2D(/*Collider2D other*/){
		if(GameController.inventory.Contains(items.Slippers)){
			if(!GameController.hasSneaked){

				GameController.hasSneaked = true;
				Destroy (gameObject);
			}
		} else{
			StartCoroutine (Creaked ());
		}
	}

	IEnumerator Creaked(){
		room.player.rigidbody2D.velocity = Vector2.zero;
		Destroy(room.player);
		audio.Play ();
		room.SendMessage ("ShowMessage","You woke your parents up. You're grounded for another week!");
		yield return new WaitForSeconds(room.msgTime +room.msgFadeTime);
		gc.Penalty (20f);
		gc.SendMessage ("ClearTeenItems");
		Application.LoadLevel("TeenBedroom");
	}
}
