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

public class InteractPopUp : MonoBehaviour
{
    public GameObject canvas;
    public TextMeshProUGUI popUpText;
    public bool isNpc;
    public KeyCode interactButton;

    private void Awake()
    {
        canvas.SetActive(false);
    }

    // Start is called before the first frame update
    void Start()
    {
        if (isNpc)
        {
            interactButton = GetComponent<NPC>().npcDiaglougeInteract;
        }

        if (gameObject.transform.localScale.x == -1)
        {
            canvas.transform.rotation = new Quaternion(0, 180, 0, 0);
        }

        popUpText.text = interactButton.ToString();

    }
    
    public void CanvasActive(bool x)
    {
        canvas.SetActive(x);
    }

    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Player"))
        {
            canvas.SetActive(true);
        }
        
    }

    private void OnTriggerExit2D(Collider2D other)
    {
        canvas.SetActive(false);
    }
}
