using UnityEngine;
using System.Collections;

public class PopperDrop : MonoBehaviour {

	public float VertProximityToExplode;
	public Transform ExplosionPrefab;
	public Transform ConvertedExplosionPrefab;

	private float startTime;

	private GameController gc;
	
	void Start () {
		GameObject go = GameObject.Find ("GameController");
		gc = go.GetComponent<GameController>();

		startTime = Time.fixedTime;
	}
	
	// Update is called once per frame
	void FixedUpdate () {
		if(transform.position.y - gc.Player.position.y < VertProximityToExplode)
			Pop ();
	}

	private void Pop()
	{
		Transform e = (Transform)GameObject.Instantiate (ExplosionPrefab);
		e.position = transform.position;
		GameObject.Destroy(gameObject);
	}

	public void PopConverted()
	{
		Transform e = (Transform)GameObject.Instantiate (ConvertedExplosionPrefab);
		e.position = transform.position;
		GameObject.Destroy(gameObject);
	}
}
