FunctionOpenDataManager.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 (cfgs[i].lv > oldLv && 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 void CheckHasSpecialFunOpen()
  81. {
  82. FunctionOpenCfg[] cfgs = FunctionOpenCfgArray.Instance.dataArray;
  83. List<string> listCfg = new List<string>();
  84. for (int i = 0; i < cfgs.Length; i++)
  85. {
  86. if (cfgs[i].show == 0) continue;
  87. if (cfgs[i].storyLevelId > 0) continue;
  88. if (cfgs[i].lv > 0) continue;
  89. if ((cfgs[i].special <= 0)) continue;
  90. if (StorageDataManager.Instance.GetStorageValue(ConstStorageId.FUNCTION_OPEN + cfgs[i].index) == 1) continue;
  91. if (CheckIsSpecialFunOpen(cfgs[i], false))
  92. {
  93. listCfg.Add(cfgs[i].id);
  94. }
  95. }
  96. if (listCfg.Count > 0)
  97. {
  98. ViewManager.Show<FunctionOpenView>(listCfg);
  99. }
  100. }
  101. // private void FunctionOpen(object param)
  102. // {
  103. // if (ViewManager.isViewOpen(typeof(RoleLvUpView).Name)) return;
  104. // ViewManager.Show<FunctionOpenView>(param);
  105. // Timers.inst.Remove(FunctionOpen);
  106. // }
  107. //检测配置章节是否开启
  108. private bool CheckIsChapterFunOpen(FunctionOpenCfg cfg, bool showTips = true)
  109. {
  110. if (cfg.storyLevelId <= 0)
  111. {
  112. return true;
  113. }
  114. if (InstanceZonesDataManager.CheckLevelPass(cfg.storyLevelId))
  115. {
  116. return true;
  117. }
  118. StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(cfg.storyLevelId);
  119. StoryChapterCfg storyChapterCfg = StoryChapterCfgArray.Instance.GetCfg(storyLevelCfg.chapterId);
  120. if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("通关主线{0}-{1}解锁", storyChapterCfg.order, storyLevelCfg.order));
  121. return false;
  122. }
  123. //检测配置角色是否开启
  124. private bool CheckIsLvFunOpen(FunctionOpenCfg cfg, bool showTips = true)
  125. {
  126. //GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl)
  127. if (RoleDataManager.lvl >= cfg.lv)
  128. {
  129. return true;
  130. }
  131. if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("角色达到{0}级解锁", cfg.lv));
  132. return false;
  133. }
  134. private bool CheckIsSpecialFunOpen(FunctionOpenCfg cfg, bool showTips = true)
  135. {
  136. if (cfg.special <= 0) return true;
  137. if (cfg.id == typeof(SuitListView).Name)//服装升级获取第一套【天衣】套装后开启
  138. {
  139. if (StorageDataManager.Instance.GetStorageValue(ConstStorageId.FUNCTION_OPEN + cfg.index) == 1) return true;
  140. List<int> _currentList3 = DressUpMenuSuitDataManager.GetSuitIDList();
  141. if (_currentList3.Count == 0) return false;
  142. _currentList3 = SuitUtil.SortSuitListByHighRarity(_currentList3);
  143. if (SuitCfgArray.Instance.GetCfg(_currentList3[0]).rarity == ConstDressRarity.Rarity_TIANYI)
  144. {
  145. StorageSProxy.ReqSetClientValue(ConstStorageId.FUNCTION_OPEN + cfg.index, 1).Coroutine();
  146. return true;
  147. }
  148. if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("收集一套“天衣”套装后开启"));
  149. }
  150. return false;
  151. }
  152. }
  153. }