StoryFightFailView.cs 3.0 KB

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