using UnityEngine;
using System.Collections;

public class TimeZone : MonoBehaviour
{
    const float slowTime = 0.10f;
    const float normTime = 0.9f;

	// Use this for initialization
	void Start ()
    {
        Time.timeScale = normTime;
	}
	
	void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Ball")
            Time.timeScale = slowTime;
    }

    void OnTriggerExit(Collider other)
    {
        if (other.tag == "Ball")
            Time.timeScale = normTime;
    }

    void OnTriggerStay(Collider other)
    {
        if (other.tag == "Ball")
        {
            //float ballPercent = Ball.instance.myBody.velocity.magnitude / 20.0f;
            //Time.timeScale = Mathf.Lerp(normTime, slowTime, ballPercent);
            if (Ball.instance.myBody.velocity.magnitude < 7.5f)
                Time.timeScale = normTime;
        }
    }
}
