using System.Collections.Generic; using Animancer; using Logic; using Logic.Multilingual; using RuntimeData; using TH1_Core.Events; using TH1_Core.Managers; using TH1_Logic.Core; using TH1Resource; using TMPro; using TMPro.Examples; using UnityEngine; using UnityEngine.UI; namespace UI.LibraryUI { public enum LibrarySubUIType { None, Force, Giant, Wonder, Achievement } public abstract class LibrarySubUIBase { //成就大类 public LibrarySubUIType Type; //成就大类的id public int AchievementBigId; //对应整个panel,listpanel和infopanel public GameObject Panel; public GameObject ListPanel; public GameObject InfoPanel; public GameObject ListTable; public GameObject ListDefault; public LibraryUI LibraryUI; //进入该panel的总开关 public Button EnterButton; //记录当前是否正在展示 public bool IsSelectPanel; //默认list选择的目标 public Transform SelectedListItem; public Transform DefaultListItem; protected LibrarySubUIBase(LibrarySubUIType type, Button enterButton,GameObject panel,LibraryUI libraryUI) { LibraryUI = libraryUI; EnterButton = enterButton; Type = type; Panel = panel; ListPanel = panel.transform.Find("ListPanel").gameObject; InfoPanel = panel.transform.Find("InfoPanel").gameObject; ListTable = ListPanel.transform.Find("Scroll View/Viewport/Content").gameObject; EnterButton.onClick.AddListener(() => { LibraryUI.SwitchToPanel(Type); }); } //对外只有两个函数:Show和Hide public abstract void Show(); public abstract void Hide(); //更新listpanel的信息 protected abstract void UpdateListPanel(); //更新infopanel的信息 protected abstract void UpdateInfoPanel(); //switch到这个panel之前要做的初始化函数 protected abstract void SetDefaultItem(); protected virtual void DeselectButton() { //设置文字alpha=64 var text = EnterButton.gameObject.transform.Find("Text")?.GetComponent(); if (text != null) { Color color = text.color; color.a = 64 / 255f; text.color = color; } //设置button颜色 var button = EnterButton.GetComponent(); if (button != null) button.color = new Color(136/255f, 136/255f, 136/255f, 93 / 255f); } protected virtual void SelectButton() { //设置文字alpha=255 var text = EnterButton.gameObject.transform.Find("Text")?.GetComponent(); if (text != null) { Color color = text.color; color.a = 1f; text.color = color; } //设置button颜色 var button = EnterButton.GetComponent(); if (button != null) button.color = new Color(1f, 1f, 1f, 1f); } protected virtual void ClosePanel() { //topbar 的button要改为熄灭 DeselectButton(); //panel要隐藏 var anim = Panel.GetComponent(); if (anim != null) anim.Play(ResourceCache.Instance.AnimCache.UICommonPanelFadeOut); Timer.Instance.TimerRegister(this,()=>{Panel.SetActive(false);},ResourceCache.Instance.AnimCache.UICommonPanelFadeOut.length,"LibraryUI_ClosePanel"); IsSelectPanel = false; } protected virtual void OpenPanel() { //topbar的button要改为选中 SelectButton(); Panel.SetActive(true); //panel要显示 var anim = Panel.GetComponent(); if (anim != null) anim.Play(ResourceCache.Instance.AnimCache.UICommonPanelFadeIn); IsSelectPanel = true; } } public class LibraryUI { private Main _main; private MapData _mapData; public GameObject ROLibraryUI; public bool NeedShow = false; private bool _isShowing = false; private bool _isAnimating = false; //记录当前的panel之间是否正在互相切换 private bool _isSwitching = false; public Dictionary SubUIDict = new(); public LibrarySubUIType SelectedSubUIType = LibrarySubUIType.None; public LibraryUI(Main main, MapData mapData) { _main = main; _mapData = mapData; ROLibraryUI = UIManager.Instance.ROUIManager.transform.Find("GameUI/LibraryUI").gameObject; ROLibraryUI.transform.Find("CloseButton").GetComponent