using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class HurtEffect : MonoBehaviour
{
    private static RawImage image;
    private static bool hurt;
    // Start is called before the first frame update
    void Start()
    {
        image = GetComponent<RawImage>();
        hurt = false;
    }

    // Update is called once per frame
    void Update()
    {
        if (hurt)
        {
            StartCoroutine(FlashCoroutine(0.05f));
            hurt = false;
        }
    }
    IEnumerator FlashCoroutine(float waitTime)
    {
        yield return new WaitForSeconds(1f);
        image.enabled = true;
        yield return new WaitForSeconds(waitTime);
        image.enabled = false;
    }
    public static void Flash()
    {
        hurt = true;
    }
    
}
