123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- 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<WidgetItem> widgetItems = new List<WidgetItem>();
- List<DaoYouLevelWidget> _daoYouLevelWidgets = new List<DaoYouLevelWidget>();
- private void Init()
- {
- IsShowAppBar = true;
- isAddStack = true;
- }
- protected override void AddEvent()
- {
- }
- protected override void DelEvent()
- {
- }
- public async override CTask<bool> AsyncInit(object[] uiData)
- {
- daoYouData = uiData[0] as AccountFileInfo.DaoYouData;
- _daoyouModelConfig = ConfigComponent.Instance.Get<DaoyouModelConfig>(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<DaoyouLevelupConfig>(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<WidgetItem>(null, LoveItemContent);
- widgetItem.InitWidget(new ItemInfo(i, 0));
- widgetItems.Add(widgetItem);
- }
- }
- }
- DaoyouLevelupConfig[] configs = ConfigComponent.Instance.GetAll<DaoyouLevelupConfig>();
- foreach (var daoyouLevelupConfig in configs)
- {
- DaoYouLevelWidget daoYouLevelWidget = await UIManager.Instance.CreateGComponent<DaoYouLevelWidget>(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<DaoYouInfoPanel>(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();
- }
- }
- }
|