ChapterItemGuideView.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 List<StoryChapterCfg> _storychapterDatas = new List<StoryChapterCfg>();
  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. }
  30. protected override void AddEventListener()
  31. {
  32. base.AddEventListener();
  33. }
  34. protected override void OnShown()
  35. {
  36. base.OnShown();
  37. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("hc_bj_1");
  38. _storychapterDatas = StoryChapterCfgArray.Instance.GetCfgsBysubType(ConstInstanceZonesSubType.Normal);
  39. _ui.m_list.numItems = _storychapterDatas.Count - 1;
  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. StoryChapterCfg cfg = _storychapterDatas[index + 1];
  56. UI_ChapterGuideItem item = UI_ChapterGuideItem.Proxy(obj);
  57. item.m_loaIcon.url = string.Format("ui://FieldGuide/chapter_{0}", cfg.order);
  58. bool isPass = InstanceZonesDataManager.CheckChapterPass(cfg.type, cfg.subType, cfg.id, cfg.levelCount);
  59. item.m_grpLock.visible = !isPass;
  60. item.m_txtDesc.text = string.Format("通关主线第{0}章解锁", NumberUtil.GetChiniseNumberText(cfg.order));
  61. item.target.data = cfg;
  62. }
  63. private void OnListItemClick(EventContext context)
  64. {
  65. StoryChapterCfg cfg = (context.data as GObject).data as StoryChapterCfg;
  66. bool isPass = InstanceZonesDataManager.CheckChapterPass(cfg.type, cfg.subType, cfg.id, cfg.levelCount);
  67. if (!isPass)
  68. {
  69. PromptController.Instance.ShowFloatTextPrompt("暂未解锁");
  70. return;
  71. }
  72. ViewManager.Show<ChapterItemShowView>(cfg, new object[] { typeof(ChapterItemGuideView).FullName, this.viewData });
  73. }
  74. }
  75. }