ChapterItemGuideView.cs 3.2 KB

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