using System.Collections.Generic; using System.Linq; using Excel2Json; using Fort23.Core; using Fort23.UTool; using GameLogic.Bag; namespace Fort23.Mono { [UIBinding(prefab = "DaoYouInfoPanel")] public partial class DaoYouInfoPanel : UIPanel { private AccountFileInfo.DaoYouData daoYouData; private DaoyouModelConfig _daoyouModelConfig; List widgetItems = new List(); List _daoYouLevelWidgets = new List(); private void Init() { IsShowAppBar = true; isAddStack = true; } protected override void AddEvent() { } protected override void DelEvent() { } public async override CTask AsyncInit(object[] uiData) { daoYouData = uiData[0] as AccountFileInfo.DaoYouData; _daoyouModelConfig = ConfigComponent.Instance.Get(daoYouData.id); await UpdateUI(); return await base.AsyncInit(uiData); } public async CTask UpdateUI() { foreach (var widgetItem in widgetItems) { UIManager.Instance.DormancyGComponent(widgetItem); } widgetItems.Clear(); foreach (var daoYouLevelWidget in _daoYouLevelWidgets) { UIManager.Instance.DormancyGComponent(daoYouLevelWidget); } _daoYouLevelWidgets.Clear(); DaoyouLevelupConfig currentDaoyouLevelupConfig = ConfigComponent.Instance.Get(daoYouData.id); Text_CurrentLevel.text = daoYouData.favorabilityLv.ToString(); // Slider_LeveUp.maxValue = currentDaoyouLevelupConfig. Slider_LeveUp.value = daoYouData.exp; if (_daoyouModelConfig.PreferGiftID != null) { foreach (var i in _daoyouModelConfig.PreferGiftID) { if (_daoyouModelConfig.shownPreferGiftID.Contains(i) || (daoYouData != null && daoYouData.loveIds.Contains(i))) { WidgetItem widgetItem = await UIManager.Instance.CreateGComponent(null, LoveItemContent); widgetItem.InitWidget(new ItemInfo(i, 0)); widgetItems.Add(widgetItem); } } } DaoyouLevelupConfig[] configs = ConfigComponent.Instance.GetAll(); foreach (var daoyouLevelupConfig in configs) { DaoYouLevelWidget daoYouLevelWidget = await UIManager.Instance.CreateGComponent(null, DaoYouLevelWidgetContent); daoYouLevelWidget.CustomInit(daoYouData,daoyouLevelupConfig.ID); _daoYouLevelWidgets.Add(daoYouLevelWidget); } } public override CTask GetFocus() { AppBarPanel.OpenPanel(this); return base.GetFocus(); } public override void AddButtonEvent() { Btn_Facorability.onClick.AddListener(() => { Info.SetActive(false); Facorability.SetActive(true); }); Btn_InfoMation.onClick.AddListener(() => { Info.SetActive(true); Facorability.SetActive(false); }); Btn_SendGift.onClick.AddListener(() => { GiveGite.gameObject.SetActive(true); AppBarPanel.ClosePanel(); }); Btn_Back.onClick.AddListener(() => { GiveGite.gameObject.SetActive(false); AppBarPanel.OpenPanel(this); }); } public static async CTask OpenPanel(AccountFileInfo.DaoYouData daoYouData) { await UIManager.Instance.LoadAndOpenPanel(null, uiData: new[] { daoYouData }); } public override void Close() { foreach (var widgetItem in widgetItems) { UIManager.Instance.DormancyGComponent(widgetItem); } widgetItems.Clear(); foreach (var daoYouLevelWidget in _daoYouLevelWidgets) { UIManager.Instance.DormancyGComponent(daoYouLevelWidget); } _daoYouLevelWidgets.Clear(); base.Close(); } } }