83 lines
2.2 KiB
C#
83 lines
2.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class EquipmentPanelController : BasePanelController
|
|
{
|
|
[Header("Slots List")]
|
|
[SerializeField] public const int MAX_SLOT_CUNT = 0;
|
|
[SerializeField] public EquipmentSlot _helmet;
|
|
[SerializeField] public EquipmentSlot _chest;
|
|
[SerializeField] public EquipmentSlot _boots;
|
|
[SerializeField] public EquipmentSlot _weapon;
|
|
[SerializeField] public EquipmentSlot _potion_one;
|
|
[SerializeField] public EquipmentSlot _potion_two;
|
|
[SerializeField] public EquipmentSlot _potion_three;
|
|
[SerializeField] public EquipmentSlot _potion_four;
|
|
[SerializeField] public EquipmentSlot _potion_five;
|
|
|
|
Dictionary<int, EquipmentSlot> equipment;
|
|
|
|
// overrwrite this metoh in in parent beacuse we dont have to init any slots
|
|
void Awake()
|
|
{
|
|
base.MAX_SLOT_CUNT = 9;
|
|
|
|
equipment = new Dictionary<int, EquipmentSlot>() {
|
|
{ 0, _helmet },
|
|
{ 1, _chest },
|
|
{ 2, _boots },
|
|
{ 3, _weapon },
|
|
{ 4, _potion_one },
|
|
{ 5, _potion_two },
|
|
{ 6, _potion_three },
|
|
{ 7, _potion_four },
|
|
{ 8, _potion_five }
|
|
};
|
|
|
|
base.Awake();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if(Input.GetKeyDown("i"))
|
|
{
|
|
if (_instance)
|
|
{
|
|
_instance.GetComponent<EquipmentManager>().ClosePanel();
|
|
Destroy(gameObject); // destroy panel
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void CloseOnClick()
|
|
{
|
|
Destroy(gameObject); // destroy panel
|
|
GameObject panel = FindObjectOfType<ChestPanelController>()?.gameObject;
|
|
if(panel != null) Destroy(panel);
|
|
FindObjectOfType<InventoryManager>()?.ClosePanel();
|
|
|
|
|
|
if(_instance)
|
|
{
|
|
_instance.GetComponent<EquipmentManager>().ClosePanel();
|
|
}
|
|
}
|
|
|
|
public void Setup(GameObject _equipment, Dictionary<int, Item> _equipmentItems)
|
|
{
|
|
_instance = _equipment;
|
|
|
|
base.Setup(_equipmentItems);
|
|
}
|
|
|
|
protected override ISlot SetupSlot(int key, GameObject _parent)
|
|
{
|
|
ISlot tmp = equipment[key];
|
|
tmp.SetupSlot(key, null, this);
|
|
|
|
return tmp;
|
|
}
|
|
|
|
}
|