123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- using ET;
- using System.Collections.Generic;
- using UnityEngine;
- namespace GFGGame
- {
- public class FunctionOpenDataManager : SingletonBase<FunctionOpenDataManager>
- {
- /// <summary>
- /// 根据功能名检测功能是否开启
- /// </summary>
- /// <param name="functionId"></param>
- /// <returns></returns>
- 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))
- {
- return false;
- }
- }
- if (!CheckIsChapterFunOpen(cfg, showTips)) return false;
- if (!CheckIsLvFunOpen(cfg, showTips)) return false;
- return true;
- }
- /// <summary>
- /// 根据章节Id检测是否有新功能开启
- /// </summary>
- public void CheckHasChapterFunOpen(int storyLevelCfgId)
- {
- FunctionOpenCfg[] cfgs = FunctionOpenCfgArray.Instance.dataArray;
- List<string> listCfg = new List<string>();
- 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<FunctionOpenView>(listCfg);
- }
- }
- /// <summary>
- /// 根据角色Lv检测是否有新功能开启
- /// </summary>
- public void CheckHasLvFunOpen(int lv)
- {
- FunctionOpenCfg[] cfgs = FunctionOpenCfgArray.Instance.dataArray;
- List<string> listCfg = new List<string>();
- 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<FunctionOpenView>(listCfg);
- }
- }
- //检测配置章节是否开启
- private bool CheckIsChapterFunOpen(FunctionOpenCfg cfg, bool showTips = true)
- {
- if (cfg.storyLevelId <= 0)
- {
- return true;
- }
- if (InstanceZonesDataManager.CheckLevelPass(cfg.storyLevelId))
- {
- return true;
- }
- if (showTips) PromptController.Instance.ShowFloatTextPrompt("功能暂未开启,敬请期待");
- 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("功能暂未开启,敬请期待");
- return false;
- }
- }
- }
|