using UnityEngine;
using System.Collections;

public class CameraPanAnim {
	private const float SPEED = 7.0f;
	
	private Vector3 target;
	
	public CameraPanAnim(Unit targetUnit) {
		target = targetUnit.getPosition().getWorldPosition();
		target.z = Camera.main.transform.position.z;
	}
	
	public void step(float dt) {
		Vector3 diff = target - Camera.main.transform.position;
		if (diff.magnitude <= dt * SPEED) {
			Camera.main.transform.position = target;
		}
		else {
			Vector3.Normalize(diff);
			Camera.main.transform.position += diff * dt * SPEED;
		}
	}
	
	public bool isComplete() {
		return Vector3.Distance(Camera.main.transform.position, target) < 1.0e-5f;
	}
}
