SummonScoreAwardWidget.cs 1.9 KB

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