using UnityEngine;
using System.Collections;

public class ZoomPill : Pill {

	private float startZoom = Data.owlHeight;
	private float endZoom = Data.owlHeight / 3.0f;
	private float zoomTime = 1.0f;
	private float timeLeft;
	
	private float angleChange;
	
	private Camera camera;
	
	public override void attach(World world, Camera camera, Owl owl) {
		timeLeft = zoomTime;
		this.camera = camera;
	}
	
	public override void update(float dt, float totalTimeLeft) {
		timeLeft -= dt;
		if (timeLeft > 0.0f) {
			Debug.Log ("Time left: " + timeLeft);
			float y = Interpolate.EaseOutQuad (startZoom, endZoom - startZoom, zoomTime - timeLeft, zoomTime);
			camera.transform.position = new Vector3(camera.transform.position.x, y, camera.transform.position.z);
		}
		if (totalTimeLeft < zoomTime) {
			float y = Interpolate.EaseOutQuad (endZoom, startZoom - endZoom, zoomTime - totalTimeLeft, zoomTime);
			camera.transform.position = new Vector3(camera.transform.position.x, y, camera.transform.position.z);
		}

		fixYAxis(camera);
	}
	
	public override Color getColor() {
		return Color.red;
	}
}
