2022-05-15 18:54:59 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
[System.Serializable]
|
2022-06-05 01:57:57 +02:00
|
|
|
public class InventoryManager : BaseWarehouseController
|
2022-05-15 18:54:59 +02:00
|
|
|
{
|
|
|
|
public static int MAX_ITEMS = 5;
|
|
|
|
|
|
|
|
public static InventoryManager Instance;
|
2022-06-05 01:57:57 +02:00
|
|
|
|
|
|
|
// temporary delegate dragged item to outside static object instance to remember it
|
|
|
|
[Space]
|
|
|
|
[SerializeField]
|
|
|
|
protected ISlot _draggedSlot;
|
|
|
|
public ISlot DraggedSlot
|
|
|
|
{
|
|
|
|
get { return _draggedSlot; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_draggedSlot = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-15 18:54:59 +02:00
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
if(Instance == null)
|
|
|
|
{
|
|
|
|
Instance = this;
|
|
|
|
}else if (Instance != this)
|
|
|
|
{
|
|
|
|
Destroy(gameObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-29 21:54:28 +02:00
|
|
|
public void AddToInventory(EquippableItem pickable)
|
2022-05-15 18:54:59 +02:00
|
|
|
{
|
2022-06-05 01:57:57 +02:00
|
|
|
if(this._items.Count <= MAX_ITEMS)
|
2022-05-15 18:54:59 +02:00
|
|
|
{
|
2022-06-05 01:57:57 +02:00
|
|
|
this._items[this._items.Count] = pickable;
|
2022-05-15 18:54:59 +02:00
|
|
|
}else {
|
2022-06-05 01:57:57 +02:00
|
|
|
Debug.Log("Cent add - Inventory is full");
|
2022-05-15 18:54:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-05 01:57:57 +02:00
|
|
|
|
|
|
|
protected override void SetupPanel()
|
|
|
|
{
|
|
|
|
if(this.dynamicPanel)
|
|
|
|
{
|
|
|
|
this.dynamicPanel.GetComponent<InventoryPanelController>().Setup(gameObject, _items);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-05-15 18:54:59 +02:00
|
|
|
// public void DropItem()
|
|
|
|
// {
|
|
|
|
|
2022-06-05 01:57:57 +02:00
|
|
|
// }
|
2022-05-15 18:54:59 +02:00
|
|
|
}
|