using UnityEngine;
using System.Collections;

public class Nest : MonoBehaviour
{
	void Start ()
	{
	
	}
	
	void Update ()
	{
	
	}

	void OnTriggerEnter( Collider collisionInfo )
	{
		//Debug.Log( "Nest triggered " + collisionInfo.name );

		if ( collisionInfo.collider.name == "Player" )
		{
			Player Pla = collisionInfo.gameObject.GetComponent<Player>();

			if ( null != Pla )
			{
				TucanAttack( collisionInfo.gameObject );

				DestroyObject( gameObject );
			}
		}
	}

	void TucanAttack( GameObject Attacker )
	{
		GameObject Obj	= Instantiate( Resources.Load( "obj_tucan" ) ) as GameObject;
		Tucan Tuc		= Obj.GetComponent<Tucan>();

		Tuc.Begin( transform.position.x > 500 ? true : false );
	}
}
