using System.Collections.Generic; using ET; using FairyGUI; using UI.Main; using UI.CommonGame; using UnityEngine; namespace GFGGame { public class StoryFightFailView : BaseWindow { private UI_StoryFightFailUI _ui; private List _cfgs = new List(); public override void Dispose() { if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_StoryFightFailUI.PACKAGE_NAME; _ui = UI_StoryFightFailUI.Create(); this.viewCom = _ui.target; this.viewCom.Center(); this.modal = true; viewAnimationType = EnumViewAnimationType.ZOOM_CENTER; _ui.m_list.itemRenderer = RenderListItem; _ui.m_comBg.GetChild("btnClose").asCom.onClick.Add(Hide); } protected override void AddEventListener() { base.AddEventListener(); } protected override void OnShown() { base.OnShown(); for (int i = 0; i < LevelTipsCfgArray.Instance.dataArray.Length; i++) { LevelTipsCfg cfg = LevelTipsCfgArray.Instance.dataArray[i]; if (cfg.storyLevel > 0 && InstanceZonesDataManager.currentLevelCfgId != cfg.storyLevel) continue; _cfgs.Add(cfg); } _ui.m_list.numItems = _cfgs.Count; } protected override void OnHide() { base.OnHide(); _cfgs.Clear(); if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0); } protected override void RemoveEventListener() { base.RemoveEventListener(); } private void RenderListItem(int index, GObject gObject) { UI_ListFailItem item = UI_ListFailItem.Proxy(gObject); FieldDataManager _dataManager = FieldDataManager.Instance; StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId); StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID); item.m_grpRecommend.visible = _cfgs[index].isAdvise == 1; int scoreType = 0; if (fightCfg.scoreType > 0) scoreType = fightCfg.scoreType; else scoreType = _dataManager.fieldInfos.theme; item.m_txtDesc.text = string.Format(_cfgs[index].desc, ConstDressUpScoreType.scoreTypeList()[scoreType]); if (item.m_btnGo.data == null) { item.m_btnGo.onClick.Add(OnBtnGoClick); } item.m_btnGo.data = _cfgs[index]; UI_ListFailItem.ProxyEnd(); } private void OnBtnGoClick(EventContext context) { GObject obj = context.sender as GObject; LevelTipsCfg cfg = obj.data as LevelTipsCfg; if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(cfg.jumpId)) return; object[] param = new object[cfg.jumpParamArr.Length]; for (int i = 0; i < cfg.jumpParamArr.Length; i++) { param[i] = cfg.jumpParamArr[i]; } if (cfg.jumpId != nameof(FirstChargeBonusView)) { ViewManager.Hide(); Hide(); } ViewManager.JumpToView(cfg.jumpId, param, null); if (cfg.jumpId == nameof(LuckyBoxView)) ViewManager.Hide(); // ViewManager.Show(); } } }