123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- 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<StoryLevelCfg> _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<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);
- }
- }
- }
|