using UnityEngine;
using System.Collections;

public class Bee : 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);
		if(room.player){
			room.player.rigidbody2D.velocity = Vector2.zero;
			Destroy(room.player);
		}
		room.SendMessage ("ShowMessage","Ouch!! Bad bee!");
		yield return new WaitForSeconds(room.msgTime +room.msgFadeTime);
		gc.SendMessage ("Penalty",20f);
		Application.LoadLevel("ChildEntrance");
	}
}
