104 lines
3.3 KiB
C#
104 lines
3.3 KiB
C#
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<bItemType> locationTypes = new List<bItemType> { bItemType.Locations };
|
|
private List<bItemType> legendsTypes = new List<bItemType> { bItemType.Characters };
|
|
private List<bItemType> protocolsTypes = new List<bItemType> { bItemType.Science };
|
|
private List<bItemType> gameplayTypes = new List<bItemType> { bItemType.ChronicleResources };
|
|
public List<bItemType> currentTypes = new List<bItemType>();
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
} |