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

public class VictimBlink : MonoBehaviour 
{
    public Image m_image;
    public float m_blinkTime;
    public float m_curBlinkTime;
    public bool m_isActive;
	// Use this for initialization
	void Start () 
    {
        m_curBlinkTime = m_blinkTime;
	}
	
	// Update is called once per frame
	void Update () 
    {
	    if(m_isActive)
        {
            m_curBlinkTime -= Time.deltaTime;
            m_image.color = new Color(1, 0, 0, (m_curBlinkTime / m_blinkTime)*0.75f);
            if(m_curBlinkTime <= 0)
            {
                m_curBlinkTime = m_blinkTime;
                m_isActive = false;
            }
        }
        else
        {
            m_image.color = new Color(1, 0, 0, 0);
        }
	}

    public void SetActive(bool _b)
    {
        m_isActive = _b;
    }
}
