MainStoryDataManager.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using UnityEngine;
  5. using ET;
  6. using ProtoBuf.Meta;
  7. namespace GFGGame
  8. {
  9. public class MainStoryDataManager
  10. {
  11. public static string priorId = "prior";//首次登录前置剧情id
  12. //剧情副本专用当前章节
  13. public static int currentChapterCfgId = 0;
  14. //剧情副本专用当前关卡序号,从1开始
  15. public static int CurrentChapterOrder
  16. {
  17. get
  18. {
  19. var chapterCfg = StoryChapterCfgArray.Instance.GetCfg(currentChapterCfgId);
  20. if (chapterCfg != null)
  21. {
  22. return chapterCfg.order;
  23. }
  24. return 0;
  25. }
  26. }
  27. //剧情副本专用关卡编号
  28. private static int _currentLevelCfgId;
  29. public static int currentLevelCfgId
  30. {
  31. get
  32. {
  33. return _currentLevelCfgId;
  34. }
  35. set
  36. {
  37. _currentLevelCfgId = value;
  38. var levelCfg = StoryLevelCfgArray.Instance.GetCfg(_currentLevelCfgId);
  39. currentChapterCfgId = levelCfg.chapterId;
  40. }
  41. }
  42. //剧情副本专用关卡宝箱状态记录
  43. private static Dictionary<int, int[]> _chapterBonusDic = new Dictionary<int, int[]>();
  44. public static void InitBoxBonusStates(List<int> ks, List<int> vs)
  45. {
  46. _chapterBonusDic.Clear();
  47. for (var i = 0; i < ks.Count; ++i)
  48. {
  49. var states = new int[] { 0, 0, 0 };
  50. var value = vs[i];
  51. CalculateHelper.GenerateChapterBoxStates(states, value);
  52. _chapterBonusDic.Add(ks[i], states);
  53. }
  54. }
  55. public static void UpdateBoxBonusStates(int chapter, int stateInt)
  56. {
  57. if (!_chapterBonusDic.TryGetValue(chapter, out var states))
  58. {
  59. states = new int[] { 0, 0, 0 };
  60. _chapterBonusDic.Add(chapter, states);
  61. }
  62. CalculateHelper.GenerateChapterBoxStates(states, stateInt);
  63. }
  64. //获取宝箱奖励状态
  65. public static int GetChapterBonusStatus(int chapterID, int index)
  66. {
  67. if (_chapterBonusDic.ContainsKey(chapterID))
  68. {
  69. var states = _chapterBonusDic[chapterID];
  70. if (states != null)
  71. {
  72. return states[index];
  73. }
  74. }
  75. return ConstBonusStatus.CAN_NOT_GET;
  76. }
  77. public static List<ItemData> GetChapterBonus(int chapterID, int index)
  78. {
  79. List<ItemData> bonusList = StoryBonusDataCache.GetChapterBonusList(chapterID, index);
  80. return bonusList;
  81. }
  82. public static bool CheckOpenMainUI()
  83. {
  84. return InstanceZonesDataManager.CheckLevelPass(10004) && GuideDataManager.GetGuideCountCopy(ConstGuideId.SINGLE_FIGHT) > 0;
  85. }
  86. //检查指定章节对应的普通章节是否通关
  87. public static bool CheckNeedChapterPass(int chapterId, out int needChapterId)
  88. {
  89. StoryChapterCfg chapterCfg = StoryChapterCfgArray.Instance.GetCfg(chapterId);
  90. needChapterId = chapterCfg.needChapterId;
  91. if (chapterCfg.needChapterId > 0)
  92. {
  93. var preChapterCfg = StoryChapterCfgArray.Instance.GetCfg(chapterCfg.needChapterId);
  94. if (preChapterCfg != null)
  95. {
  96. return InstanceZonesDataManager.CheckChapterPass(preChapterCfg.type, preChapterCfg.subType, preChapterCfg.id, preChapterCfg.levelCount);
  97. }
  98. }
  99. return true;
  100. }
  101. public static bool CheckChapterUnlock(int chapterId)
  102. {
  103. StoryChapterCfg chapterCfg = StoryChapterCfgArray.Instance.GetCfg(chapterId);
  104. if (GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) < chapterCfg.lvl)
  105. {
  106. return false;
  107. }
  108. //上一关卡
  109. int preChapterId = chapterId - 1;
  110. var preChapterCfg = StoryChapterCfgArray.Instance.GetCfg(preChapterId);
  111. if(preChapterCfg != null)
  112. {
  113. return InstanceZonesDataManager.CheckChapterPass(preChapterCfg.type, preChapterCfg.subType, preChapterCfg.id, preChapterCfg.levelCount);
  114. }
  115. //前置关卡
  116. return CheckNeedChapterPass(chapterId, out var needChapterId);
  117. }
  118. public static bool CheckLevelUnlock(int levelCfgId)
  119. {
  120. var levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId);
  121. if (levelCfg != null)
  122. {
  123. if (!CheckChapterUnlock(levelCfg.chapterId))
  124. {
  125. return false;
  126. }
  127. var passLevelOrder = InstanceZonesDataManager.GetPassLevelOrder(levelCfg.type, levelCfg.subType, levelCfg.chapterId);
  128. return levelCfg.order <= passLevelOrder + 1;
  129. }
  130. return false;
  131. }
  132. public static bool CheckCurrentLevelPass()
  133. {
  134. return InstanceZonesDataManager.CheckLevelPass(currentLevelCfgId);
  135. }
  136. //判断章节是否是精英关卡
  137. public static bool CheckChapterIsHard(int chapterId)
  138. {
  139. return GetChapterSubType(chapterId) == ConstInstanceZonesSubType.Hard;
  140. }
  141. //获取章节难度(普通或者精英)
  142. public static int GetChapterSubType(int chapterId)
  143. {
  144. var chapterCfg = StoryChapterCfgArray.Instance.GetCfg(chapterId);
  145. if (chapterCfg != null)
  146. {
  147. return chapterCfg.subType;
  148. }
  149. return ConstInstanceZonesSubType.Normal;
  150. }
  151. }
  152. }