using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;

public class CutsceneTextManager : MonoBehaviour{

    [SerializeField] Animator cutscene;
    [SerializeField] TextMeshProUGUI text;

    [Space]
    [TextArea] [SerializeField] string[] texts;
    int currentText;

    Animator anim;

    void Awake(){
        anim = GetComponent<Animator>();
    }

    // Start is called before the first frame update
    void Start(){

    }

    // Update is called once per frame
    void Update(){
        if (Input.anyKeyDown){
            anim.SetTrigger("Change");
        }
    }

    public void UpdateText(){
        if((texts.Length - 1) >= currentText){
            if(currentText == 1){
                cutscene.SetTrigger("Start");
            }
            AudioManager.instance.Play("Cutscene" + (currentText + 1), false);
            text.text = texts[currentText];
            currentText++;
        }else{
            text.gameObject.SetActive(false);
            SceneLoader.instance.LoadScene(1, SceneLoader.DifficultySelected.Easy);
        }
    }
}
