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

public class PlayerDialogueManager : MonoBehaviour
{

    private bool isActive = false;
    private string text = "";
    private GameObject dialogueBox;
    private TextMeshPro textMesh;
    private MovementManager player;


    // Start is called before the first frame update
    void Start()
    {
        dialogueBox = transform.Find("Dialogue").gameObject;
        textMesh = dialogueBox.GetComponentInChildren<TextMeshPro>();
        player = GetComponent<MovementManager>();
       
    }

    // Update is called once per frame
    void Update()
    {
        dialogueBox.SetActive(isActive);
        textMesh.text = text;
        textMesh.transform.localEulerAngles = new Vector3(0, player.directionRight ? 0 : 180, 0);
    }

    public void SetDialogueBox(string text)
    {
        isActive = true;
        this.text = text;

    }

    public void CloseDialogueBox()
    {
        isActive = false;
        text = "";
    }
}
