FunctionOpenDataManager.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. }
  73. if (listCfg.Count > 0)
  74. {
  75. // Timers.inst.Add(1, 0, FunctionOpen, listCfg);
  76. ViewManager.Show<FunctionOpenView>(listCfg);
  77. }
  78. }
  79. /// <summary>
  80. /// 根据角色Lv检测是否有新功能开启
  81. /// </summary>
  82. public void CheckHasLvFunOpen(int lv, int oldLv)
  83. {
  84. FunctionOpenCfg[] cfgs = FunctionOpenCfgArray.Instance.dataArray;
  85. List<string> listCfg = new List<string>();
  86. for (int i = 0; i < cfgs.Length; i++)
  87. {
  88. if ((cfgs[i].special > 0)) continue;
  89. if (cfgs[i].show == 0) continue;
  90. if (lv <= 0) continue;
  91. if (cfgs[i].storyLevelId > 0) continue;
  92. if (oldLv >= cfgs[i].lv || lv < cfgs[i].lv || !CheckIsLvFunOpen(cfgs[i], false)) continue;
  93. // if (CheckIsChapterFunOpen(cfgs[i], false)) continue;
  94. listCfg.Add(cfgs[i].id);
  95. }
  96. if (listCfg.Count > 0)
  97. {
  98. ViewManager.Show<FunctionOpenView>(listCfg);
  99. }
  100. }
  101. public async void CheckHasSpecialFunOpen()
  102. {
  103. if (StorageDataManager.Instance.GetStorangeDic().Count == 0)
  104. {
  105. await StorageSProxy.ReqGetClientValues();
  106. }
  107. FunctionOpenCfg[] cfgs = FunctionOpenCfgArray.Instance.dataArray;
  108. List<string> listCfg = new List<string>();
  109. for (int i = 0; i < cfgs.Length; i++)
  110. {
  111. if (cfgs[i].show == 0) continue;
  112. if (cfgs[i].storyLevelId > 0) continue;
  113. if (cfgs[i].lv > 0) continue;
  114. if ((cfgs[i].special <= 0)) continue;
  115. if (StorageDataManager.Instance.GetStorageValue(ConstStorageId.FUNCTION_OPEN + cfgs[i].index) == 1) continue;
  116. if (CheckIsSpecialFunOpen(cfgs[i], false))
  117. {
  118. listCfg.Add(cfgs[i].id);
  119. }
  120. }
  121. if (listCfg.Count > 0)
  122. {
  123. ViewManager.Show<FunctionOpenView>(listCfg);
  124. }
  125. }
  126. //检测配置章节是否开启
  127. private bool CheckIsChapterFunOpen(FunctionOpenCfg cfg, bool showTips = true)
  128. {
  129. if (cfg.storyLevelId <= 0)
  130. {
  131. return true;
  132. }
  133. if (InstanceZonesDataManager.CheckLevelPass(cfg.storyLevelId))
  134. {
  135. return true;
  136. }
  137. StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(cfg.storyLevelId);
  138. StoryChapterCfg storyChapterCfg = StoryChapterCfgArray.Instance.GetCfg(storyLevelCfg.chapterId);
  139. if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("通关主线{0}-{1}解锁", storyChapterCfg.order, storyLevelCfg.order));
  140. return false;
  141. }
  142. //检测配置角色是否开启
  143. private bool CheckIsLvFunOpen(FunctionOpenCfg cfg, bool showTips = true)
  144. {
  145. //GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl)
  146. if (RoleDataManager.lvl >= cfg.lv)
  147. {
  148. return true;
  149. }
  150. if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("角色达到{0}级解锁", cfg.lv));
  151. return false;
  152. }
  153. private bool CheckIsSpecialFunOpen(FunctionOpenCfg cfg, bool showTips = true)
  154. {
  155. if (cfg.special <= 0) return true;
  156. if (cfg.id == typeof(ClothingListView).Name)//服装升级获取第一套【天衣】套装后开启
  157. {
  158. if (StorageDataManager.Instance.GetStorageValue(ConstStorageId.FUNCTION_OPEN + cfg.index) == 1) return true;
  159. List<int> _currentList3 = DressUpMenuSuitDataManager.GetSuitIDList();
  160. if (_currentList3.Count == 0)
  161. {
  162. if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("收集一套“天衣”套装后解锁"));
  163. return false;
  164. }
  165. _currentList3 = SuitUtil.SortSuitListByHighRarity(_currentList3);
  166. if (SuitCfgArray.Instance.GetCfg(_currentList3[0]).rarity == ConstDressRarity.Rarity_TIANYI)
  167. {
  168. StorageSProxy.ReqSetClientValue(ConstStorageId.FUNCTION_OPEN + cfg.index, 1).Coroutine();
  169. return true;
  170. }
  171. else
  172. {
  173. if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("收集一套“天衣”套装后解锁"));
  174. }
  175. }
  176. return false;
  177. }
  178. private string GetChapterOpenTips(FunctionOpenCfg cfg)
  179. {
  180. string strTips = "";
  181. if (cfg.storyLevelId > 0)
  182. {
  183. StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(cfg.storyLevelId);
  184. StoryChapterCfg storyChapterCfg = StoryChapterCfgArray.Instance.GetCfg(storyLevelCfg.chapterId);
  185. strTips = string.Format("通关主线{0}-{1}解锁", storyChapterCfg.order, storyLevelCfg.order);
  186. }
  187. return strTips;
  188. }
  189. private string GetLvTips(FunctionOpenCfg cfg)
  190. {
  191. string strTips = "";
  192. if (cfg.lv > 0)
  193. {
  194. strTips = string.Format("角色达到{0}级解锁", cfg.lv);
  195. }
  196. return strTips;
  197. }
  198. private string GetChapterLvTips(FunctionOpenCfg cfg)
  199. {
  200. string strTips = "";
  201. if (cfg.special > 0)
  202. {
  203. if (cfg.id == typeof(ClothingListView).Name)//服装升级获取第一套【天衣】套装后开启
  204. {
  205. strTips = string.Format("收集一套“天衣”套装后解锁");
  206. }
  207. }
  208. return strTips;
  209. }
  210. }
  211. }