using System.Collections.Generic; using FairyGUI; using UI.FieldGuide; namespace GFGGame { public class ChapterItemGuideView : BaseWindow { private UI_ChapterItemGuideUI _ui; private List _storychapterDatas = new List(); public override void Dispose() { if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_ChapterItemGuideUI.PACKAGE_NAME; _ui = UI_ChapterItemGuideUI.Create(); this.viewCom = _ui.target; isfullScreen = true; _ui.m_btnBack.onClick.Add(OnClickBtnBack); _ui.m_list.itemRenderer = RenderListItem; _ui.m_list.onClickItem.Add(OnListItemClick); } protected override void AddEventListener() { base.AddEventListener(); } protected override void OnShown() { base.OnShown(); _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("hc_bj_1"); _storychapterDatas = StoryChapterCfgArray.Instance.GetCfgsBysubType(ConstInstanceZonesSubType.Normal); _ui.m_list.numItems = _storychapterDatas.Count - 1; } protected override void OnHide() { base.OnHide(); } protected override void RemoveEventListener() { base.RemoveEventListener(); } private void OnClickBtnBack() { ViewManager.GoBackFrom(typeof(ChapterItemGuideView).FullName); } private void RenderListItem(int index, GObject obj) { StoryChapterCfg cfg = _storychapterDatas[index + 1]; UI_ChapterGuideItem item = UI_ChapterGuideItem.Proxy(obj); item.m_loaIcon.url = string.Format("ui://FieldGuide/chapter_{0}", cfg.order); bool isPass = InstanceZonesDataManager.CheckChapterPass(cfg.type, cfg.subType, cfg.id, cfg.levelCount); item.m_grpLock.visible = !isPass; item.m_txtDesc.text = string.Format("通关主线第{0}章解锁", NumberUtil.GetChiniseNumberText(cfg.order)); item.target.data = cfg; } private void OnListItemClick(EventContext context) { StoryChapterCfg cfg = (context.data as GObject).data as StoryChapterCfg; bool isPass = InstanceZonesDataManager.CheckChapterPass(cfg.type, cfg.subType, cfg.id, cfg.levelCount); if (!isPass) { PromptController.Instance.ShowFloatTextPrompt("暂未解锁"); return; } ViewManager.Show(cfg, new object[] { typeof(ChapterItemGuideView).FullName, this.viewData }); } } }