SummonScoreAwardWidget.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.Collections.Generic;
  3. using Excel2Json;
  4. using GameLogic.Bag;
  5. using UnityEngine.UI;
  6. namespace Fort23.Mono
  7. {
  8. [UIBinding(prefab = "SummonScoreAwardWidget")]
  9. public partial class SummonScoreAwardWidget : UIComponent
  10. {
  11. List<WidgetItem> _widgetItems = new List<WidgetItem>();
  12. public OpenBoxProgressReward _openBoxProgressReward = new OpenBoxProgressReward();
  13. private Action lingquCallBack;
  14. private void Init()
  15. {
  16. }
  17. public override void AddEvent()
  18. {
  19. }
  20. public override void DelEvent()
  21. {
  22. }
  23. public override void AddButtonEvent()
  24. {
  25. Btn_LingQu.onClick.AddListener(() =>
  26. {
  27. lingquCallBack?.Invoke();
  28. Btn_LingQu.gameObject.SetActive(false);
  29. });
  30. }
  31. public async void CustomInit(OpenBoxProgressReward openBoxProgressReward, Action lingquCallBack)
  32. {
  33. this.lingquCallBack = lingquCallBack;
  34. _openBoxProgressReward = openBoxProgressReward;
  35. Text_Name.text = $"累计达到 {openBoxProgressReward.TotalScore}";
  36. for (var i = 0; i < openBoxProgressReward.PrizeID.Length; i++)
  37. {
  38. WidgetItem widgetItem =
  39. await UIManager.Instance.CreateGComponentForObject<WidgetItem>(WidgetItemGam, null, ItemRoot);
  40. widgetItem.InitWidget(new ItemInfo(openBoxProgressReward.PrizeID[i],
  41. openBoxProgressReward.PrizeCount[i]));
  42. _widgetItems.Add(widgetItem);
  43. }
  44. LayoutRebuilder.ForceRebuildLayoutImmediate(ItemRoot);
  45. }
  46. public override void DormancyObj()
  47. {
  48. foreach (var widgetItem in _widgetItems)
  49. {
  50. UIManager.Instance.DormancyGComponent(widgetItem);
  51. }
  52. _widgetItems.Clear();
  53. Icon_Select.gameObject.SetActive(false);
  54. Btn_LingQu.gameObject.SetActive(false);
  55. base.DormancyObj();
  56. }
  57. }
  58. }