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 _studioCfg; private List _storyLevelCfgs; private int _viewData = 0; 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_btnBack.onClick.Add(GoBackFrom); _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_LIMIT_CHANGED, OnLimitChanged); EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateRedDot); } protected override void OnShown() { base.OnShown(); _valueBarController.OnShown(); _viewData = this.viewData != null ? (int)this.viewData : 0; _ui.m_btnChange.visible = _viewData != StudioDataManager.Instance.luckyBoxFilingChapterId; StudioDataManager.Instance.filingChapterId = _viewData > 0 ? _viewData : StudioDataManager.Instance.npcFilingChapterId; UpdateView(); Timers.inst.AddUpdate(CheckGuide); } protected override void OnHide() { base.OnHide(); _valueBarController.OnHide(); Timers.inst.Remove(CheckGuide); } protected void GoBackFrom() { 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_LIMIT_CHANGED, OnLimitChanged); EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateRedDot); } private void OnLimitChanged(EventContext context) { int limitId = (int)context.data; if (this._studioCfg.limit != limitId) { return; } UpdateView(); } private void UpdateView() { _studioCfg = StudioCfgArray.Instance.GetCfg(StudioDataManager.Instance.filingChapterId); RoleLimitData limitData = RoleLimitDataManager.GetLimitData(this._studioCfg.limit); var limitCfg = LimitCfgArray.Instance.GetCfg(this._studioCfg.limit); _ui.m_btnAdd.visible = limitCfg.itemID > 0; _ui.m_loaBg.url = ResPathUtil.GetBgImgPath(_studioCfg.res); _ui.m_btnChange.title = _studioCfg.name; _ui.m_txtNum.text = string.Format("剩余次数:{0}/{1}", limitData.TotalPlayMax - limitData.PlayTimes, limitData.MaxStorageCount); SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_studioCfg.suitId); _ui.m_txtSuitName.text = suitCfg.name; DressUpMenuSuitDataManager.GetSuitProgressBySuitId(_studioCfg.suitId, out int count, out int totalCount); _ui.m_txtSuitProgress.text = string.Format("({0}/{1})", count, totalCount); _ui.m_suitIcon.url = ResPathUtil.GetIconPath(suitCfg.res, "png"); _storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(_studioCfg.type, _studioCfg.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); int itemId = DropOutCfgArray.Instance.GetCfgsByid(storyFightCfg.bonusRandomArr[0])[0].item; ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId); item.m_loaItem.url = ResPathUtil.GetIconPath(itemCfg); if (item.m_loaItem.data == null) { item.m_loaItem.onClick.Add(OnLoaItemClick); } item.m_loaItem.data = index; } 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}", _studioCfg.res); } item.m_grpLock.visible = index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1].id); item.m_comFlower.m_c1.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(_storyLevelCfgs[index].id); if (item.m_loaBg.data == null) { item.m_loaBg.onClick.Add(OnListItemClick); } item.m_loaBg.data = index; UI_ListLevelItem.ProxyEnd(); } private void OnListItemClick(EventContext context) { GObject obj = context.sender 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; InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishFilingStoryLevel); } private void OnLoaItemClick(EventContext context) { GObject obj = context.sender as GObject; int index = (int)obj.data; StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID); int itemId = DropOutCfgArray.Instance.GetCfgsByid(storyFightCfg.bonusRandomArr[0])[0].item; // StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(_storyLevelCfgs[index].fightID); // ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(storyFightCfg.bonusBaseArr[0][0]); GoodsItemTipsController.ShowItemTips(itemId); } private void OnBtnChangeClick() { ViewManager.Show(); } private void OnBtnRewardClick() { ViewManager.Show(); } private void OnBtnAddClick() { ViewManager.Show(_studioCfg.limit); } private void OnBtnSuitClick() { SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(_studioCfg.suitId); if (suitCfg.syntheticStoryLevelId > 0 && !InstanceZonesDataManager.CheckLevelPass(suitCfg.syntheticStoryLevelId)) { StoryLevelCfg cfg = StoryLevelCfgArray.Instance.GetCfg(suitCfg.syntheticStoryLevelId); PromptController.Instance.ShowFloatTextPrompt(string.Format("需通关{0}关卡解锁", cfg.name)); return; } if (_viewData == StudioDataManager.Instance.luckyBoxFilingChapterId) { int _activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(ConstLimitTimeActivityType.ActLimitLuckyBox); ActivityOpenCfg _activityCfg = ActivityOpenCfgArray.Instance.GetCfg(_activityId); long endTime = TimeUtil.DateTimeToTimestamp(_activityCfg.endTime); long curTime = TimeHelper.ServerNow(); if (endTime < curTime) return; ViewManager.Show(_activityId, new object[] { typeof(StudioFilingView).FullName, this.viewData }, true); } else { ViewManager.Show(new object[] { _studioCfg.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)); } private void CheckGuide(object param) { if (GuideDataManager.IsGuideFinish(ConstGuideId.STUDIO_FILING) <= 0) { UpdateToCheckGuide(null); } else { Timers.inst.Remove(CheckGuide); } } protected override void UpdateToCheckGuide(object param) { if (!ViewManager.CheckIsTopView(this.viewCom)) return; GuideController.TryGuide(_ui.m_list, ConstGuideId.STUDIO_FILING, 5, "从华贵的花想容开始吧~~", 0); GuideController.TryCompleteGuide(ConstGuideId.STUDIO_FILING, 5); } } }