using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; namespace Beyond { public class ChroniclesMenuController : MonoBehaviour { // Start is called before the first frame update [SerializeField] private MenuScroll menuScroll; [SerializeField] private bEquipArea resourcesArea; [SerializeField] private bItemWindow itemPicker; [SerializeField] private bInventory inventory; [SerializeField] private TMP_Text categoryText; [SerializeField] private Image locationsImage, legendsImage, protocolsImage, gameplayImage; private Image currentCategoryImage = null; private List locationTypes = new List { bItemType.Locations }; private List legendsTypes = new List { bItemType.Characters }; private List protocolsTypes = new List { bItemType.Science }; private List gameplayTypes = new List { bItemType.ChronicleResources }; public List currentTypes = new List(); public void OpenChronicles() { resourcesArea.SetNewItemWindow(itemPicker); OpenLocationsArea(); menuScroll.OnOpened += RefreshEquipmentWindow; } public void CloseChronicles() { menuScroll.OnOpened -= RefreshEquipmentWindow; } public void OpenLocationsArea() { currentTypes = locationTypes; categoryText.text = "Locations"; RefreshEquipmentWindow(); Player.Instance.PlayCategoryChangeSound(); EnableProperCategoryImage(locationsImage); } public void OpenLegendsArea() { currentTypes = legendsTypes; categoryText.text = "Characters"; RefreshEquipmentWindow(); Player.Instance.PlayCategoryChangeSound(); EnableProperCategoryImage(legendsImage); } public void OpenProtocolsArea() { currentTypes = protocolsTypes; categoryText.text = "Science"; RefreshEquipmentWindow(); Player.Instance.PlayCategoryChangeSound(); EnableProperCategoryImage(protocolsImage); } public void OpenGameplayArea() { currentTypes = gameplayTypes; categoryText.text = "Resources"; RefreshEquipmentWindow(); Player.Instance.PlayCategoryChangeSound(); EnableProperCategoryImage(gameplayImage); } private void EnableProperCategoryImage(Image imageToEnable) { if (currentCategoryImage != null) { currentCategoryImage.enabled = false; } currentCategoryImage = imageToEnable; currentCategoryImage.enabled = true; } public void RefreshEquipmentWindow() { resourcesArea.SetEquipmentwindowWithFilter(currentTypes); } private void OnDestroy() { if (menuScroll) { menuScroll.OnOpened -= RefreshEquipmentWindow; } if (inventory) { inventory.OnUpdateInventory -= RefreshEquipmentWindow; } } } }