ChapterItemGuideView.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. _ui.m_list.scrollPane.ScrollTop();
  53. }
  54. private void RenderListItem(int index, GObject obj)
  55. {
  56. CulturalRelicCfg cfg = culturalRelicCfg[index];
  57. StoryChapterCfg storyChapterCfg = StoryChapterCfgArray.Instance.GetCfg(cfg.chapterId);
  58. UI_ChapterGuideItem item = UI_ChapterGuideItem.Proxy(obj);
  59. item.m_loaIcon.url = ResPathUtil.GetChapterGuideIconPath(cfg.bgRes);// string.Format("ui://FieldGuide/{0}", cfg.iconRes);
  60. bool isPass = InstanceZonesDataManager.CheckChapterPass(storyChapterCfg.type, storyChapterCfg.subType, storyChapterCfg.id, storyChapterCfg.levelCount);
  61. item.m_grpLock.visible = !isPass;
  62. item.m_txtDesc.text = string.Format("通关主线第{0}章解锁", NumberUtil.GetChiniseNumberText(storyChapterCfg.order));
  63. item.target.data = cfg;
  64. }
  65. private void OnListItemClick(EventContext context)
  66. {
  67. CulturalRelicCfg cfg = (context.data as GObject).data as CulturalRelicCfg;
  68. StoryChapterCfg storyChapterCfg = StoryChapterCfgArray.Instance.GetCfg(cfg.chapterId);
  69. bool isPass = InstanceZonesDataManager.CheckChapterPass(storyChapterCfg.type, storyChapterCfg.subType, storyChapterCfg.id, storyChapterCfg.levelCount);
  70. if (!isPass)
  71. {
  72. PromptController.Instance.ShowFloatTextPrompt("暂未解锁");
  73. return;
  74. }
  75. ViewManager.Show<ChapterItemShowView>(cfg, new object[] { typeof(ChapterItemGuideView).FullName, this.viewData });
  76. }
  77. }
  78. }