StoryFightFailView.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. }
  54. protected override void RemoveEventListener()
  55. {
  56. base.RemoveEventListener();
  57. }
  58. private void RenderListItem(int index, GObject gObject)
  59. {
  60. UI_ListFailItem item = UI_ListFailItem.Proxy(gObject);
  61. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  62. StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  63. item.m_grpRecommend.visible = _cfgs[index].isAdvise == 1;
  64. item.m_txtDesc.text = string.Format(_cfgs[index].desc, ConstDressUpScoreType.scoreTypeList()[fightCfg.scoreType]);
  65. if (item.m_btnGo.data == null)
  66. {
  67. item.m_btnGo.onClick.Add(OnBtnGoClick);
  68. }
  69. item.m_btnGo.data = _cfgs[index];
  70. UI_ListFailItem.ProxyEnd();
  71. }
  72. private void OnBtnGoClick(EventContext context)
  73. {
  74. GObject obj = context.sender as GObject;
  75. LevelTipsCfg cfg = obj.data as LevelTipsCfg;
  76. if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(cfg.jumpId)) return;
  77. object[] param = new object[cfg.jumpParamArr.Length];
  78. for (int i = 0; i < cfg.jumpParamArr.Length; i++)
  79. {
  80. param[i] = cfg.jumpParamArr[i];
  81. }
  82. Hide();
  83. ViewManager.Hide<StroyFightResultView>();
  84. ViewManager.JumpToView(cfg.jumpId, param, null, false);
  85. }
  86. }
  87. }