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 StoryLevelCfg[] storyLevelCfgs; protected StudioData studioData; 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); } private void UpdateView() { _ui.m_txtNum.text = string.Format("剩余次数:{0}/{1}", this.studioData.TotalPlayTimes - this.studioData.PlayTimes, this.studioData.TotalPlayTimes); } 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, 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 ? string.Format("{0}{1}", studioCfg.name, index + 1) : content; item.target.data = storyLevelCfgs[index]; } private void OnCliclListItem(EventContext context) { UI_ListItem item = UI_ListItem.Proxy(context.data as GObject); StoryLevelCfg storyLevelCfg = item.target.data as StoryLevelCfg; StudioDataManager.Instance.IsCanFight(storyLevelCfgs, storyLevelCfg, out bool canFight, out string content); if (!canFight) { PromptController.Instance.ShowFloatTextPrompt(content); return; } InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishStoryLevel); } private bool GetCanFight(StoryLevelCfg storyLevelCfg) { bool isPass = InstanceZonesDataManager.CheckLevelPass(storyLevelCfg.needStoryLevelId); bool isRoleLv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= storyLevelCfg.needRoleLv; return isPass && isRoleLv; } private void OnCliclBtnBuy() { ViewManager.Show(this.studioCfg.id); } } }