HeroBreakthroughSuccessPanel.cs 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using System.Collections.Generic;
  2. using Core.Language;
  3. using Fort23.Core;
  4. using GameLogic.Hero;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. namespace Fort23.Mono
  8. {
  9. [UIBinding(prefab = "HeroBreakthroughSuccessPanel")]
  10. public partial class HeroBreakthroughSuccessPanel : UIPanel
  11. {
  12. List<UIComponent> heroAttributeWidgets = new List<UIComponent>();
  13. private void Init()
  14. {
  15. }
  16. protected override void AddEvent()
  17. {
  18. }
  19. protected override void DelEvent()
  20. {
  21. }
  22. public override void AddButtonEvent()
  23. {
  24. Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
  25. }
  26. int type;
  27. public async static CTask<HeroBreakthroughSuccessPanel> OpenPanel(int type, List<HeroAttributeData> heroAttributes)
  28. {
  29. HeroBreakthroughSuccessPanel heroBreakthroughSuccessPanel = await UIManager.Instance.LoadAndOpenPanel<HeroBreakthroughSuccessPanel>(null, UILayer.Top, isFocus: false);
  30. heroBreakthroughSuccessPanel.CustomInit(type, heroAttributes);
  31. return heroBreakthroughSuccessPanel;
  32. }
  33. public async void CustomInit(int type, List<HeroAttributeData> heroAttributes)
  34. {
  35. HeroInfo heroInfo = new HeroInfo();
  36. heroInfo.InitHero(PlayerManager.Instance.myHero.heroData.heroModelId, PlayerManager.Instance.myHero.heroData.heroPowerId + 1);
  37. Text_CurretnJIngjie.text = LanguageManager.Instance.Text(PlayerManager.Instance.myHero.powerUpConfig.jingjieLanIDs[0]) +
  38. LanguageManager.Instance.Text(PlayerManager.Instance.myHero.powerUpConfig.jingjieLanIDs[1]) +
  39. LanguageManager.Instance.Text(PlayerManager.Instance.myHero.powerUpConfig.jingjieLanIDs[2]);
  40. Text_NextJIngjie.text = LanguageManager.Instance.Text(heroInfo.powerUpConfig.jingjieLanIDs[0]) +
  41. LanguageManager.Instance.Text(heroInfo.powerUpConfig.jingjieLanIDs[1]) +
  42. LanguageManager.Instance.Text(heroInfo.powerUpConfig.jingjieLanIDs[2]);
  43. if (type == 1 || type == 2)
  44. {
  45. Icon_Tu.gameObject.SetActive(true);
  46. Icon_Dj.gameObject.SetActive(false);
  47. }
  48. else
  49. {
  50. Icon_Tu.gameObject.SetActive(false);
  51. Icon_Dj.gameObject.SetActive(true);
  52. }
  53. foreach (var heroAttributeData in heroAttributes)
  54. {
  55. if (type == 1)
  56. {
  57. HeroAttributeWidgetType1 heroAttributeWidget = await UIManager.Instance.CreateGComponent<HeroAttributeWidgetType1>(null, AttributeRoot);
  58. heroAttributeWidget.CustomInit(heroAttributeData);
  59. heroAttributeWidgets.Add(heroAttributeWidget);
  60. }
  61. else
  62. {
  63. HeroAttributeWidgetType2 heroAttributeWidget = await UIManager.Instance.CreateGComponent<HeroAttributeWidgetType2>(null, AttributeRoot);
  64. heroAttributeWidget.CustomInit(heroAttributeData);
  65. heroAttributeWidgets.Add(heroAttributeWidget);
  66. }
  67. }
  68. LayoutRebuilder.ForceRebuildLayoutImmediate(AttributeRoot);
  69. LayoutRebuilder.ForceRebuildLayoutImmediate(AttributeRoot.parent.GetComponent<RectTransform>());
  70. }
  71. public override void Close()
  72. {
  73. foreach (var heroAttributeWidget in heroAttributeWidgets)
  74. {
  75. UIManager.Instance.DormancyGComponent(heroAttributeWidget);
  76. }
  77. heroAttributeWidgets.Clear();
  78. base.Close();
  79. }
  80. }
  81. }