123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- 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<StoryLevelCfg> _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_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_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();
- // _valueBarController.Controller(1);
- 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_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);
- 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}", _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);
- 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<StudioFilingNpcView>();
- }
- private void OnBtnRewardClick()
- {
- ViewManager.Show<StudioFilingRewardView>();
- }
- private void OnBtnAddClick()
- {
- ViewManager.Show<StudioBuyNumView>(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<ClothingSyntheticView>(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));
- }
- 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);
- }
- }
- }
|