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

public class VictimNext : MonoBehaviour {

    public Image m_image;
    public float m_fadeTime;
    public float m_curfadeTime;
    public bool m_isActive;
    public int m_fadeDirection = 1;
    // Use this for initialization
    void Start()
    {
        m_curfadeTime = m_fadeTime;
        m_fadeDirection = 1;
    }

    // Update is called once per frame
    void Update()
    {
        if (m_isActive)
        {
            m_curfadeTime -= Time.deltaTime;
            m_image.color = new Color(1, 1, 1, m_curfadeTime / m_fadeTime);
            /*if (m_curfadeTime >= m_fadeTime)
            {
                m_curfadeTime = m_fadeTime;
                m_fadeDirection = -1;
            }*/
            if (m_curfadeTime <= 0)
            {
                m_curfadeTime = 0;
                m_isActive = false;
            }
        }
        else
        {
            m_image.color = new Color(1, 0, 0, 0);
        }
    }

    public void Activate(bool _b)
    {
        m_isActive = _b;
        if(_b)
        {
            m_curfadeTime = m_fadeTime;
            m_fadeDirection = 1;
        }
        gameObject.SetActive(_b);
    }
}
