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 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() { { 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().ClosePanel(); Destroy(gameObject); // destroy panel } } } public override void CloseOnClick() { Destroy(gameObject); // destroy panel GameObject panel = FindObjectOfType()?.gameObject; if(panel != null) Destroy(panel); FindObjectOfType()?.ClosePanel(); if(_instance) { _instance.GetComponent().ClosePanel(); } } public void Setup(GameObject _equipment, Dictionary _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; } }