ChapterItemGuideView.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. isReturnView = true;
  27. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  28. _ui.m_list.itemRenderer = RenderListItem;
  29. _ui.m_list.onClickItem.Add(OnListItemClick);
  30. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("hc_bj_1");
  31. }
  32. protected override void AddEventListener()
  33. {
  34. base.AddEventListener();
  35. }
  36. protected override void OnShown()
  37. {
  38. base.OnShown();
  39. culturalRelicCfg = CulturalRelicCfgArray.Instance.dataArray;
  40. _ui.m_list.numItems = culturalRelicCfg.Length;
  41. }
  42. protected override void OnHide()
  43. {
  44. base.OnHide();
  45. }
  46. protected override void RemoveEventListener()
  47. {
  48. base.RemoveEventListener();
  49. }
  50. private void OnClickBtnBack()
  51. {
  52. ViewManager.GoBackFrom(typeof(ChapterItemGuideView).FullName);
  53. _ui.m_list.scrollPane.ScrollTop();
  54. }
  55. private void RenderListItem(int index, GObject obj)
  56. {
  57. CulturalRelicCfg cfg = culturalRelicCfg[index];
  58. StoryChapterCfg storyChapterCfg = StoryChapterCfgArray.Instance.GetCfg(cfg.chapterId);
  59. UI_ChapterGuideItem item = UI_ChapterGuideItem.Proxy(obj);
  60. item.m_loaIcon.url = ResPathUtil.GetChapterGuideIconPath(cfg.bgRes);// string.Format("ui://FieldGuide/{0}", cfg.iconRes);
  61. bool isPass = InstanceZonesDataManager.CheckChapterPass(storyChapterCfg.type, storyChapterCfg.subType, storyChapterCfg.id, storyChapterCfg.levelCount);
  62. item.m_grpLock.visible = !isPass;
  63. item.m_txtDesc.text = string.Format("通关主线第{0}章解锁", NumberUtil.GetChiniseNumberText(storyChapterCfg.order));
  64. item.target.data = cfg;
  65. }
  66. private void OnListItemClick(EventContext context)
  67. {
  68. CulturalRelicCfg cfg = (context.data as GObject).data as CulturalRelicCfg;
  69. StoryChapterCfg storyChapterCfg = StoryChapterCfgArray.Instance.GetCfg(cfg.chapterId);
  70. bool isPass = InstanceZonesDataManager.CheckChapterPass(storyChapterCfg.type, storyChapterCfg.subType, storyChapterCfg.id, storyChapterCfg.levelCount);
  71. if (!isPass)
  72. {
  73. PromptController.Instance.ShowFloatTextPrompt("暂未解锁");
  74. return;
  75. }
  76. ViewManager.Show<ChapterItemShowView>(cfg);
  77. }
  78. }
  79. }