FunctionOpenDataManager.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. /// <summary>
  37. /// 根据章节Id检测是否有新功能开启
  38. /// </summary>
  39. public void CheckHasChapterFunOpen(int storyLevelCfgId)
  40. {
  41. FunctionOpenCfg[] cfgs = FunctionOpenCfgArray.Instance.dataArray;
  42. List<string> listCfg = new List<string>();
  43. for (int i = 0; i < cfgs.Length; i++)
  44. {
  45. if (cfgs[i].show == 0) continue;
  46. if (cfgs[i].special > 0) continue;
  47. if (cfgs[i].lv > 0) continue;
  48. if (cfgs[i].storyLevelId != storyLevelCfgId || !CheckIsChapterFunOpen(cfgs[i], false)) continue;
  49. // if (CheckIsLvFunOpen(cfgs[i], false)) continue;
  50. listCfg.Add(cfgs[i].id);
  51. }
  52. if (listCfg.Count > 0)
  53. {
  54. // Timers.inst.Add(1, 0, FunctionOpen, listCfg);
  55. ViewManager.Show<FunctionOpenView>(listCfg);
  56. }
  57. }
  58. /// <summary>
  59. /// 根据角色Lv检测是否有新功能开启
  60. /// </summary>
  61. public void CheckHasLvFunOpen(int lv, int oldLv)
  62. {
  63. FunctionOpenCfg[] cfgs = FunctionOpenCfgArray.Instance.dataArray;
  64. List<string> listCfg = new List<string>();
  65. for (int i = 0; i < cfgs.Length; i++)
  66. {
  67. if ((cfgs[i].special > 0)) continue;
  68. if (cfgs[i].show == 0) continue;
  69. if (lv <= 0) continue;
  70. if (cfgs[i].storyLevelId > 0) continue;
  71. if (oldLv >= cfgs[i].lv || lv < cfgs[i].lv || !CheckIsLvFunOpen(cfgs[i], false)) continue;
  72. // if (CheckIsChapterFunOpen(cfgs[i], false)) continue;
  73. listCfg.Add(cfgs[i].id);
  74. }
  75. if (listCfg.Count > 0)
  76. {
  77. ViewManager.Show<FunctionOpenView>(listCfg);
  78. }
  79. }
  80. public async void CheckHasSpecialFunOpen()
  81. {
  82. if (StorageDataManager.Instance.GetStorangeDic().Count == 0)
  83. {
  84. await StorageSProxy.ReqGetClientValues();
  85. }
  86. FunctionOpenCfg[] cfgs = FunctionOpenCfgArray.Instance.dataArray;
  87. List<string> listCfg = new List<string>();
  88. for (int i = 0; i < cfgs.Length; i++)
  89. {
  90. if (cfgs[i].show == 0) continue;
  91. if (cfgs[i].storyLevelId > 0) continue;
  92. if (cfgs[i].lv > 0) continue;
  93. if ((cfgs[i].special <= 0)) continue;
  94. if (StorageDataManager.Instance.GetStorageValue(ConstStorageId.FUNCTION_OPEN + cfgs[i].index) == 1) continue;
  95. if (CheckIsSpecialFunOpen(cfgs[i], false))
  96. {
  97. listCfg.Add(cfgs[i].id);
  98. }
  99. }
  100. if (listCfg.Count > 0)
  101. {
  102. ViewManager.Show<FunctionOpenView>(listCfg);
  103. }
  104. }
  105. // private void FunctionOpen(object param)
  106. // {
  107. // if (ViewManager.isViewOpen(typeof(RoleLvUpView).Name)) return;
  108. // ViewManager.Show<FunctionOpenView>(param);
  109. // Timers.inst.Remove(FunctionOpen);
  110. // }
  111. //检测配置章节是否开启
  112. private bool CheckIsChapterFunOpen(FunctionOpenCfg cfg, bool showTips = true)
  113. {
  114. if (cfg.storyLevelId <= 0)
  115. {
  116. return true;
  117. }
  118. if (InstanceZonesDataManager.CheckLevelPass(cfg.storyLevelId))
  119. {
  120. return true;
  121. }
  122. StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(cfg.storyLevelId);
  123. StoryChapterCfg storyChapterCfg = StoryChapterCfgArray.Instance.GetCfg(storyLevelCfg.chapterId);
  124. if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("通关主线{0}-{1}解锁", storyChapterCfg.order, storyLevelCfg.order));
  125. return false;
  126. }
  127. //检测配置角色是否开启
  128. private bool CheckIsLvFunOpen(FunctionOpenCfg cfg, bool showTips = true)
  129. {
  130. //GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl)
  131. if (RoleDataManager.lvl >= cfg.lv)
  132. {
  133. return true;
  134. }
  135. if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("角色达到{0}级解锁", cfg.lv));
  136. return false;
  137. }
  138. private bool CheckIsSpecialFunOpen(FunctionOpenCfg cfg, bool showTips = true)
  139. {
  140. if (cfg.special <= 0) return true;
  141. if (cfg.id == typeof(ClothingListView).Name)//服装升级获取第一套【天衣】套装后开启
  142. {
  143. if (StorageDataManager.Instance.GetStorageValue(ConstStorageId.FUNCTION_OPEN + cfg.index) == 1) return true;
  144. List<int> _currentList3 = DressUpMenuSuitDataManager.GetSuitIDList();
  145. if (_currentList3.Count == 0)
  146. {
  147. if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("收集一套“天衣”套装后解锁"));
  148. return false;
  149. }
  150. _currentList3 = SuitUtil.SortSuitListByHighRarity(_currentList3);
  151. if (SuitCfgArray.Instance.GetCfg(_currentList3[0]).rarity == ConstDressRarity.Rarity_TIANYI)
  152. {
  153. StorageSProxy.ReqSetClientValue(ConstStorageId.FUNCTION_OPEN + cfg.index, 1).Coroutine();
  154. return true;
  155. }
  156. else
  157. {
  158. if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("收集一套“天衣”套装后解锁"));
  159. }
  160. }
  161. return false;
  162. }
  163. }
  164. }