using UnityEngine;
using System.Collections;

public class TimeManager : MonoBehaviour
{

	float currentTime;
	public float duration;
	 float progress;
	Camera sceneCam;

	public AnimationCurve timeSlowAnimate;



	public bool lerp;

	void Awake()
	{
		sceneCam = Camera.main;
	}

	public void StartSlow ()
	{
		currentTime = Time.realtimeSinceStartup;
		lerp = true;
		progress = 0;
	}
	
	// Update is called once per frame
	void Update ()
	{

		


		if (lerp) {
			progress = (Time.realtimeSinceStartup- currentTime) / duration;
			Time.timeScale = Mathf.Lerp (0, 1, timeSlowAnimate.Evaluate(progress));
			sceneCam.orthographicSize = Mathf.Lerp (4.4f, 4.5f, timeSlowAnimate.Evaluate(progress));
			if (progress > 1) {
				progress = 0;
				lerp = false;

			}
		}

	}


}

