Chess-II-Counterattack/Assets/Scripts/UI/CutsceneTextManager.cs
Gerard Gascón 78b901484a init
2025-04-24 17:43:50 +02:00

46 lines
1.1 KiB
C#

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);
}
}
}