using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; namespace Beyond { public class PowersMenuController : MonoBehaviour { [SerializeField] private MenuScroll menuScroll; [SerializeField] private bEquipArea powersArea; [SerializeField] private bItemWindow powersPicker, scrollsPicker; [SerializeField] private bInventory inventory; [SerializeField] private TMP_Text categoryText; [SerializeField] private Image quantaPowersImage, powerScrollImage; private Image currentCategoryImage = null; private List quantaPowerTypes = new List { bItemType.QuantaPower }; private List powerScrollTypes = new List { bItemType.PowerScroll }; private List currentTypes = new List(); public void OpenPowers() { OpenPowerScrollsArea(); menuScroll.OnOpened += RefreshEquipmentWindow; } public void ClosePowers() { menuScroll.OnOpened -= RefreshEquipmentWindow; } public void OpenQuantaPowersArea() { currentTypes = quantaPowerTypes; categoryText.text = "Quanta Powers"; Player.Instance.PlayCategoryChangeSound(); powersArea.SetNewItemWindow(powersPicker); scrollsPicker.gameObject.SetActive(false); powersPicker.gameObject.SetActive(true); RefreshEquipmentWindow(); EnableProperCategoryImage(quantaPowersImage); } public void OpenPowerScrollsArea() { currentTypes = powerScrollTypes; categoryText.text = "Power Scrolls"; Player.Instance.PlayCategoryChangeSound(); powersArea.SetNewItemWindow(scrollsPicker); scrollsPicker.gameObject.SetActive(true); powersPicker.gameObject.SetActive(false); RefreshEquipmentWindow(); EnableProperCategoryImage(powerScrollImage); } public void TryToOpenScrollsOnPowerGaze() { OpenPowerScrollsArea(); menuScroll.OnOpened += TryToSelectCovertGaze; } private void TryToSelectCovertGaze() { bItemSlot gazeSlot = scrollsPicker.slots.Find(slot => slot.item && slot.item.name == "Covert Gaze "); if (gazeSlot) { gazeSlot.OnSelect(null); } menuScroll.OnOpened -= TryToSelectCovertGaze; } private void EnableProperCategoryImage(Image imageToEnable) { if (currentCategoryImage != null) { currentCategoryImage.enabled = false; } currentCategoryImage = imageToEnable; currentCategoryImage.enabled = true; } public void RefreshEquipmentWindow() { powersArea.SetEquipmentwindowWithFilter(currentTypes); } private void OnDestroy() { if (menuScroll) { menuScroll.OnOpened -= RefreshEquipmentWindow; } if (inventory) { inventory.OnUpdateInventory -= RefreshEquipmentWindow; } } } }