Projekt_SI_automatyczny_kelner/Assets/Logic/UI/UIQueue.cs

49 lines
1.3 KiB
C#

using Logic.Data;
using Logic.Graph;
using UnityEngine;
using UnityEngine.UI;
namespace Logic.UI
{
public class UIQueue : MonoBehaviour
{
[SerializeField] private UIInventorySlot uiInventorySlot;
[SerializeField] private KitchenTable table;
public GameObject queueWrapper;
// private void Start()
// {
// foreach (var child in queueWrapper.GetComponentsInChildren<UIInventorySlot>())
// {
// Destroy(child.gameObject);
// }
// }
private void Start()
{
table = KitchenTableManager.Instance.GETTable();
var button = GetComponentInChildren<Button>();
button.onClick.AddListener( ButtonClick );
}
private void ButtonClick()
{
AgentManager.Instance.GoToNode(table);
}
public void Add(Item item)
{
UIInventorySlot uiQueueSlot = Instantiate(uiInventorySlot, queueWrapper.transform, false);
uiQueueSlot.AddItem(item);
Canvas.ForceUpdateCanvases();
}
public void Remove()
{
Destroy(queueWrapper.GetComponentsInChildren<UIInventorySlot>()[0].gameObject);
}
}
}