using UnityEngine;
using System.Collections;

public class TeenDogBark : Item {
	void OnTriggerEnter2D(/*Collider2D other*/){
		if(GameController.inventory.Contains (items.Bone)){
			room.player.rigidbody2D.velocity = Vector2.zero;
			Destroy(room.player);
			room.SendMessage ("ShowMessage","Good thing you had that bone with you.");
			StartCoroutine (End ());
		} else {
			StartCoroutine (Restart ());
		}
	}

	IEnumerator End(){
		yield return new WaitForSeconds (2f);
		gc.SendMessage ("WinAge", Age.Teen);
	}

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