DaoYouInfoPanel.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using Excel2Json;
  4. using Fort23.Core;
  5. using Fort23.UTool;
  6. using GameLogic.Bag;
  7. namespace Fort23.Mono
  8. {
  9. [UIBinding(prefab = "DaoYouInfoPanel")]
  10. public partial class DaoYouInfoPanel : UIPanel
  11. {
  12. private AccountFileInfo.DaoYouData daoYouData;
  13. private DaoyouModelConfig _daoyouModelConfig;
  14. List<WidgetItem> widgetItems = new List<WidgetItem>();
  15. List<DaoYouLevelWidget> _daoYouLevelWidgets = new List<DaoYouLevelWidget>();
  16. private void Init()
  17. {
  18. IsShowAppBar = true;
  19. isAddStack = true;
  20. }
  21. protected override void AddEvent()
  22. {
  23. }
  24. protected override void DelEvent()
  25. {
  26. }
  27. public async override CTask<bool> AsyncInit(object[] uiData)
  28. {
  29. daoYouData = uiData[0] as AccountFileInfo.DaoYouData;
  30. _daoyouModelConfig = ConfigComponent.Instance.Get<DaoyouModelConfig>(daoYouData.id);
  31. await UpdateUI();
  32. return await base.AsyncInit(uiData);
  33. }
  34. public async CTask UpdateUI()
  35. {
  36. foreach (var widgetItem in widgetItems)
  37. {
  38. UIManager.Instance.DormancyGComponent(widgetItem);
  39. }
  40. widgetItems.Clear();
  41. foreach (var daoYouLevelWidget in _daoYouLevelWidgets)
  42. {
  43. UIManager.Instance.DormancyGComponent(daoYouLevelWidget);
  44. }
  45. _daoYouLevelWidgets.Clear();
  46. DaoyouLevelupConfig currentDaoyouLevelupConfig = ConfigComponent.Instance.Get<DaoyouLevelupConfig>(daoYouData.id);
  47. Text_CurrentLevel.text = daoYouData.favorabilityLv.ToString();
  48. // Slider_LeveUp.maxValue = currentDaoyouLevelupConfig.
  49. Slider_LeveUp.value = daoYouData.exp;
  50. if (_daoyouModelConfig.PreferGiftID != null)
  51. {
  52. foreach (var i in _daoyouModelConfig.PreferGiftID)
  53. {
  54. if (_daoyouModelConfig.shownPreferGiftID.Contains(i) || (daoYouData != null && daoYouData.loveIds.Contains(i)))
  55. {
  56. WidgetItem widgetItem = await UIManager.Instance.CreateGComponent<WidgetItem>(null, LoveItemContent);
  57. widgetItem.InitWidget(new ItemInfo(i, 0));
  58. widgetItems.Add(widgetItem);
  59. }
  60. }
  61. }
  62. DaoyouLevelupConfig[] configs = ConfigComponent.Instance.GetAll<DaoyouLevelupConfig>();
  63. foreach (var daoyouLevelupConfig in configs)
  64. {
  65. DaoYouLevelWidget daoYouLevelWidget = await UIManager.Instance.CreateGComponent<DaoYouLevelWidget>(null, DaoYouLevelWidgetContent);
  66. daoYouLevelWidget.CustomInit(daoYouData,daoyouLevelupConfig.ID);
  67. _daoYouLevelWidgets.Add(daoYouLevelWidget);
  68. }
  69. }
  70. public override CTask GetFocus()
  71. {
  72. AppBarPanel.OpenPanel(this);
  73. return base.GetFocus();
  74. }
  75. public override void AddButtonEvent()
  76. {
  77. Btn_Facorability.onClick.AddListener(() =>
  78. {
  79. Info.SetActive(false);
  80. Facorability.SetActive(true);
  81. });
  82. Btn_InfoMation.onClick.AddListener(() =>
  83. {
  84. Info.SetActive(true);
  85. Facorability.SetActive(false);
  86. });
  87. Btn_SendGift.onClick.AddListener(() =>
  88. {
  89. GiveGite.gameObject.SetActive(true);
  90. AppBarPanel.ClosePanel();
  91. });
  92. Btn_Back.onClick.AddListener(() =>
  93. {
  94. GiveGite.gameObject.SetActive(false);
  95. AppBarPanel.OpenPanel(this);
  96. });
  97. }
  98. public static async CTask OpenPanel(AccountFileInfo.DaoYouData daoYouData)
  99. {
  100. await UIManager.Instance.LoadAndOpenPanel<DaoYouInfoPanel>(null, uiData: new[] { daoYouData });
  101. }
  102. public override void Close()
  103. {
  104. foreach (var widgetItem in widgetItems)
  105. {
  106. UIManager.Instance.DormancyGComponent(widgetItem);
  107. }
  108. widgetItems.Clear();
  109. foreach (var daoYouLevelWidget in _daoYouLevelWidgets)
  110. {
  111. UIManager.Instance.DormancyGComponent(daoYouLevelWidget);
  112. }
  113. _daoYouLevelWidgets.Clear();
  114. base.Close();
  115. }
  116. }
  117. }