StoryFightFailView.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using System.Collections.Generic;
  2. using ET;
  3. using FairyGUI;
  4. using UI.Main;
  5. using UI.CommonGame;
  6. using UnityEngine;
  7. namespace GFGGame
  8. {
  9. public class StoryFightFailView : BaseWindow
  10. {
  11. private UI_StoryFightFailUI _ui;
  12. private List<LevelTipsCfg> _cfgs = new List<LevelTipsCfg>();
  13. public override void Dispose()
  14. {
  15. if (_ui != null)
  16. {
  17. _ui.Dispose();
  18. _ui = null;
  19. }
  20. base.Dispose();
  21. }
  22. protected override void OnInit()
  23. {
  24. base.OnInit();
  25. packageName = UI_StoryFightFailUI.PACKAGE_NAME;
  26. _ui = UI_StoryFightFailUI.Create();
  27. this.viewCom = _ui.target;
  28. this.viewCom.Center();
  29. this.modal = true;
  30. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  31. _ui.m_list.itemRenderer = RenderListItem;
  32. _ui.m_comBg.GetChild("btnClose").asCom.onClick.Add(Hide);
  33. }
  34. protected override void AddEventListener()
  35. {
  36. base.AddEventListener();
  37. }
  38. protected override void OnShown()
  39. {
  40. base.OnShown();
  41. for (int i = 0; i < LevelTipsCfgArray.Instance.dataArray.Length; i++)
  42. {
  43. LevelTipsCfg cfg = LevelTipsCfgArray.Instance.dataArray[i];
  44. if (cfg.storyLevel > 0 && InstanceZonesDataManager.currentLevelCfgId != cfg.storyLevel) continue;
  45. _cfgs.Add(cfg);
  46. }
  47. _ui.m_list.numItems = _cfgs.Count;
  48. }
  49. protected override void OnHide()
  50. {
  51. base.OnHide();
  52. _cfgs.Clear();
  53. if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0);
  54. }
  55. protected override void RemoveEventListener()
  56. {
  57. base.RemoveEventListener();
  58. }
  59. private void RenderListItem(int index, GObject gObject)
  60. {
  61. UI_ListFailItem item = UI_ListFailItem.Proxy(gObject);
  62. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  63. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  64. item.m_grpRecommend.visible = _cfgs[index].isAdvise == 1;
  65. item.m_txtDesc.text = string.Format(_cfgs[index].desc, ConstDressUpScoreType.scoreTypeList()[fightCfg.scoreType]);
  66. if (item.m_btnGo.data == null)
  67. {
  68. item.m_btnGo.onClick.Add(OnBtnGoClick);
  69. }
  70. item.m_btnGo.data = _cfgs[index];
  71. UI_ListFailItem.ProxyEnd();
  72. }
  73. private void OnBtnGoClick(EventContext context)
  74. {
  75. GObject obj = context.sender as GObject;
  76. LevelTipsCfg cfg = obj.data as LevelTipsCfg;
  77. if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(cfg.jumpId)) return;
  78. object[] param = new object[cfg.jumpParamArr.Length];
  79. for (int i = 0; i < cfg.jumpParamArr.Length; i++)
  80. {
  81. param[i] = cfg.jumpParamArr[i];
  82. }
  83. if (cfg.jumpId != nameof(FirstChargeBonusView))
  84. {
  85. ViewManager.Hide<StroyFightResultView>();
  86. Hide();
  87. }
  88. ViewManager.JumpToView(cfg.jumpId, param, null);
  89. // ViewManager.Show<MainUIView>();
  90. }
  91. }
  92. }