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

public class PlayerWin : MonoBehaviour
{
    private bool winned;
    private string[] dialogos = new string[20];
    private int indexDialogos;
    public GameObject cajaDialogos;
    public Text dialogo;

    private void Start()
    {
        dialogos[0] = "Fue demasiado el tiempo en ese refugio, necesitaba salir";
        dialogos[1] = "Entiendo lo que tuviste que pasar por mi pero...";
        dialogos[2] = "Creo que es momento de separarse";
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if(collision.tag == "FinalJuego")
        {
            winned = true;
        }
    }

    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space) && winned)
        {
            if (indexDialogos < 3)
            {
                MostrarDialogos();
            }
            else
            {
                SceneManager.LoadScene(0);
            }
            
        }

    }

    private void MostrarDialogos()
    {
        cajaDialogos.SetActive(true);
        Debug.Log(dialogos[indexDialogos]);
        dialogo.text = dialogos[indexDialogos];
        indexDialogos++;
    }
}
