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

public class BuffEvent : MonoBehaviour {

    ScreenOverlay screenOverlay;

    Player player;
    public float buffHealth;
    public float normalHealth;

	// Use this for initialization
	void Start () {
        screenOverlay = Camera.main.GetComponent<ScreenOverlay>();
        player = GetComponent<Player>();
        EventManager.OnBuffStart += StartBuff;
	}
	
	// Update is called once per frame
	void Update () {
	    
	}

    void StartBuff(float time)
    {
        StartCoroutine(BuffTimer(time));
    }

    IEnumerator BuffTimer(float time)
    {
        screenOverlay.enabled = true;
        player.health = buffHealth;
        yield return new WaitForSeconds(time);
        screenOverlay.enabled = false;
        if(player.health > normalHealth)
        {
            player.health = normalHealth;
        }
    }
}
