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

public class BubblesGiveHeightBoost : MonoBehaviour
{
    public Trigger trigger;
    public bool playVoiceLine;
    public float elapsedTime;
    public float resetTime;
    public float subtitleDissapearTime;
    public AudioSource audioSource;
    public AudioClip audioClip;

    public RawImage subtitleRawImage;
    public Texture2D subtitleImage;
    public Color subtitleRawImageOnColor;
    public Color subtitleRawImageOffColor; // alpha = 0

    public bool subtitleRemoved;
    
    void Update()
    {
        if (trigger.isTriggered && !audioSource.isPlaying)
        {
            audioSource.clip = audioClip;
            audioSource.Play();

            subtitleRemoved = false;
        }

        if (audioSource.isPlaying)
        {
            subtitleRawImage.texture = subtitleImage;
            subtitleRawImage.color = subtitleRawImageOnColor;
        }
        else if (!trigger.isTriggered && !subtitleRemoved)
        {
            subtitleRawImage.color = subtitleRawImageOffColor;
            subtitleRemoved = true;
        }
    }
}
