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

public class AlphaMessage : MonoBehaviour
{
    public float alpha;
    public Text textMessage;
    public Image imageMessage;
    public float textMessageAlpha, imageMessageAlpha;
    // Start is called before the first frame update
    void Awake()
    {
        textMessageAlpha = 1f;
        imageMessageAlpha = 0.5f;
    }

    // Update is called once per frame
    void Update()
    {
        if (enabled == true && alpha>0)
        {
            textMessageAlpha *= alpha/100f;
            imageMessageAlpha *= alpha/100f;
            alpha -= 1.5f * Time.deltaTime;
            textMessage.color = new Color (1f, 1f, 1f,textMessageAlpha);
            imageMessage.color = new Color (0.726f, 0.209f, 0.209f,imageMessageAlpha);
        }
        else
        {
            textMessage.enabled = false;
            imageMessage.enabled = false;
        }
    }
    
}