Scriptum/Assets/Scripts/Equipment/EquipmentPanelController.cs
2022-06-05 20:01:56 +02:00

66 lines
1.8 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();
}
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;
}
}