using UnityEngine;
using System.Collections;

public class SlowTime : MonoBehaviour {
	TimeManager timeManager;
	public float fTimeScale = 0.1f, fTimeReturnToNormal = 3;
	public bool bTimeSlown;
	// Use this for initialization
	void Start () {
		timeManager = GameObject.Find("TimeManager").GetComponent<TimeManager>();
	}
	
	// Update is called once per frame
	void Update()
	{
		if (bTimeSlown && !timeManager.btimeReSpeedUp)
		{
//			print ("Pika!!!!!!");
			ReturnSpeedToNormalInTime ();
			bTimeSlown = false;
		}
	}
	void OnTriggerEnter (Collider other) 
	{
		if (other.tag == "Car")
		{
//			print ("Returning To Time!");
			timeManager.SetTimeScale(fTimeScale);
//			Invoke( "ReturnSpeedToNormalInTime",.02f);
		}
	}
	void ReturnSpeedToNormalInTime () 
	{
		timeManager.SetTimeScaleInSecconds(1, fTimeReturnToNormal);
	}
}
