FunctionOpenDataManager.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using ET;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace GFGGame
  5. {
  6. public class FunctionOpenDataManager : SingletonBase<FunctionOpenDataManager>
  7. {
  8. /// <summary>
  9. /// 根据功能名检测功能是否开启
  10. /// </summary>
  11. /// <param name="functionId"></param>
  12. /// <returns></returns>
  13. public bool CheckIsFunOpenById(string functionId, bool showTips = true)
  14. {
  15. FunctionOpenCfg cfg = FunctionOpenCfgArray.Instance.GetCfg(functionId);
  16. if (cfg == null)
  17. {
  18. // Debug.LogWarning("g功能.xlsx 功能开启_FunctionOpenCfg 未添加 " + viewName + " 的配置");
  19. return true;//未配置功能开启的暂时默认开启
  20. }
  21. if (cfg.parentId != null && cfg.parentId != "")
  22. {
  23. //先检查父功能是否开启
  24. if (!CheckIsFunOpenById(cfg.parentId))
  25. {
  26. return false;
  27. }
  28. }
  29. if (!CheckIsChapterFunOpen(cfg, showTips)) return false;
  30. if (!CheckIsLvFunOpen(cfg, showTips)) return false;
  31. return true;
  32. }
  33. /// <summary>
  34. /// 根据章节Id检测是否有新功能开启
  35. /// </summary>
  36. public void CheckHasChapterFunOpen(int storyLevelCfgId)
  37. {
  38. FunctionOpenCfg[] cfgs = FunctionOpenCfgArray.Instance.dataArray;
  39. List<string> listCfg = new List<string>();
  40. for (int i = 0; i < cfgs.Length; i++)
  41. {
  42. if (cfgs[i].show == 0) continue;
  43. if (cfgs[i].storyLevelId != storyLevelCfgId || !CheckIsChapterFunOpen(cfgs[i], false)) continue;
  44. if (!CheckIsLvFunOpen(cfgs[i], false)) continue;
  45. listCfg.Add(cfgs[i].id);
  46. }
  47. if (listCfg.Count > 0)
  48. {
  49. ViewManager.Show<FunctionOpenView>(listCfg);
  50. }
  51. }
  52. /// <summary>
  53. /// 根据角色Lv检测是否有新功能开启
  54. /// </summary>
  55. public void CheckHasLvFunOpen(int lv)
  56. {
  57. FunctionOpenCfg[] cfgs = FunctionOpenCfgArray.Instance.dataArray;
  58. List<string> listCfg = new List<string>();
  59. for (int i = 0; i < cfgs.Length; i++)
  60. {
  61. if (cfgs[i].show == 0) continue;
  62. if (lv != cfgs[i].lv || !CheckIsLvFunOpen(cfgs[i], false)) continue;
  63. if (!CheckIsChapterFunOpen(cfgs[i], false)) continue;
  64. listCfg.Add(cfgs[i].id);
  65. }
  66. if (listCfg.Count > 0)
  67. {
  68. ViewManager.Show<FunctionOpenView>(listCfg);
  69. }
  70. }
  71. //检测配置章节是否开启
  72. private bool CheckIsChapterFunOpen(FunctionOpenCfg cfg, bool showTips = true)
  73. {
  74. if (cfg.storyLevelId <= 0)
  75. {
  76. return true;
  77. }
  78. if (InstanceZonesDataManager.CheckLevelPass(cfg.storyLevelId))
  79. {
  80. return true;
  81. }
  82. if (showTips) PromptController.Instance.ShowFloatTextPrompt("功能暂未开启,敬请期待");
  83. return false;
  84. }
  85. //检测配置角色是否开启
  86. private bool CheckIsLvFunOpen(FunctionOpenCfg cfg, bool showTips = true)
  87. {
  88. if (GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= cfg.lv)
  89. {
  90. return true;
  91. }
  92. if (showTips) PromptController.Instance.ShowFloatTextPrompt("功能暂未开启,敬请期待");
  93. return false;
  94. }
  95. }
  96. }