using ET; using FairyGUI; using System.Collections.Generic; using cfg.GfgCfg; using UnityEngine; namespace GFGGame { public class FunctionOpenDataManager : SingletonBase { /// /// 根据功能名检测功能是否开启 /// /// /// public bool CheckIsFunOpenById(string functionId, bool showTips = true) { string name = ViewManager.GetName(functionId); FunctionOpenCfg cfg = CommonDataManager.Tables.TblFunctionOpenCfg.GetOrDefault(name); if (cfg == null) { // Debug.LogWarning("g功能.xlsx 功能开启_FunctionOpenCfg 未添加 " + viewName + " 的配置"); return true;//未配置功能开启的暂时默认开启 } if (cfg.ParentId != null && cfg.ParentId != "") { //先检查父功能是否开启 if (!CheckIsFunOpenById(cfg.ParentId, showTips)) { return false; } } if (!CheckIsChapterFunOpen(cfg, showTips)) return false; if (!CheckIsLvFunOpen(cfg, showTips)) return false; if (!CheckIsSpecialFunOpen(cfg, showTips)) return false; return true; } public string GetOpenTips(string functionId) { FunctionOpenCfg cfg = CommonDataManager.Tables.TblFunctionOpenCfg.GetOrDefault(functionId); if (cfg == null) { return ""; } if (!CheckIsChapterFunOpen(cfg, false)) { return GetChapterOpenTips(cfg); } if (!CheckIsLvFunOpen(cfg, false)) { return GetLvTips(cfg); } if (!CheckIsSpecialFunOpen(cfg, false)) { return GetChapterLvTips(cfg); } return ""; } /// /// 根据章节Id检测是否有新功能开启 /// public void CheckHasChapterFunOpen(int storyLevelCfgId) { List cfgs = CommonDataManager.Tables.TblFunctionOpenCfg.DataList; List listCfg = new List(); for (int i = 0; i < cfgs.Count; i++) { if (cfgs[i].Id == typeof(ArenaView).Name && cfgs[i].StoryLevelId == storyLevelCfgId) ArenaDataManager.Instance.ReqArenaInfo(); if (cfgs[i].Show == 0) continue; if (cfgs[i].Special > 0) continue; if (cfgs[i].Lv > 0) continue; if (cfgs[i].StoryLevelId != storyLevelCfgId || !CheckIsChapterFunOpen(cfgs[i], false)) continue; // if (CheckIsLvFunOpen(cfgs[i], false)) continue; listCfg.Add(cfgs[i].Id); } if (listCfg.Count > 0) { // Timers.inst.Add(1, 0, FunctionOpen, listCfg); ViewManager.Show(listCfg); } } /// /// 根据角色Lv检测是否有新功能开启 /// public void CheckHasLvFunOpen(int lv, int oldLv) { List cfgs = CommonDataManager.Tables.TblFunctionOpenCfg.DataList ; List listCfg = new List(); for (int i = 0; i < cfgs.Count; i++) { if (cfgs[i].Id == typeof(ArenaView).Name && oldLv < cfgs[i].Lv && cfgs[i].Lv == lv) ArenaDataManager.Instance.ReqArenaInfo(); if ((cfgs[i].Special > 0)) continue; if (cfgs[i].Show == 0) continue; if (lv <= 0) continue; if (cfgs[i].StoryLevelId > 0) continue; if (oldLv >= cfgs[i].Lv || lv < cfgs[i].Lv || !CheckIsLvFunOpen(cfgs[i], false)) continue; // if (CheckIsChapterFunOpen(cfgs[i], false)) continue; listCfg.Add(cfgs[i].Id); } if (listCfg.Count > 0) { ViewManager.Show(listCfg); } } public async void CheckHasSpecialFunOpen() { if (StorageDataManager.Instance.GetStorangeDic().Count == 0) { await StorageSProxy.ReqGetClientValues(); } List cfgs = CommonDataManager.Tables.TblFunctionOpenCfg.DataList ; List listCfg = new List(); for (int i = 0; i < cfgs.Count; i++) { if (cfgs[i].Id == typeof(ArenaView).Name) ArenaDataManager.Instance.ReqArenaInfo(); if (cfgs[i].Show == 0) continue; if (cfgs[i].StoryLevelId > 0) continue; if (cfgs[i].Lv > 0) continue; if ((cfgs[i].Special <= 0)) continue; if (StorageDataManager.Instance.GetStorageValue(ConstStorageId.FUNCTION_OPEN + cfgs[i].Index) == 1) continue; if (CheckIsSpecialFunOpen(cfgs[i], false)) { listCfg.Add(cfgs[i].Id); } } if (listCfg.Count > 0) { ViewManager.Show(listCfg); } } //检测配置章节是否开启 private bool CheckIsChapterFunOpen(FunctionOpenCfg cfg, bool showTips = true) { if (cfg.StoryLevelId <= 0) { return true; } if (InstanceZonesDataManager.CheckLevelPass(cfg.StoryLevelId)) { return true; } StoryLevelCfg storyLevelCfg = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(cfg.StoryLevelId); StoryChapterCfg storyChapterCfg = CommonDataManager.Tables.TblStoryChapterCfg.GetOrDefault(storyLevelCfg.ChapterId); if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("通关主线{0}-{1}解锁", storyChapterCfg.Order, storyLevelCfg.Order)); return false; } //检测配置角色是否开启 private bool CheckIsLvFunOpen(FunctionOpenCfg cfg, bool showTips = true) { //GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) if (RoleDataManager.lvl >= cfg.Lv) { return true; } if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("角色达到{0}级解锁", cfg.Lv)); return false; } private bool CheckIsSpecialFunOpen(FunctionOpenCfg cfg, bool showTips = true) { if (cfg.Special <= 0) return true; if (cfg.Id == typeof(ClothingListView).Name)//服装升级获取第一套【天衣】套装后开启 { if (StorageDataManager.Instance.GetStorageValue(ConstStorageId.FUNCTION_OPEN + cfg.Index) == 1) return true; List _currentList3 = DressUpMenuSuitDataManager.GetSuitIDList(); if (_currentList3.Count == 0) { if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("收集一套“天衣”套装后解锁")); return false; } _currentList3 = SuitUtil.SortSuitListByHighRarity(_currentList3); if ( CommonDataManager.Tables.TblSuitCfg.GetOrDefault(_currentList3[0]).Rarity == ConstDressRarity.Rarity_TIANYI) { StorageSProxy.ReqSetClientValue(ConstStorageId.FUNCTION_OPEN + cfg.Index, 1).Coroutine(); return true; } else { if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("收集一套“天衣”套装后解锁")); } } return false; } private string GetChapterOpenTips(FunctionOpenCfg cfg) { string strTips = ""; if (cfg.StoryLevelId > 0) { StoryLevelCfg storyLevelCfg = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(cfg.StoryLevelId); StoryChapterCfg storyChapterCfg = CommonDataManager.Tables.TblStoryChapterCfg.GetOrDefault(storyLevelCfg.ChapterId); strTips = string.Format("通关主线{0}-{1}解锁", storyChapterCfg.Order, storyLevelCfg.Order); } return strTips; } private string GetLvTips(FunctionOpenCfg cfg) { string strTips = ""; if (cfg.Lv > 0) { strTips = string.Format("角色达到{0}级解锁", cfg.Lv); } return strTips; } private string GetChapterLvTips(FunctionOpenCfg cfg) { string strTips = ""; if (cfg.Special > 0) { if (cfg.Id == typeof(ClothingListView).Name)//服装升级获取第一套【天衣】套装后开启 { strTips = string.Format("收集一套“天衣”套装后解锁"); } } return strTips; } } }