ChapterItemGuideView.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using System.Collections.Generic;
  2. using FairyGUI;
  3. using UI.FieldGuide;
  4. namespace GFGGame
  5. {
  6. public class ChapterItemGuideView : BaseWindow
  7. {
  8. private UI_ChapterItemGuideUI _ui;
  9. private CulturalRelicCfg[] culturalRelicCfg;
  10. public override void Dispose()
  11. {
  12. if (_ui != null)
  13. {
  14. _ui.Dispose();
  15. _ui = null;
  16. }
  17. base.Dispose();
  18. }
  19. protected override void OnInit()
  20. {
  21. base.OnInit();
  22. packageName = UI_ChapterItemGuideUI.PACKAGE_NAME;
  23. _ui = UI_ChapterItemGuideUI.Create();
  24. this.viewCom = _ui.target;
  25. isfullScreen = true;
  26. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  27. _ui.m_list.itemRenderer = RenderListItem;
  28. _ui.m_list.onClickItem.Add(OnListItemClick);
  29. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("hc_bj_1");
  30. }
  31. protected override void AddEventListener()
  32. {
  33. base.AddEventListener();
  34. }
  35. protected override void OnShown()
  36. {
  37. base.OnShown();
  38. culturalRelicCfg = CulturalRelicCfgArray.Instance.dataArray;
  39. _ui.m_list.numItems = culturalRelicCfg.Length;
  40. }
  41. protected override void OnHide()
  42. {
  43. base.OnHide();
  44. }
  45. protected override void RemoveEventListener()
  46. {
  47. base.RemoveEventListener();
  48. }
  49. private void OnClickBtnBack()
  50. {
  51. ViewManager.GoBackFrom(typeof(ChapterItemGuideView).FullName);
  52. }
  53. private void RenderListItem(int index, GObject obj)
  54. {
  55. CulturalRelicCfg cfg = culturalRelicCfg[index];
  56. StoryChapterCfg storyChapterCfg = StoryChapterCfgArray.Instance.GetCfg(cfg.chapterId);
  57. UI_ChapterGuideItem item = UI_ChapterGuideItem.Proxy(obj);
  58. item.m_loaIcon.url = string.Format("ui://FieldGuide/{0}", cfg.iconRes);
  59. bool isPass = InstanceZonesDataManager.CheckChapterPass(storyChapterCfg.type, storyChapterCfg.subType, storyChapterCfg.id, storyChapterCfg.levelCount);
  60. item.m_grpLock.visible = !isPass;
  61. item.m_txtDesc.text = string.Format("通关主线第{0}章解锁", NumberUtil.GetChiniseNumberText(storyChapterCfg.order));
  62. item.target.data = cfg;
  63. }
  64. private void OnListItemClick(EventContext context)
  65. {
  66. CulturalRelicCfg cfg = (context.data as GObject).data as CulturalRelicCfg;
  67. StoryChapterCfg storyChapterCfg = StoryChapterCfgArray.Instance.GetCfg(cfg.chapterId);
  68. bool isPass = InstanceZonesDataManager.CheckChapterPass(storyChapterCfg.type, storyChapterCfg.subType, storyChapterCfg.id, storyChapterCfg.levelCount);
  69. if (!isPass)
  70. {
  71. PromptController.Instance.ShowFloatTextPrompt("暂未解锁");
  72. return;
  73. }
  74. ViewManager.Show<ChapterItemShowView>(cfg, new object[] { typeof(ChapterItemGuideView).FullName, this.viewData });
  75. }
  76. }
  77. }