using System.Collections.Generic; using UnityEngine; namespace GFGGame { public class FunctionOpenDataManager : SingletonBase { /// /// 根据功能名检测功能是否开启 /// /// /// public bool CheckIsFunOpenBgViewName(string viewName) { FunctionOpenCfg cfg = FunctionOpenCfgArray.Instance.GetCfg(viewName); if (cfg == null) { // Debug.LogWarning("g功能.xlsx 功能开启_FunctionOpenCfg 未添加 " + viewName + " 的配置"); return true;//未配置功能开启的暂时默认开启 } if (cfg.parentId != null && cfg.parentId != "") { //先检查父功能是否开启 CheckIsFunOpenBgViewName(cfg.parentId); } if (!CheckIsChapterFunOpen(cfg)) return false; if (!CheckIsLvFunOpen(cfg)) return false; return true; } /// /// 根据章节Id检测是否有新功能开启 /// public void CheckHasChapterFunOpen(int chapterId, int level) { 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].chapterId != chapterId || cfgs[i].level != level || !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.chapterId > 0 && cfg.level <= 0 || cfg.level > 0 && cfg.chapterId <= 0) { if (showTips) PromptController.Instance.ShowFloatTextPrompt("功能暂未开启,敬请期待"); return false; } if (cfg.chapterId > 0 && StoryDataManager.CheckLevelPass(cfg.chapterId, cfg.level)) { return true; } if (showTips) PromptController.Instance.ShowFloatTextPrompt("功能暂未开启,敬请期待"); return false; } //检测配置角色是否开启 private bool CheckIsLvFunOpen(FunctionOpenCfg cfg, bool showTips = true) { if (RoleDataManager.lvl >= cfg.lv) { return true; } if (showTips) PromptController.Instance.ShowFloatTextPrompt("功能暂未开启,敬请期待"); return false; } } }