FunctionOpenDataManager.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. return true;
  34. }
  35. /// <summary>
  36. /// 根据章节Id检测是否有新功能开启
  37. /// </summary>
  38. public void CheckHasChapterFunOpen(int storyLevelCfgId)
  39. {
  40. FunctionOpenCfg[] cfgs = FunctionOpenCfgArray.Instance.dataArray;
  41. List<string> listCfg = new List<string>();
  42. for (int i = 0; i < cfgs.Length; i++)
  43. {
  44. if (cfgs[i].show == 0) continue;
  45. if (cfgs[i].storyLevelId != storyLevelCfgId || !CheckIsChapterFunOpen(cfgs[i], false)) continue;
  46. if (!CheckIsLvFunOpen(cfgs[i], false)) continue;
  47. listCfg.Add(cfgs[i].id);
  48. }
  49. if (listCfg.Count > 0)
  50. {
  51. // Timers.inst.Add(1, 0, FunctionOpen, listCfg);
  52. ViewManager.Show<FunctionOpenView>(listCfg);
  53. }
  54. }
  55. /// <summary>
  56. /// 根据角色Lv检测是否有新功能开启
  57. /// </summary>
  58. public void CheckHasLvFunOpen(int lv)
  59. {
  60. FunctionOpenCfg[] cfgs = FunctionOpenCfgArray.Instance.dataArray;
  61. List<string> listCfg = new List<string>();
  62. for (int i = 0; i < cfgs.Length; i++)
  63. {
  64. if (cfgs[i].show == 0) continue;
  65. if (lv != cfgs[i].lv || !CheckIsLvFunOpen(cfgs[i], false)) continue;
  66. if (!CheckIsChapterFunOpen(cfgs[i], false)) continue;
  67. listCfg.Add(cfgs[i].id);
  68. }
  69. if (listCfg.Count > 0)
  70. {
  71. // Timers.inst.Add(1, 0, FunctionOpen, listCfg);
  72. ViewManager.Show<FunctionOpenView>(listCfg);
  73. }
  74. }
  75. // private void FunctionOpen(object param)
  76. // {
  77. // if (ViewManager.isViewOpen(typeof(RoleLvUpView).Name)) return;
  78. // ViewManager.Show<FunctionOpenView>(param);
  79. // Timers.inst.Remove(FunctionOpen);
  80. // }
  81. //检测配置章节是否开启
  82. private bool CheckIsChapterFunOpen(FunctionOpenCfg cfg, bool showTips = true)
  83. {
  84. if (cfg.storyLevelId <= 0)
  85. {
  86. return true;
  87. }
  88. if (InstanceZonesDataManager.CheckLevelPass(cfg.storyLevelId))
  89. {
  90. return true;
  91. }
  92. StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(cfg.storyLevelId);
  93. StoryChapterCfg storyChapterCfg = StoryChapterCfgArray.Instance.GetCfg(storyLevelCfg.chapterId);
  94. if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("通关主线{0}-{1}解锁", storyChapterCfg.order, storyLevelCfg.order));
  95. return false;
  96. }
  97. //检测配置角色是否开启
  98. private bool CheckIsLvFunOpen(FunctionOpenCfg cfg, bool showTips = true)
  99. {
  100. //GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl)
  101. if (RoleDataManager.lvl >= cfg.lv)
  102. {
  103. return true;
  104. }
  105. if (showTips) PromptController.Instance.ShowFloatTextPrompt(string.Format("角色达到{0}级解锁", cfg.lv));
  106. return false;
  107. }
  108. }
  109. }