| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- using System.Collections;
- using System.Collections.Generic;
- using System;
- using cfg.GfgCfg;
- 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 = CommonDataManager.Tables.TblStoryChapterCfg.GetOrDefault(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 = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(_currentLevelCfgId);
- _currentLevelCfgId = value;
- var levelCfg = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(_currentLevelCfgId);
- currentChapterCfgId = levelCfg == null ? lastLevelCfg.ChapterId : levelCfg.ChapterId;
- }
- }
- //剧情副本专用关卡宝箱状态记录
- private static Dictionary<int, int[]> _chapterBonusDic = new Dictionary<int, int[]>();
- public static void InitBoxBonusStates(List<int> ks, List<int> 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<ItemData> GetChapterBonus(int chapterID, int index)
- {
- List<ItemData> 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 = CommonDataManager.Tables.TblStoryChapterCfg.GetOrDefault(chapterId);
- needChapterId = chapterCfg.NeedChapterId;
- if (chapterCfg.NeedChapterId > 0)
- {
- var preChapterCfg = CommonDataManager.Tables.TblStoryChapterCfg.GetOrDefault(chapterCfg.NeedChapterId);
- if (preChapterCfg != null)
- {
- return InstanceZonesDataManager.CheckChapterPass(preChapterCfg.Type, preChapterCfg.SubType,
- preChapterCfg.Id, preChapterCfg.LevelCount);
- }
- }
- return true;
- }
- public static int CheckChapterPassIndex(int subtype)
- {
- int count = 2;
- List<StoryChapterCfg> chapList = CommonDataManager.Tables.TblStoryChapterCfg.GetGroup1BySubType(subtype);
- foreach (StoryChapterCfg item in chapList)
- {
- var preChapterCfg = CommonDataManager.Tables.TblStoryChapterCfg.GetOrDefault(item.Id);
- if (preChapterCfg != null)
- {
- if (InstanceZonesDataManager.CheckChapterPass(preChapterCfg.Type, preChapterCfg.SubType,
- preChapterCfg.Id, preChapterCfg.LevelCount))
- {
- count++;
- }
- }
- }
- if (count > chapList.Count)
- {
- count = chapList.Count;
- }
- return count;
- }
- public static bool CheckChapterUnlock(int chapterId, bool checkRoleLv = true)
- {
- StoryChapterCfg chapterCfg = CommonDataManager.Tables.TblStoryChapterCfg.GetOrDefault(chapterId);
- if (checkRoleLv && GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) < chapterCfg.Lvl)
- {
- return false;
- }
- //上一关卡
- int preChapterId = chapterId - 1;
- var preChapterCfg = CommonDataManager.Tables.TblStoryChapterCfg.GetOrDefault(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 = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(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 = CommonDataManager.Tables.TblStoryChapterCfg.GetOrDefault(chapterId);
- if (chapterCfg != null)
- {
- return chapterCfg.SubType;
- }
- return ConstInstanceZonesSubType.Normal;
- }
- //章节奖励状态
- public static Dictionary<int, int> ChapterRewardStatusDic = new Dictionary<int, int>();
- public static bool GetChapterRewardStatus()
- {
- foreach (var item in ChapterRewardStatusDic)
- {
- StoryChapterCfg chapterRewardCfg = CommonDataManager.Tables.TblStoryChapterCfg.GetOrDefault(item.Key);
- if (chapterRewardCfg.Type == 1 && chapterRewardCfg.SubType == 1)
- {
- continue;
- }
- if (item.Value == 1)
- {
- return true;
- }
- }
- return false;
- }
- //关卡当前难度类型
- public static int currentChapterType = 0;
- }
- }
|