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

public class EquipmentPanel : MonoBehaviour {

    private static EquipmentPanel instance;

    public static EquipmentPanel Instance
    {
        get
        {
            return instance;
        }
    }

    public EquipmentPanel()
    {
        instance = this;
    }

    public EquipmentButton selectedButton;

    public void SetSelectedEquipment(EquipmentButton button)
    {
        if(selectedButton != null)
        {
            selectedButton.GetComponent<Button>().interactable = true;
            foreach(GameObject clickableZone in selectedButton.clickableZones)
            {
                clickableZone.GetComponent<BoxCollider>().enabled = false;
            }
        }

        selectedButton = button;

        if(selectedButton != null)
        {
            selectedButton.GetComponent<Button>().interactable = false;
            foreach (GameObject clickableZone in selectedButton.clickableZones)
            {
                clickableZone.GetComponent<BoxCollider>().enabled = true;
            }
        }
    }

    public Equipment SelectedEquipment
    {
        get
        {
            if (selectedButton == null)
            {
                return null;
            }
            else
            {
                return selectedButton.equipmentPrefab;
            }
        }
    }

    void Start()
    {
        
    }

    public void UpgradePlaced()
    {
        selectedButton.nextObject.SetActive(true);
        selectedButton.gameObject.SetActive(false);
        SetSelectedEquipment(null);

        Level.Instance.UpgradePlaced();
    }

}
