using ET; using FairyGUI; using UI.Studio; using UnityEngine; namespace GFGGame { public class StudioFilingNpcView : BaseWindow { private UI_StudioFilingNpcUI _ui; private GComponent _comSelect; public override void Dispose() { if (_comSelect != null) { _comSelect.RemoveFromParent(); _comSelect.Dispose(); } if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_StudioFilingNpcUI.PACKAGE_NAME; _ui = UI_StudioFilingNpcUI.Create(); this.viewCom = _ui.target; this.viewCom.Center(); this.modal = true; viewAnimationType = EnumViewAnimationType.ZOOM_CENTER; _comSelect = new GComponent(); _comSelect = UIPackage.CreateObject(UI_StudioFilingNpcUI.PACKAGE_NAME, "ComNpcItemSelect").asCom; _comSelect.touchable = false; _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_list.numItems = FilingCfgArray.Instance.dataArray.Length; } protected override void OnHide() { base.OnHide(); } protected override void RemoveEventListener() { base.RemoveEventListener(); } private void RenderListItem(int index, GObject obj) { FilingCfg cfg = FilingCfgArray.Instance.dataArray[index]; UI_ListNpcItem item = UI_ListNpcItem.Proxy(obj); bool isPass = InstanceZonesDataManager.CheckLevelPass(cfg.storyLevelId); string res = isPass ? cfg.res : cfg.res1; item.m_loaIcon.url = ResPathUtil.GetNpcPicSPath(res); item.m_txtName.text = cfg.name; item.target.data = cfg; if (cfg.id == StudioDataManager.Instance.filingChapterId) { item.target.AddChild(_comSelect); } UI_ListNpcItem.ProxyEnd(); } private void OnListItemClick(EventContext context) { GObject obj = context.data as GObject; FilingCfg cfg = obj.data as FilingCfg; bool isPass = InstanceZonesDataManager.CheckLevelPass(cfg.storyLevelId); if (!isPass) { StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(cfg.storyLevelId); string showId = StoryUtil.GetChapterOrder(storyLevelCfg.chapterId) + "_" + storyLevelCfg.order; PromptController.Instance.ShowFloatTextPrompt(string.Format("通关主线{0}解锁", showId)); return; } StudioDataManager.Instance.filingChapterId = cfg.id; StorageSProxy.ReqSetClientValue(ConstStorageId.STUDIO_FILING_CHAPTERID, cfg.id).Coroutine(); EventAgent.DispatchEvent(ConstMessage.FILLING_CHANGE_CHAPTER); UI_ListNpcItem item = UI_ListNpcItem.Proxy(obj); item.target.AddChild(_comSelect); UI_ListNpcItem.ProxyEnd(); } } }