using UnityEngine; using FairyGUI; using UI.OpenServerActivity; using UI.CommonGame; using System.Collections.Generic; namespace GFGGame { public class OpenServerStoryView : BaseWindow { private UI_OpenServerStoryUI _ui; private Dictionary> _storyLevelCfgs = new Dictionary>(); private int _activityId; private int _activityType; private ActivityOpenCfg _activityCfg; public override void Dispose() { if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void Init() { base.Init(); } protected override void OnInit() { base.OnInit(); packageName = UI_OpenServerStoryUI.PACKAGE_NAME; _ui = UI_OpenServerStoryUI.Create(); viewCom = _ui.target; isfullScreen = true; isReturnView = true; _ui.m_btnBack.onClick.Add(OnClickBtnBack); _ui.m_list.itemRenderer = RenderListItem; } protected override void AddEventListener() { base.AddEventListener(); } protected override void OnShown() { base.OnShown(); _activityType = (int)this.viewData; StudioDataManager.Instance.VIEW_NAME = typeof(OpenServerStoryView).FullName; StudioDataManager.Instance.PROPERTY_SELECT_INDEX = _activityType; _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("bg_sdcy_gq"); _activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(_activityType); _activityCfg = ActivityOpenCfgArray.Instance.GetCfg(_activityId); _storyLevelCfgs.Clear(); _ui.m_list.numItems = _activityCfg.params4Arr.Length; } protected override void OnHide() { base.OnHide(); } protected override void RemoveEventListener() { base.RemoveEventListener(); } private void OnClickBtnBack() { ViewManager.GoBackFrom(typeof(OpenServerStoryView).FullName); } private void RenderListItem(int index, GObject obj) { UI_StoryItem item = UI_StoryItem.Proxy(obj); var activityStoryCfg = ActivityStoryCfgArray.Instance.GetCfg(_activityCfg.params4Arr[index]); var storyLevelCfg = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(activityStoryCfg.type, activityStoryCfg.subType, _activityCfg.params4Arr[index]); _storyLevelCfgs.Add(index, storyLevelCfg); item.m_posType.selectedIndex = index % 2; item.m_txtTitle.text = activityStoryCfg.name; item.m_txtNumber.text = "0" + (index + 1); if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1][0].id)) item.m_storyImageType.selectedIndex = 0; else item.m_storyImageType.selectedIndex = index+1; if (item.target.data == null) item.target.onClick.Add(OnClickBtnPlay); item.target.data = index; UI_StoryItem.ProxyEnd(); } private void OnClickBtnPlay(EventContext context) { GObject obj = context.sender as GObject; int index = (int)obj.data; StoryLevelCfg storyLevelCfg = _storyLevelCfgs[index][0]; if (index > 0 && !InstanceZonesDataManager.CheckLevelPass(_storyLevelCfgs[index - 1][0].id)) { PromptController.Instance.ShowFloatTextPrompt("需通关前置关卡"); return; } MainStoryDataManager.currentLevelCfgId = storyLevelCfg.id; InstanceZonesController.ShowLevelView(storyLevelCfg.id, StudioDataManager.Instance.OnFinishStudioStoryLevel); } } }