123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- using ET;
- using FairyGUI;
- 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)
- {
- string name = ViewManager.GetName(functionId);
- FunctionOpenCfg cfg = FunctionOpenCfgArray.Instance.GetCfg(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;
- }
- /// <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].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<FunctionOpenView>(listCfg);
- }
- }
- /// <summary>
- /// 根据角色Lv检测是否有新功能开启
- /// </summary>
- public void CheckHasLvFunOpen(int lv, int oldLv)
- {
- FunctionOpenCfg[] cfgs = FunctionOpenCfgArray.Instance.dataArray;
- List<string> listCfg = new List<string>();
- for (int i = 0; i < cfgs.Length; i++)
- {
- 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<FunctionOpenView>(listCfg);
- }
- }
- public async void CheckHasSpecialFunOpen()
- {
- if (StorageDataManager.Instance.GetStorangeDic().Count == 0)
- {
- await StorageSProxy.ReqGetClientValues();
- }
- 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 > 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<FunctionOpenView>(listCfg);
- }
- }
- // private void FunctionOpen(object param)
- // {
- // if (ViewManager.isViewOpen(typeof(RoleLvUpView).Name)) return;
- // ViewManager.Show<FunctionOpenView>(param);
- // Timers.inst.Remove(FunctionOpen);
- // }
- //检测配置章节是否开启
- 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)
- {
- //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<int> _currentList3 = DressUpMenuSuitDataManager.GetSuitIDList();
- if (_currentList3.Count == 0)
- {
- if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("收集一套“天衣”套装后解锁"));
- return false;
- }
- _currentList3 = SuitUtil.SortSuitListByHighRarity(_currentList3);
- if (SuitCfgArray.Instance.GetCfg(_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;
- }
- }
- }
|