FunctionOpenDataManager.cs 6.0 KB

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