using UnityEngine;
using System.Collections;

public class ClockControl : MonoBehaviour {
    public float PunchSpeed = 0.05f;

    public static float TurnSpeed=1.0f;
    public static float HurrySpeed = 2.5f;
    public static float HiddenSpeed = 3.0f;



    // running normal
    // hurry up
    // punched

    private static float PunchUntil=0;
    private static float speed = 1;
    public static void Punch(float t)
    {
        PunchUntil = Time.realtimeSinceStartup + t;
    }

    public static void MovePlayer()
    {
        speed = TurnSpeed;
        SetTimeScale(speed);
    }

    public static void MoveHurry()
    {
        speed = HurrySpeed;
        SetTimeScale(speed);
    }

    public static void MoveAI()
    {
        if (speed != HurrySpeed)
            speed = TurnSpeed;
        SetTimeScale(speed);
    }

    public static void MoveHiddenAI()
    {
        if (speed != HurrySpeed)
            speed = HiddenSpeed;
        SetTimeScale(speed);
    }

	// Update is called once per frame
	void Update () {
        if (speed != TurnSpeed)
            PunchUntil = -1;

        if (PunchUntil >= Time.realtimeSinceStartup)
        {
            Time.timeScale = PunchSpeed;
        }
        else
        {
            Time.timeScale = speed;
        }
	}

    private static void SetTimeScale(float speed)
    {
        Time.timeScale = speed;
        Time.fixedDeltaTime = 0.02F * Time.timeScale;
    }
}
