using ET; using System.Collections.Generic; using UnityEngine; namespace GFGGame { public class FunctionOpenDataManager : SingletonBase { /// /// 根据功能名检测功能是否开启 /// /// /// public bool CheckIsFunOpenById(string functionId, bool showTips = true) { FunctionOpenCfg cfg = FunctionOpenCfgArray.Instance.GetCfg(functionId); 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; return true; } /// /// 根据章节Id检测是否有新功能开启 /// public void CheckHasChapterFunOpen(int storyLevelCfgId) { FunctionOpenCfg[] cfgs = FunctionOpenCfgArray.Instance.dataArray; List listCfg = new List(); for (int i = 0; i < cfgs.Length; i++) { if (cfgs[i].show == 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) { ViewManager.Show(listCfg); } } /// /// 根据角色Lv检测是否有新功能开启 /// public void CheckHasLvFunOpen(int lv) { FunctionOpenCfg[] cfgs = FunctionOpenCfgArray.Instance.dataArray; List listCfg = new List(); for (int i = 0; i < cfgs.Length; i++) { if (cfgs[i].show == 0) continue; if (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); } } //检测配置章节是否开启 private bool CheckIsChapterFunOpen(FunctionOpenCfg cfg, bool showTips = true) { if (cfg.storyLevelId <= 0) { return true; } if (InstanceZonesDataManager.CheckLevelPass(cfg.storyLevelId)) { return true; } StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(cfg.storyLevelId); StoryChapterCfg storyChapterCfg = StoryChapterCfgArray.Instance.GetCfg(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) { if (GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= cfg.lv) { return true; } if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("角色达到{0}级解锁", cfg.lv)); return false; } } }