123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- 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<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 = 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 int CheckChapterPassIndex(int subtype)
- {
- int count = 2;
- List<StoryChapterCfg> chapList = StoryChapterCfgArray.Instance.GetCfgsBysubType(subtype);
- foreach (StoryChapterCfg item in chapList)
- {
- var preChapterCfg = StoryChapterCfgArray.Instance.GetCfg(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 = 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;
- }
- //章节奖励状态
- public static Dictionary<int, int> ChapterRewardStatusDic = new Dictionary<int, int>();
- public static bool GetChapterRewardStatus()
- {
- foreach(var item in ChapterRewardStatusDic)
- {
- if(item.Value == 1)
- {
- return true;
- }
- }
- return false;
- }
- }
- }
|