using System.Collections.Generic; using ET; using FairyGUI; using UI.Studio; using UnityEngine; namespace GFGGame { public class StudioFilingView : BaseWindow { private UI_StudioFilingUI _ui; private ValueBarController _valueBarController; private StudioCfg _filingCfg; private List _storyLevelCfgs; public override void Dispose() { if (_valueBarController != null) { _valueBarController.Dispose(); _valueBarController = null; } 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; _valueBarController = new ValueBarController(_ui.m_comValueBar); _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); } protected override void AddEventListener() { base.AddEventListener(); EventAgent.AddEventListener(ConstMessage.STORY_LEVEL_CHANGE, UpdateView); EventAgent.AddEventListener(ConstMessage.FILLING_CHANGE_CHAPTER, UpdateView); EventAgent.AddEventListener(ConstMessage.NOTICE_STUDIO_PLAY_TIMES, UpdateView); EventAgent.AddEventListener(ConstMessage.BUY_STUDIO_PLAY_TIMES, UpdateView); EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateRedDot); } protected override void OnShown() { base.OnShown(); _valueBarController.OnShown(); UpdateView(); } protected override void OnHide() { base.OnHide(); _valueBarController.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); EventAgent.RemoveEventListener(ConstMessage.NOTICE_STUDIO_PLAY_TIMES, UpdateView); EventAgent.RemoveEventListener(ConstMessage.BUY_STUDIO_PLAY_TIMES, UpdateView); EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateRedDot); } private void UpdateView() { StudioData studioData = StudioDataManager.Instance.GetStudioDataById(StudioDataManager.Instance.filingChapterId); _filingCfg = StudioCfgArray.Instance.GetCfg(StudioDataManager.Instance.filingChapterId); _ui.m_loaBg.url = ResPathUtil.GetBgImgPath(_filingCfg.res); _ui.m_btnChange.title = _filingCfg.name; _ui.m_txtNum.text = string.Format("剩余次数:{0}/{1}", studioData.TotalPlayTimes - studioData.PlayTimes, _filingCfg.num); 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; UpdateRedDot(); } private void RenderListItem(int index, GObject obj) { // int _index = _storyLevelCfgs.Count - index - 1; UI_ListLevelItem item = UI_ListLevelItem.Proxy(obj); item.m_c1.selectedIndex = index % 2 == 0 ? 0 : 1; item.m_txtName.text = _storyLevelCfgs[index].name; bool isFight = string.IsNullOrEmpty(_storyLevelCfgs[index].storyStartID); string resBg = isFight ? "cyjd_di_1" : "cyjd_di_2"; item.m_loaBg.url = string.Format("ui://Studio/{0}", resBg); if (isFight) { item.m_loaBg.url = "ui://Studio/cyjd_di_1"; item.m_loaIcon.visible = false; item.m_loaItem.visible = true; StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID); ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(storyFightCfg.bonusBaseArr[0][0]); item.m_loaItem.url = ResPathUtil.GetIconPath(itemCfg); } else { item.m_loaBg.url = "ui://Studio/cyjd_di_2"; item.m_loaItem.visible = false; item.m_loaIcon.visible = true; item.m_loaIcon.url = string.Format("ui://Studio/{0}", _filingCfg.res); } item.m_grpLock.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_ListLevelItem.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); } private void UpdateRedDot() { RedDotController.Instance.SetComRedDot(_ui.m_btnReward, StudioDataManager.Instance.GetFilingRewardState(StudioDataManager.Instance.filingChapterId)); RedDotController.Instance.SetComRedDot(_ui.m_btnChange, RedDotDataManager.Instance.GetStudioFilingRed(false)); } } }