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

public class IntroManager : MonoBehaviour
{
    [SerializeField]
    private GameObject normaJokeBubble;

    [SerializeField]
    private GameObject normaJoke;

    private List<string> texts = new List<string>()
    {
        "Wake up, Rex. I think life\nmade us a cruel joke, again.",
        "I have a bad news\nand a good news.",
        "Something is wrong\non my exterior hull\n you need to fix it, okay?",
        "Wait, it's a laughing space \ndemon. Do not let it touch you!",
        "Did you just thrown my \nauxillary controller \nat it?",
        "Congratulations. \nWe're deorbiting, バカ Rex. \nAre you still okay?",
        "Human, you escape\n using parachute.",
        "Wait until the altitude \nwon't be that high, \nunderstand?",
        "Started backing myself up. \nWait for me. \nPlease."
    };

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

    IEnumerator NextNormaText()
    {
        foreach (var text in texts)
        {
            normaJoke.GetComponent<TMP_Text>().text = text;
            normaJokeBubble.GetComponent<AudioSource>().Play();
            yield return new WaitForSeconds(3);
        }
        Scenes.Outro(Ending.INSANITY);
    }

    public void DisplayNormaText()
    {
        normaJokeBubble.SetActive(true);
        normaJoke.SetActive(true);
        StartCoroutine(NextNormaText());
    }

    public void OnFire()
    {
        DisplayNormaText();
    }

    // Update is called once per frame
    void Update() { }
}
