2022-06-05 01:57:57 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
public class InventoryPanelController : BasePanelController
|
|
|
|
{
|
|
|
|
|
|
|
|
public override void CloseOnClick()
|
|
|
|
{
|
|
|
|
Destroy(gameObject); // destroy panel
|
|
|
|
|
|
|
|
InventoryManager.Instance.GetComponent<InventoryManager>().ClosePanel();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Setup(GameObject _inventory, Dictionary<int, Item> _items)
|
|
|
|
{
|
|
|
|
_instance = _inventory;
|
|
|
|
|
|
|
|
base.Setup(_items);
|
|
|
|
}
|
|
|
|
|
2022-10-23 13:29:22 +02:00
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
if (Input.GetKeyDown("i"))
|
|
|
|
{
|
|
|
|
Destroy(gameObject); // destroy panel
|
|
|
|
|
|
|
|
InventoryManager.Instance.GetComponent<InventoryManager>().ClosePanel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-05 01:57:57 +02:00
|
|
|
protected override ISlot SetupSlot(int key, GameObject _parent)
|
|
|
|
{
|
|
|
|
InventorySlot _tmpSlot = Instantiate(_blankSlot, _parent.transform.position, Quaternion.identity).GetComponent<InventorySlot>();
|
|
|
|
_tmpSlot.transform.SetParent(_parent.transform);
|
|
|
|
|
|
|
|
_tmpSlot.SetupSlot(key, null, this);
|
|
|
|
|
|
|
|
return _tmpSlot;
|
|
|
|
}
|
|
|
|
|
|
|
|
// public void Drop(ItemSlot<InventoryPanelController> dropItemSlot)
|
|
|
|
// {
|
|
|
|
// if(dropItemSlot.CanReceiveItem(draggedSlot.Item) && draggedSlot.CanReceiveItem(dropItemSlot.Item))
|
|
|
|
// {
|
|
|
|
// EquippableItem dragItem = draggedSlot.Item as EquippableItem;
|
|
|
|
// EquippableItem dropItem = dropItemSlot.Item as EquippableItem;
|
|
|
|
|
|
|
|
// // for changing chest to evuuipment or onventory panel !!!!
|
|
|
|
|
|
|
|
// if(draggedSlot is EquipmentSlot)
|
|
|
|
// {
|
|
|
|
// if(dragItem != null) dragItem.Unequip(this);
|
|
|
|
// if(dropItem != null) dropItem.Equip(this);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if(dropItemSlot is EquipmentSlot)
|
|
|
|
// {
|
|
|
|
// if(dragItem != null) dragItem.Equip(this);
|
|
|
|
// if(dropItem != null) dropItem.Unequip(this);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// Item draggedItem = draggedSlot.Item; // remember temporary currently dragged item
|
|
|
|
|
|
|
|
// draggedSlot.Item = dropItemSlot.Item;
|
|
|
|
// dropItemSlot.Item = draggedItem;
|
|
|
|
|
|
|
|
// // update items position in chest slots
|
|
|
|
// // - after close paned - items dont reset its positions
|
|
|
|
// _inventory.GetComponent<InventoryManager>().SetItemOnPosition(draggedSlot.Number, draggedSlot.Item);
|
|
|
|
// _inventory.GetComponent<InventoryManager>().SetItemOnPosition(dropItemSlot.Number, dropItemSlot.Item);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
}
|