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

public class ShopEntry : MonoBehaviour {
    bool canEnterShop;

    void DialogVisible(bool visibility)
    {
        canEnterShop = visibility;
    }

    void OnTriggerEnter2D(Collider2D col)
    {
        DialogVisible(true);
    }

    void OnTriggerExit2D(Collider2D col)
    {
        DialogVisible(false);
    }
	
	// Update is called once per frame
	void Update () {
		if(canEnterShop && Input.GetKeyDown(KeyCode.UpArrow))
        {
            if (NavigationMenager.CanNavigate(this.tag))
            {
                NavigationMenager.NavigateTo(this.tag);
            }
        }
	}

    void OnGUI()
    {
        if (canEnterShop)
        {
            GUI.BeginGroup(
                new Rect(Screen.width / 2 - 150, 50, 300, 50));
            GUI.Box(new Rect(0, 0, 300, 250), "");
            GUI.Label(new Rect(15, 10, 300, 68),
                "Do you want to enter the shop? (Press up)");
            GUI.EndGroup();
        }
    }
}
