Scriptum/Assets/Scripts/Equipment/EquipmentPanelController.cs

79 lines
2.1 KiB
C#
Raw Normal View History

2022-06-05 16:51:08 +02:00
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();
}
2022-10-23 13:29:22 +02:00
void Update()
{
if(Input.GetKeyDown("i"))
{
if (_instance)
{
_instance.GetComponent<EquipmentManager>().ClosePanel();
Destroy(gameObject); // destroy panel
}
}
}
2022-06-05 16:51:08 +02:00
public override void CloseOnClick()
{
Destroy(gameObject); // destroy panel
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;
}
2022-06-05 16:51:08 +02:00
}