FunctionOpenDataManager.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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="viewName"></param>
  12. /// <returns></returns>
  13. public bool CheckIsFunOpenBgViewName(string viewName, bool showTips = true)
  14. {
  15. FunctionOpenCfg cfg = FunctionOpenCfgArray.Instance.GetCfg(viewName);
  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 (!CheckIsFunOpenBgViewName(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 chapterId, int level)
  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].chapterId != chapterId || cfgs[i].level != level || !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.chapterId > 0 && cfg.level <= 0 || cfg.level > 0 && cfg.chapterId <= 0)
  75. {
  76. if (showTips) PromptController.Instance.ShowFloatTextPrompt("功能暂未开启,敬请期待");
  77. return false;
  78. }
  79. if (cfg.chapterId > 0 && StoryDataManager.CheckLevelPass(cfg.chapterId, cfg.level))
  80. {
  81. return true;
  82. }
  83. if (showTips) PromptController.Instance.ShowFloatTextPrompt("功能暂未开启,敬请期待");
  84. return false;
  85. }
  86. //检测配置角色是否开启
  87. private bool CheckIsLvFunOpen(FunctionOpenCfg cfg, bool showTips = true)
  88. {
  89. if (GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= cfg.lv)
  90. {
  91. return true;
  92. }
  93. if (showTips) PromptController.Instance.ShowFloatTextPrompt("功能暂未开启,敬请期待");
  94. return false;
  95. }
  96. }
  97. }