using UnityEngine;
using System.Collections;
using UnityStandardAssets.ImageEffects;

public class TunnelVision : MonoBehaviour {

    ScreenOverlay screenOverlay;

	// Use this for initialization
	void Start () {
        screenOverlay = GetComponent<ScreenOverlay>();
        EventManager.OnTunnelVisionStart += StartTunnelVision;
        //StartTunnelVision(10f);
	}
	
	// Update is called once per frame
	void Update () {
	
	}

    void StartTunnelVision(float time)
    {
        StartCoroutine(TunnelVisionTimer(time));
    }

    IEnumerator TunnelVisionTimer(float time)
    {
        screenOverlay.enabled = true;
        yield return new WaitForSeconds(time);
        screenOverlay.enabled = false;
    }
}
