BtnFaBaoWidget.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using GameLogic.Hero;
  2. using UnityEngine;
  3. namespace Fort23.Mono
  4. {
  5. [UIBinding(prefab = "BtnFaBaoWidget")]
  6. public partial class BtnFaBaoWidget : ItemWidgetBasic
  7. {
  8. public int index;
  9. private FaBaoWidget faBaoWidget;
  10. private void Init()
  11. {
  12. }
  13. public override void AddEvent()
  14. {
  15. }
  16. public override void DelEvent()
  17. {
  18. }
  19. public override void AddButtonEvent()
  20. {
  21. base.AddButtonEvent();
  22. }
  23. public async void CustomInit(int index)
  24. {
  25. own.name = "BtnFaBaoWidget" + index;
  26. UIManager.Instance.DormancyGComponent(faBaoWidget);
  27. faBaoWidget = null;
  28. this.index = index;
  29. FaBaoInfo faBaoInfo = PlayerManager.Instance.FaBaoControl.FightFaBao[index];
  30. if (faBaoInfo != null)
  31. {
  32. faBaoWidget = await UIManager.Instance.CreateGComponent<FaBaoWidget>(null, FaBaoRoot);
  33. faBaoWidget.CustomInit(faBaoInfo, false);
  34. faBaoWidget.transform.anchorMin = new Vector2(0.5f, 0.5f);
  35. faBaoWidget.transform.anchorMax = new Vector2(0.5f, 0.5f);
  36. faBaoWidget.transform.pivot = new Vector2(0.5f, 0.5f);
  37. faBaoWidget.transform.anchoredPosition = Vector2.zero;
  38. }
  39. else
  40. {
  41. UIManager.Instance.DormancyGComponent(faBaoWidget);
  42. faBaoWidget = null;
  43. }
  44. RedDotComType01.CustomInit(9, new object[] { faBaoInfo, index });
  45. if (index > PlayerManager.Instance.myHero.powerUpConfig.MaxFabaoNum - 1)
  46. {
  47. reorderableListElement.isNoCalculation = true;
  48. reorderableListElement.IsGrabbable = false;
  49. }
  50. else
  51. {
  52. reorderableListElement.isNoCalculation = false;
  53. reorderableListElement.IsGrabbable = true;
  54. }
  55. }
  56. public override void DormancyObj()
  57. {
  58. UIManager.Instance.DormancyGComponent(faBaoWidget);
  59. faBaoWidget = null;
  60. base.DormancyObj();
  61. }
  62. }
  63. }