using UnityEngine;
using System.Collections;

public class SongFragment : MonoBehaviour {
	public float TimeToLearn;
	public int FragmentNumber;

	private bool learning = false;
	private bool learningComplete = false;
	private float learningTimeSpent = 0f;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	void OnTriggerEnter2D(Collider2D bird)
	{
		learning = true;
	}

	void OnTriggerStay2D(Collider2D bird)
	{
		if (learningComplete) {
			return;
		}

		if (learning) {
			learningTimeSpent += Time.deltaTime;
			if(learningTimeSpent >= TimeToLearn)
			{
				FragmentViewController.instance.FragmentFound(this);
				learningComplete = true;
			}
		}
	}
}
