FunctionOpenDataManager.cs 8.9 KB

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