using System.Collections; using System.Collections.Generic; using System; using UnityEngine; using ET; using ProtoBuf.Meta; namespace GFGGame { public class MainStoryDataManager { public static string priorId = "prior";//首次登录前置剧情id //剧情副本专用当前章节 public static int currentChapterCfgId = 0; //剧情副本专用当前关卡序号,从1开始 public static int CurrentChapterOrder { get { var chapterCfg = StoryChapterCfgArray.Instance.GetCfg(currentChapterCfgId); if (chapterCfg != null) { return chapterCfg.order; } return 0; } } //剧情副本专用关卡编号 private static int _currentLevelCfgId; public static int currentLevelCfgId { get { return _currentLevelCfgId; } set { int lastLevelCfgId = _currentLevelCfgId; var lastLevelCfg = StoryLevelCfgArray.Instance.GetCfg(_currentLevelCfgId); _currentLevelCfgId = value; var levelCfg = StoryLevelCfgArray.Instance.GetCfg(_currentLevelCfgId); currentChapterCfgId = levelCfg == null ? lastLevelCfg.chapterId : levelCfg.chapterId; } } //剧情副本专用关卡宝箱状态记录 private static Dictionary _chapterBonusDic = new Dictionary(); public static void InitBoxBonusStates(List ks, List vs) { _chapterBonusDic.Clear(); for (var i = 0; i < ks.Count; ++i) { var states = new int[] { 0, 0, 0 }; var value = vs[i]; CalculateHelper.GenerateChapterBoxStates(states, value); _chapterBonusDic.Add(ks[i], states); } } public static void UpdateBoxBonusStates(int chapter, int stateInt) { if (!_chapterBonusDic.TryGetValue(chapter, out var states)) { states = new int[] { 0, 0, 0 }; _chapterBonusDic.Add(chapter, states); } CalculateHelper.GenerateChapterBoxStates(states, stateInt); } //获取宝箱奖励状态 public static int GetChapterBonusStatus(int chapterID, int index) { if (_chapterBonusDic.ContainsKey(chapterID)) { var states = _chapterBonusDic[chapterID]; if (states != null) { return states[index]; } } return ConstBonusStatus.CAN_NOT_GET; } public static List GetChapterBonus(int chapterID, int index) { List bonusList = StoryBonusDataCache.GetChapterBonusList(chapterID, index); return bonusList; } public static bool CheckOpenMainUI() { return InstanceZonesDataManager.CheckLevelPass(100001002); } //检查指定章节对应的普通章节是否通关 public static bool CheckNeedChapterPass(int chapterId, out int needChapterId) { StoryChapterCfg chapterCfg = StoryChapterCfgArray.Instance.GetCfg(chapterId); needChapterId = chapterCfg.needChapterId; if (chapterCfg.needChapterId > 0) { var preChapterCfg = StoryChapterCfgArray.Instance.GetCfg(chapterCfg.needChapterId); if (preChapterCfg != null) { return InstanceZonesDataManager.CheckChapterPass(preChapterCfg.type, preChapterCfg.subType, preChapterCfg.id, preChapterCfg.levelCount); } } return true; } public static bool CheckChapterUnlock(int chapterId, bool checkRoleLv = true) { StoryChapterCfg chapterCfg = StoryChapterCfgArray.Instance.GetCfg(chapterId); if (checkRoleLv && GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) < chapterCfg.lvl) { return false; } //上一关卡 int preChapterId = chapterId - 1; var preChapterCfg = StoryChapterCfgArray.Instance.GetCfg(preChapterId); if (preChapterCfg != null) { if(!InstanceZonesDataManager.CheckChapterPass(preChapterCfg.type, preChapterCfg.subType, preChapterCfg.id, preChapterCfg.levelCount)) { return false; } } //前置关卡 return CheckNeedChapterPass(chapterId, out var needChapterId); } public static bool CheckLevelUnlock(int levelCfgId, bool checkRoleLv = true) { var levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId); if (levelCfg != null) { if (!CheckChapterUnlock(levelCfg.chapterId, checkRoleLv)) { return false; } var passLevelOrder = InstanceZonesDataManager.GetPassLevelOrder(levelCfg.type, levelCfg.subType, levelCfg.chapterId); return levelCfg.order <= passLevelOrder + 1; } return false; } public static bool CheckCurrentLevelPass() { return InstanceZonesDataManager.CheckLevelPass(currentLevelCfgId); } //判断章节是否是精英关卡 public static bool CheckChapterIsHard(int chapterId) { return GetChapterSubType(chapterId) == ConstInstanceZonesSubType.Hard; } //获取章节难度(普通或者精英) public static int GetChapterSubType(int chapterId) { var chapterCfg = StoryChapterCfgArray.Instance.GetCfg(chapterId); if (chapterCfg != null) { return chapterCfg.subType; } return ConstInstanceZonesSubType.Normal; } } }