StoryFightFailView.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. FieldDataManager _dataManager = FieldDataManager.Instance;
  63. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  64. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  65. item.m_grpRecommend.visible = _cfgs[index].isAdvise == 1;
  66. int scoreType = 0;
  67. if (fightCfg.scoreType > 0)
  68. scoreType = fightCfg.scoreType;
  69. else
  70. scoreType = _dataManager.fieldInfos.theme;
  71. item.m_txtDesc.text = string.Format(_cfgs[index].desc, ConstDressUpScoreType.scoreTypeList()[scoreType]);
  72. if (item.m_btnGo.data == null)
  73. {
  74. item.m_btnGo.onClick.Add(OnBtnGoClick);
  75. }
  76. item.m_btnGo.data = _cfgs[index];
  77. UI_ListFailItem.ProxyEnd();
  78. }
  79. private void OnBtnGoClick(EventContext context)
  80. {
  81. GObject obj = context.sender as GObject;
  82. LevelTipsCfg cfg = obj.data as LevelTipsCfg;
  83. if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(cfg.jumpId)) return;
  84. object[] param = new object[cfg.jumpParamArr.Length];
  85. for (int i = 0; i < cfg.jumpParamArr.Length; i++)
  86. {
  87. param[i] = cfg.jumpParamArr[i];
  88. }
  89. if (cfg.jumpId != nameof(FirstChargeBonusView))
  90. {
  91. ViewManager.Hide<StroyFightResultView>();
  92. Hide();
  93. }
  94. ViewManager.JumpToView(cfg.jumpId, param);
  95. if (cfg.jumpId == nameof(LuckyBoxView))
  96. ViewManager.Hide<StoryChapterView>();
  97. // ViewManager.Show<MainUIView>();
  98. }
  99. }
  100. }