StoryFightFailView.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. if(cfg.jumpId == typeof(ClothingSelectView).Name && !FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(ClothingSelectView).Name, false))
  46. {
  47. continue;
  48. }
  49. _cfgs.Add(cfg);
  50. }
  51. _ui.m_list.numItems = _cfgs.Count;
  52. }
  53. protected override void OnHide()
  54. {
  55. base.OnHide();
  56. _cfgs.Clear();
  57. if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0);
  58. }
  59. protected override void RemoveEventListener()
  60. {
  61. base.RemoveEventListener();
  62. }
  63. private void RenderListItem(int index, GObject gObject)
  64. {
  65. UI_ListFailItem item = UI_ListFailItem.Proxy(gObject);
  66. FieldDataManager _dataManager = FieldDataManager.Instance;
  67. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  68. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  69. item.m_grpRecommend.visible = _cfgs[index].isAdvise == 1;
  70. int scoreType = 0;
  71. if (fightCfg.scoreType > 0)
  72. scoreType = fightCfg.scoreType;
  73. else
  74. scoreType = _dataManager.fieldInfos.theme;
  75. item.m_txtDesc.text = string.Format(_cfgs[index].desc, ConstDressUpScoreType.scoreTypeList()[scoreType]);
  76. if (item.m_btnGo.data == null)
  77. {
  78. item.m_btnGo.onClick.Add(OnBtnGoClick);
  79. }
  80. item.m_btnGo.data = _cfgs[index];
  81. UI_ListFailItem.ProxyEnd();
  82. }
  83. private void OnBtnGoClick(EventContext context)
  84. {
  85. GObject obj = context.sender as GObject;
  86. LevelTipsCfg cfg = obj.data as LevelTipsCfg;
  87. if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(cfg.jumpId)) return;
  88. object[] param = new object[cfg.jumpParamArr.Length];
  89. for (int i = 0; i < cfg.jumpParamArr.Length; i++)
  90. {
  91. param[i] = cfg.jumpParamArr[i];
  92. }
  93. if (cfg.jumpId != nameof(FirstChargeBonusView))
  94. {
  95. ViewManager.Hide<StroyFightResultView>();
  96. Hide();
  97. }
  98. ViewManager.JumpToView(cfg.jumpId, param);
  99. if (cfg.jumpId == nameof(LuckyBoxView))
  100. ViewManager.Hide<StoryChapterView>();
  101. // ViewManager.Show<MainUIView>();
  102. }
  103. }
  104. }