FunctionOpenDataManager.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. using ET;
  2. using FairyGUI;
  3. using System.Collections.Generic;
  4. using cfg.GfgCfg;
  5. using UnityEngine;
  6. namespace GFGGame
  7. {
  8. public class FunctionOpenDataManager : SingletonBase<FunctionOpenDataManager>
  9. {
  10. /// <summary>
  11. /// 根据功能名检测功能是否开启
  12. /// </summary>
  13. /// <param name="functionId"></param>
  14. /// <returns></returns>
  15. public bool CheckIsFunOpenById(string functionId, bool showTips = true)
  16. {
  17. string name = ViewManager.GetName(functionId);
  18. FunctionOpenCfg cfg = CommonDataManager.Tables.TblFunctionOpenCfg.GetOrDefault(name);
  19. if (cfg == null)
  20. {
  21. // Debug.LogWarning("g功能.xlsx 功能开启_FunctionOpenCfg 未添加 " + viewName + " 的配置");
  22. return true;//未配置功能开启的暂时默认开启
  23. }
  24. if (cfg.ParentId != null && cfg.ParentId != "")
  25. {
  26. //先检查父功能是否开启
  27. if (!CheckIsFunOpenById(cfg.ParentId, showTips))
  28. {
  29. return false;
  30. }
  31. }
  32. if (!CheckIsChapterFunOpen(cfg, showTips)) return false;
  33. if (!CheckIsLvFunOpen(cfg, showTips)) return false;
  34. if (!CheckIsSpecialFunOpen(cfg, showTips)) return false;
  35. return true;
  36. }
  37. public string GetOpenTips(string functionId)
  38. {
  39. FunctionOpenCfg cfg = CommonDataManager.Tables.TblFunctionOpenCfg.GetOrDefault(functionId);
  40. if (cfg == null)
  41. {
  42. return "";
  43. }
  44. if (!CheckIsChapterFunOpen(cfg, false))
  45. {
  46. return GetChapterOpenTips(cfg);
  47. }
  48. if (!CheckIsLvFunOpen(cfg, false))
  49. {
  50. return GetLvTips(cfg);
  51. }
  52. if (!CheckIsSpecialFunOpen(cfg, false))
  53. {
  54. return GetChapterLvTips(cfg);
  55. }
  56. return "";
  57. }
  58. /// <summary>
  59. /// 根据章节Id检测是否有新功能开启
  60. /// </summary>
  61. public void CheckHasChapterFunOpen(int storyLevelCfgId)
  62. {
  63. List<FunctionOpenCfg> cfgs = CommonDataManager.Tables.TblFunctionOpenCfg.DataList;
  64. List<string> listCfg = new List<string>();
  65. for (int i = 0; i < cfgs.Count; i++)
  66. {
  67. if (cfgs[i].Id == typeof(ArenaView).Name && cfgs[i].StoryLevelId == storyLevelCfgId) ArenaDataManager.Instance.ReqArenaInfo();
  68. if (cfgs[i].Show == 0) continue;
  69. if (cfgs[i].Special > 0) continue;
  70. if (cfgs[i].Lv > 0) continue;
  71. if (cfgs[i].StoryLevelId != storyLevelCfgId || !CheckIsChapterFunOpen(cfgs[i], false)) continue;
  72. // if (CheckIsLvFunOpen(cfgs[i], false)) continue;
  73. listCfg.Add(cfgs[i].Id);
  74. }
  75. if (listCfg.Count > 0)
  76. {
  77. // Timers.inst.Add(1, 0, FunctionOpen, listCfg);
  78. ViewManager.Show<FunctionOpenView>(listCfg);
  79. }
  80. }
  81. /// <summary>
  82. /// 根据角色Lv检测是否有新功能开启
  83. /// </summary>
  84. public void CheckHasLvFunOpen(int lv, int oldLv)
  85. {
  86. List<FunctionOpenCfg> cfgs = CommonDataManager.Tables.TblFunctionOpenCfg.DataList ;
  87. List<string> listCfg = new List<string>();
  88. for (int i = 0; i < cfgs.Count; i++)
  89. {
  90. if (cfgs[i].Id == typeof(ArenaView).Name && oldLv < cfgs[i].Lv && cfgs[i].Lv == lv) ArenaDataManager.Instance.ReqArenaInfo();
  91. if ((cfgs[i].Special > 0)) continue;
  92. if (cfgs[i].Show == 0) continue;
  93. if (lv <= 0) continue;
  94. if (cfgs[i].StoryLevelId > 0) continue;
  95. if (oldLv >= cfgs[i].Lv || lv < cfgs[i].Lv || !CheckIsLvFunOpen(cfgs[i], false)) continue;
  96. // if (CheckIsChapterFunOpen(cfgs[i], false)) continue;
  97. listCfg.Add(cfgs[i].Id);
  98. }
  99. if (listCfg.Count > 0)
  100. {
  101. ViewManager.Show<FunctionOpenView>(listCfg);
  102. }
  103. }
  104. public async void CheckHasSpecialFunOpen()
  105. {
  106. if (StorageDataManager.Instance.GetStorangeDic().Count == 0)
  107. {
  108. await StorageSProxy.ReqGetClientValues();
  109. }
  110. List<FunctionOpenCfg> cfgs = CommonDataManager.Tables.TblFunctionOpenCfg.DataList ;
  111. List<string> listCfg = new List<string>();
  112. for (int i = 0; i < cfgs.Count; i++)
  113. {
  114. if (cfgs[i].Id == typeof(ArenaView).Name) ArenaDataManager.Instance.ReqArenaInfo();
  115. if (cfgs[i].Show == 0) continue;
  116. if (cfgs[i].StoryLevelId > 0) continue;
  117. if (cfgs[i].Lv > 0) continue;
  118. if ((cfgs[i].Special <= 0)) continue;
  119. if (StorageDataManager.Instance.GetStorageValue(ConstStorageId.FUNCTION_OPEN + cfgs[i].Index) == 1) continue;
  120. if (CheckIsSpecialFunOpen(cfgs[i], false))
  121. {
  122. listCfg.Add(cfgs[i].Id);
  123. }
  124. }
  125. if (listCfg.Count > 0)
  126. {
  127. ViewManager.Show<FunctionOpenView>(listCfg);
  128. }
  129. }
  130. //检测配置章节是否开启
  131. private bool CheckIsChapterFunOpen(FunctionOpenCfg cfg, bool showTips = true)
  132. {
  133. if (cfg.StoryLevelId <= 0)
  134. {
  135. return true;
  136. }
  137. if (InstanceZonesDataManager.CheckLevelPass(cfg.StoryLevelId))
  138. {
  139. return true;
  140. }
  141. StoryLevelCfg storyLevelCfg = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(cfg.StoryLevelId);
  142. StoryChapterCfg storyChapterCfg = CommonDataManager.Tables.TblStoryChapterCfg.GetOrDefault(storyLevelCfg.ChapterId);
  143. if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("通关主线{0}-{1}解锁", storyChapterCfg.Order, storyLevelCfg.Order));
  144. return false;
  145. }
  146. //检测配置角色是否开启
  147. private bool CheckIsLvFunOpen(FunctionOpenCfg cfg, bool showTips = true)
  148. {
  149. //GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl)
  150. if (RoleDataManager.lvl >= cfg.Lv)
  151. {
  152. return true;
  153. }
  154. if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("角色达到{0}级解锁", cfg.Lv));
  155. return false;
  156. }
  157. private bool CheckIsSpecialFunOpen(FunctionOpenCfg cfg, bool showTips = true)
  158. {
  159. if (cfg.Special <= 0) return true;
  160. if (cfg.Id == typeof(ClothingListView).Name)//服装升级获取第一套【天衣】套装后开启
  161. {
  162. if (StorageDataManager.Instance.GetStorageValue(ConstStorageId.FUNCTION_OPEN + cfg.Index) == 1) return true;
  163. List<int> _currentList3 = DressUpMenuSuitDataManager.GetSuitIDList();
  164. if (_currentList3.Count == 0)
  165. {
  166. if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("收集一套“天衣”套装后解锁"));
  167. return false;
  168. }
  169. _currentList3 = SuitUtil.SortSuitListByHighRarity(_currentList3);
  170. if ( CommonDataManager.Tables.TblSuitCfg.GetOrDefault(_currentList3[0]).Rarity == ConstDressRarity.Rarity_TIANYI)
  171. {
  172. StorageSProxy.ReqSetClientValue(ConstStorageId.FUNCTION_OPEN + cfg.Index, 1).Coroutine();
  173. return true;
  174. }
  175. else
  176. {
  177. if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("收集一套“天衣”套装后解锁"));
  178. }
  179. }
  180. return false;
  181. }
  182. private string GetChapterOpenTips(FunctionOpenCfg cfg)
  183. {
  184. string strTips = "";
  185. if (cfg.StoryLevelId > 0)
  186. {
  187. StoryLevelCfg storyLevelCfg = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(cfg.StoryLevelId);
  188. StoryChapterCfg storyChapterCfg = CommonDataManager.Tables.TblStoryChapterCfg.GetOrDefault(storyLevelCfg.ChapterId);
  189. strTips = string.Format("通关主线{0}-{1}解锁", storyChapterCfg.Order, storyLevelCfg.Order);
  190. }
  191. return strTips;
  192. }
  193. private string GetLvTips(FunctionOpenCfg cfg)
  194. {
  195. string strTips = "";
  196. if (cfg.Lv > 0)
  197. {
  198. strTips = string.Format("角色达到{0}级解锁", cfg.Lv);
  199. }
  200. return strTips;
  201. }
  202. private string GetChapterLvTips(FunctionOpenCfg cfg)
  203. {
  204. string strTips = "";
  205. if (cfg.Special > 0)
  206. {
  207. if (cfg.Id == typeof(ClothingListView).Name)//服装升级获取第一套【天衣】套装后开启
  208. {
  209. strTips = string.Format("收集一套“天衣”套装后解锁");
  210. }
  211. }
  212. return strTips;
  213. }
  214. }
  215. }