Scriptum/Assets/Scripts/Inventory/InventoryManager.cs
kabix09 9fa400f9a7 Add inventory Drag & Drop
Simple code refaactor
2022-06-05 10:30:52 +02:00

61 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class InventoryManager : BaseWarehouseController
{
public static int MAX_ITEMS = 5;
public static InventoryManager Instance;
// 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;
}
}
private void Awake()
{
if(Instance == null)
{
Instance = this;
}else if (Instance != this)
{
Destroy(gameObject);
}
}
public void AddToInventory(EquippableItem pickable)
{
if(this._items.Count <= MAX_ITEMS)
{
this._items[this._items.Count] = pickable;
}else {
Debug.Log("Cent add - Inventory is full");
}
}
protected override void SetupPanel()
{
if(this.dynamicPanel)
{
this.dynamicPanel.GetComponent<InventoryPanelController>().Setup(gameObject, _items);
}
}
// public void DropItem()
// {
// }
}