using System.Collections.Generic; using ET; using FairyGUI; using UI.Studio; using UnityEngine; namespace GFGGame { public class StudioFilingView : BaseWindow { private UI_StudioFilingUI _ui; private StudioCfg _filingCfg; private List _storyLevelCfgs; public override void Dispose() { if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_StudioFilingUI.PACKAGE_NAME; _ui = UI_StudioFilingUI.Create(); this.viewCom = _ui.target; isfullScreen = true; _ui.m_list.itemRenderer = RenderListItem; _ui.m_list.onClickItem.Add(OnListItemClick); _ui.m_btnBack.onClick.Add(Hide); _ui.m_btnChange.onClick.Add(OnBtnChangeClick); _ui.m_btnReward.onClick.Add(OnBtnRewardClick); _ui.m_btnAdd.onClick.Add(OnBtnAddClick); _ui.m_btnSuit.onClick.Add(OnBtnSuitClick); _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("tc_bjbj"); } protected override void AddEventListener() { base.AddEventListener(); EventAgent.AddEventListener(ConstMessage.STORY_LEVEL_CHANGE, UpdateView); EventAgent.AddEventListener(ConstMessage.FILLING_CHANGE_CHAPTER, UpdateView); } protected override void OnShown() { base.OnShown(); UpdateView(); } protected override void OnHide() { base.OnHide(); ViewManager.GoBackFrom(typeof(StudioFilingView).FullName); } protected override void RemoveEventListener() { base.RemoveEventListener(); EventAgent.RemoveEventListener(ConstMessage.STORY_LEVEL_CHANGE, UpdateView); EventAgent.RemoveEventListener(ConstMessage.FILLING_CHANGE_CHAPTER, UpdateView); } private void UpdateView() { _filingCfg = StudioCfgArray.Instance.GetCfg(StudioDataManager.Instance.filingChapterId); _ui.m_txtTitle.SetVar("name", _filingCfg.name).FlushVars(); _ui.m_loaNpc.url = ResPathUtil.GetNpcPicFPath(_filingCfg.res); SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_filingCfg.suitId); _ui.m_txtSuitName.text = suitCfg.name; DressUpMenuSuitDataManager.GetSuitProgressBySuitId(_filingCfg.suitId, out int count, out int totalCount); _ui.m_txtSuitProgress.text = string.Format("({0}/{1})", count, totalCount); _storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(_filingCfg.type, _filingCfg.subType, StudioDataManager.Instance.filingChapterId); _ui.m_list.numItems = _storyLevelCfgs.Count; } private void RenderListItem(int index, GObject obj) { int _index = _storyLevelCfgs.Count - index - 1; UI_ListLevel item = UI_ListLevel.Proxy(obj); item.m_c1.selectedIndex = _index % 2; item.m_txtName.text = _storyLevelCfgs[_index].name; item.m_imgLock.visible = _index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[_index - 1].id); item.m_comFlower.m_c1.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[_index].id); item.target.data = _index;// _storyLevelCfgs[_index]; UI_ListLevel.ProxyEnd(); } private void OnListItemClick(EventContext context) { GObject obj = context.data as GObject; int index = (int)obj.data; StoryLevelCfg storyLevelCfg = _storyLevelCfgs[index]; if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id)) { PromptController.Instance.ShowFloatTextPrompt("需通关前置关卡"); return; } MainStoryDataManager.currentLevelCfgId = storyLevelCfg.id; if (!string.IsNullOrEmpty(storyLevelCfg.storyStartID)) { StoryController.ShowFilingStoryDialog(storyLevelCfg); } else { InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishFilingStoryLevel); } } private void OnBtnChangeClick() { ViewManager.Show(); } private void OnBtnRewardClick() { ViewManager.Show(); } private void OnBtnAddClick() { ViewManager.Show(StudioDataManager.Instance.filingChapterId); } private void OnBtnSuitClick() { SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_filingCfg.suitId); if (!InstanceZonesDataManager.CheckLevelPass(suitCfg.syntheticStoryLevelId)) { StoryLevelCfg cfg = StoryLevelCfgArray.Instance.GetCfg(suitCfg.syntheticStoryLevelId); PromptController.Instance.ShowFloatTextPrompt(string.Format("需通关{0}关卡解锁", cfg.name)); return; } ViewManager.Show(new object[] { _filingCfg.suitId }, new object[] { typeof(StudioFilingView).FullName, this.viewData }, true); } } }