123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using System;
- using System.Collections.Generic;
- using ET;
- using FairyGUI;
- using UI.Studio;
- namespace GFGGame
- {
- public class StudioBaseView : BaseWindow
- {
- protected UI_StudioEctypeUI _ui;
- private ValueBarController _valueBarController;
- protected StudioCfg studioCfg;
- protected List<StoryLevelCfg> storyLevelCfgs;
- protected StudioData studioData;
- protected int curIndex = 0;
- public override void Dispose()
- {
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_StudioEctypeUI.PACKAGE_NAME;
- _ui = UI_StudioEctypeUI.Create();
- this.viewCom = _ui.target;
- isfullScreen = true;
- _valueBarController = new ValueBarController(_ui.m_valueBar);
- _ui.m_list.itemRenderer = ListItemRender;
- _ui.m_list.onClickItem.Add(OnCliclListItem);
- _ui.m_list.SetVirtual();
- _ui.m_btnBuy.onClick.Add(OnCliclBtnBuy);
- EventAgent.AddEventListener(ConstMessage.BUY_STUDIO_PLAY_TIMES, UpdateView);
- EventAgent.AddEventListener(ConstMessage.NOTICE_STUDIO_PLAY_TIMES, UpdateView);
- }
- protected override void OnShown()
- {
- base.OnShown();
- _valueBarController.OnShown();
- UpdateView();
- Timers.inst.Add(1, 0, UpdateShowTime);
- }
- protected override void OnHide()
- {
- base.OnHide();
- _valueBarController.OnHide();
- studioCfg = null;
- storyLevelCfgs = null;
- studioData = null;
- Timers.inst.Remove(UpdateShowTime);
- EventAgent.RemoveEventListener(ConstMessage.BUY_STUDIO_PLAY_TIMES, UpdateView);
- EventAgent.RemoveEventListener(ConstMessage.NOTICE_STUDIO_PLAY_TIMES, UpdateView);
- }
- protected void UpdateView()
- {
- studioData = StudioDataManager.Instance.GetStudioDataById(this.studioCfg.id);
- _ui.m_txtNum.text = string.Format("剩余次数:{0}/{1}", this.studioData.TotalPlayTimes - this.studioData.PlayTimes, studioCfg.num);
- }
- private void UpdateShowTime(object param)
- {
- _ui.m_txtTime.text = string.Format("{0}后刷新", TimeUtil.FormattingTime(TimeHelper.ServerNowSecs, GameGlobal.myNumericComponent.GetAsInt(NumericType.DailyResetSecs)));
- }
- private void ListItemRender(int index, GObject obj)
- {
- UI_ListItem item = UI_ListItem.Proxy(obj);
- StudioDataManager.Instance.IsCanFight(storyLevelCfgs, index, out bool canFight, out string content);
- ItemData itemData = StoryBonusDataCache.GetBonusData(storyLevelCfgs[index].id).bonusBase[0];
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id);
- item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
- item.m_star.selectedIndex = InstanceZonesDataManager.GetStarCountHistory(storyLevelCfgs[index].id);
- item.m_imgLock.visible = canFight ? false : true;
- item.m_txtTitle.text = canFight ? storyLevelCfgs[index].name : content;
- if (canFight) curIndex = index;
- item.target.data = index;
- }
- private void OnCliclListItem(EventContext context)
- {
- UI_ListItem item = UI_ListItem.Proxy(context.data as GObject);
- int index = (int)item.target.data;
- StoryLevelCfg storyLevelCfg = storyLevelCfgs[index];
- StudioDataManager.Instance.IsCanFight(storyLevelCfgs, index, out bool canFight, out string content);
- if (!canFight)
- {
- PromptController.Instance.ShowFloatTextPrompt(content);
- return;
- }
- StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _ui.m_listProperty.selectedIndex;
- StudioDataManager.Instance.TYPE_SELECT_INDEX = _ui.m_c1.selectedIndex;
- InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishStoryLevel);
- }
- private void OnCliclBtnBuy()
- {
- ViewManager.Show<StudioBuyNumView>(this.studioCfg.id);
- }
- }
- }
|