81 lines
2.7 KiB
C#
81 lines
2.7 KiB
C#
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
|
|
GameObject panel = FindObjectOfType<ChestPanelController>()?.gameObject;
|
|
if(panel != null) Destroy(panel);
|
|
GameObject.FindObjectOfType<EquipmentManager>()?.ClosePanel();
|
|
InventoryManager.Instance.GetComponent<InventoryManager>().ClosePanel();
|
|
}
|
|
|
|
public void Setup(GameObject _inventory, Dictionary<int, Item> _items)
|
|
{
|
|
_instance = _inventory;
|
|
|
|
base.Setup(_items);
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (Input.GetKeyDown("i"))
|
|
{
|
|
Destroy(gameObject); // destroy panel
|
|
|
|
InventoryManager.Instance.GetComponent<InventoryManager>().ClosePanel();
|
|
}
|
|
}
|
|
|
|
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);
|
|
// }
|
|
// }
|
|
|
|
}
|