using System; using System.Collections.Generic; using UnityEngine; namespace GFGGame { //本类为通用关卡数据类,特殊副本类型数据请写到各自的管理器里 public class InstanceZonesDataManager { //所有副本关卡通用换装战斗是否使用推荐 public static bool usedRecommend; //所有副本关卡通用 public static int currentScoreType; //所有副本关卡通用 public static int currentCardId = 0; //快速挑战挑战次数 public static int FightTimes = 10; //是否速刷中 public static bool isQuicklyFighting = false; //是否结算中 public static bool isResultFighting = false; //战斗场景 public static int FightScene; public static string[] currentFightTags; private static int _currentLevelCfgId; //所有副本关卡通用配置表的id public static int currentLevelCfgId { get { return _currentLevelCfgId; } set { _currentLevelCfgId = value; var levelCfg = StoryLevelCfgArray.Instance.GetCfg(_currentLevelCfgId); if (levelCfg.type == ConstInstanceZonesType.Story) { MainStoryDataManager.currentLevelCfgId = _currentLevelCfgId; } if (string.IsNullOrEmpty(levelCfg.fightID)) { currentFightTags = null; } else { StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID); currentFightTags = storyFightCfg.needTagsArr; } } } //所有副本关卡通用 public static int currentLevelOrder { get { var levelCfg = StoryLevelCfgArray.Instance.GetCfg(_currentLevelCfgId); return levelCfg.order; } } private static FightData _roleData = new FightData(); public static FightData roleData { get { return GetMyFightRoleData(); } } private static FightData _targetData = new FightData(); public static FightData targetData { get { return GetFightTargetData(); } } //获取玩家战斗数据 private static FightData GetMyFightRoleData() { _roleData.name = RoleDataManager.roleName; _roleData.scoreType = InstanceZonesDataManager.currentScoreType; _roleData.baseScore = RoleLevelCfgArray.Instance.GetCfg(RoleDataManager.lvl).baseScore; _roleData.leagueSkillScore = LeagueDataManager.Instance.GetAllSkillScore(_roleData.scoreType); _roleData.cardId = InstanceZonesDataManager.currentCardId; ;//卡牌id CardData cardData = CardDataManager.GetCardDataById(_roleData.cardId); _roleData.cardScore = _roleData.cardId <= 0 || cardData == null ? 0 : cardData.scores[_roleData.scoreType];//卡牌对应主题的属性分数 StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId); if (!string.IsNullOrEmpty(levelCfg.fightID)) { StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID); _roleData.tags = fightCfg.needTagsArr;////本次战斗要求的标签 } if (_roleData.cardId > 0) { _roleData.skillLvs = SkillDataManager.Instance.GetCardSkillLvs(_roleData.cardId); } _roleData.type = FightTargetType.PLAYER; _roleData.headId = RoleDataManager.headId; _roleData.itemList = MyDressUpHelper.dressUpObj.itemList; FightDataManager.Instance.SetItemScoreList(_roleData); ScoreSystemData.Instance.SetEquipScoresWithPartId(_roleData); return _roleData; } //获取副本机器人战斗数据 public static FightData GetFightTargetData() { StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId); StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID); _targetData.name = fightCfg.targetName; _targetData.scoreType = InstanceZonesDataManager.currentScoreType; //本次战斗的主题 _targetData.baseScore = fightCfg.targetBaseScore; _targetData.leagueSkillScore = 0; _targetData.cardId = fightCfg.targetCardId; _targetData.cardScore = fightCfg.targetCardScore; _targetData.tags = fightCfg.needTagsArr; List skillCfgs = PassivitySkillCfgArray.Instance.GetCfgsBycardId(_targetData.cardId); _targetData.skillLvs.Clear(); for (int i = 0; i < skillCfgs.Count; i++) { _targetData.skillLvs.Add(fightCfg.targetSkillLvs); } _targetData.itemScoreList.Clear(); for (int i = 0; i < fightCfg.targetPartsScoreArr.Length; i++) { _targetData.itemScoreList.Add(fightCfg.targetPartsScoreArr[i]); } _targetData.type = FightTargetType.ROBOT; _targetData.res = fightCfg.targetRes; return _targetData; } //副本通关状态,key为CalculateHelper.GenerateInstanceZonesLevelStateKey,值为通到关卡编号 private static Dictionary _passLevelDic = new Dictionary(); //关卡最高分数记录 private static Dictionary _highestScoreDic = new Dictionary(); //关卡星数记录 private static Dictionary _starDic = new Dictionary(); public static void InitScoreList(List ks, List vs) { usedRecommend = false; _highestScoreDic.Clear(); for (var i = 0; i < ks.Count; ++i) { _highestScoreDic.Add(ks[i], vs[i]); } } public static void InitStarList(List ks, List vs) { _starDic.Clear(); for (var i = 0; i < ks.Count; ++i) { _starDic.Add(ks[i], vs[i]); } } //检查更新最高分 public static void TryUpdateScore(int levelCfgId, int score) { _highestScoreDic.TryGetValue(levelCfgId, out var scoreHighest); if (score > scoreHighest) { _highestScoreDic[levelCfgId] = score; } } public static int GetScoreHighest(int levelID) { if (_highestScoreDic.ContainsKey(levelID)) { return _highestScoreDic[levelID]; } return 0; } //检查并更新关卡星数 public static void TryUpdateLevelStar(int levelCfgId, int star) { _starDic.TryGetValue(levelCfgId, out var OldStar); if (star > OldStar) { _starDic[levelCfgId] = star; } } public static int GetStarCountHistory(int levelCfgId) { _starDic.TryGetValue(levelCfgId, out var star); return star; } public static int GetChapterStarCount(int chapterID, int type, int subType) { var star = 0; foreach (var item in _starDic) { var levelCfg = StoryLevelCfgArray.Instance.GetCfg(item.Key); if (levelCfg.chapterId == chapterID && levelCfg.type == type && levelCfg.subType == subType) { star += item.Value; } } return star; } public static void InitLevelPass(List ks, List vs) { _passLevelDic.Clear(); for (var i = 0; i < ks.Count; ++i) { _passLevelDic[ks[i]] = vs[i]; } } /// /// 设置某关卡通过,参数为关卡配置id /// /// public static void TrySetLevelPass(int levelCfgId) { if (!CheckLevelPass(levelCfgId)) { var levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId); var key = CalculateHelper.GenerateInstanceZonesLevelStateKey(levelCfg.type, levelCfg.subType, levelCfg.chapterId); _passLevelDic[key] = levelCfgId; } } /// /// 获取副本通关关卡 /// /// /// /// public static int GetPassLevelCfgId(int type, int subType, int chapterId) { var key = CalculateHelper.GenerateInstanceZonesLevelStateKey(type, subType, chapterId); if (_passLevelDic.TryGetValue(key, out var value)) { return value; } return 0; } /// /// 获取通关关卡的编号 /// /// /// /// /// public static int GetPassLevelOrder(int type, int subType, int chapterId) { Debug.Log("zoya_zoya_ 222 _:" + type + " " + subType + " " + chapterId); var levelCfgId = GetPassLevelCfgId(type, subType, chapterId); Debug.Log("zoya_zoya_ 333 _:" + type + " " + subType + " " + chapterId); if (levelCfgId == 0) { Debug.Log("zoya_zoya_ 444 _:"); return 0; } Debug.Log("zoya_zoya_ 555 _:" + levelCfgId); var levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId); Debug.Log("zoya_zoya_ 666 _:" + levelCfgId); if (levelCfg != null) { Debug.Log("zoya_zoya_ 777 _:"); return levelCfg.order; } Debug.Log("zoya_zoya_ 888 _:"); return 0; } /// /// 检查某关卡是否通过,参数为关卡配置id /// /// /// public static bool CheckLevelPass(int levelCfgId) { var levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId); Debug.Log("zoya_zoya_ 000 _:" + levelCfg); if (levelCfg != null) { Debug.Log("zoya_zoya_ 111 _:" + levelCfg); var passLevelOrder = GetPassLevelOrder(levelCfg.type, levelCfg.subType, levelCfg.chapterId); return levelCfg.order <= passLevelOrder; } return false; } /// /// 检查某章是否通关 /// /// /// /// /// /// public static bool CheckChapterPass(int type, int subType, int chapterId, int levelCount) { var chapterCfg = StoryChapterCfgArray.Instance.GetCfg(chapterId); if (chapterCfg != null) { var passLevelOrder = InstanceZonesDataManager.GetPassLevelOrder(type, subType, chapterId); if (levelCount <= passLevelOrder) { return true; } } return false; } public static int GetResultStarCount(int score) { return CalculateHelper.GetStoryChapterStar(currentLevelCfgId, score); } public static bool GetFightResult(int score, out int npcScore) { npcScore = 0; bool equipedNeeded = MyDressUpHelper.CheckEquipedFightNeeded(); if (!equipedNeeded) { PromptController.Instance.ShowFloatTextPrompt("未穿必需物品"); return false;//没穿必需品 } StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(currentLevelCfgId); StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID); bool hasFightTarget = fightCfg.targetName != null && fightCfg.targetName.Length > 0; if (hasFightTarget) { npcScore = FightDataManager.Instance.npcTotalScore; if (score > npcScore) { return true;//分数低于对战对象 } } else { int starCount = GetResultStarCount(score); if (starCount > 0) { return true;//低于一星 } } return false; } public static void GetCanFightTime(int type, int subType, int levelCfgId, out int times, out string title) { var levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId); if (levelCfg.power == 0) { times = GameConst.MAX_COUNT_FIGHT_QUICKLY; } else { times = (int)Math.Floor((float)RoleDataManager.power / levelCfg.power);//体力次数 } times = Math.Min(GameConst.MAX_COUNT_FIGHT_QUICKLY, times); title = ""; if (type == ConstInstanceZonesType.Studio) { var studioCfg = StudioCfgArray.Instance.GetCfg(levelCfg.chapterId); var limitData = RoleLimitDataManager.GetLimitData(studioCfg.limit); times = Math.Min(times, limitData.TotalPlayMax - limitData.PlayTimes); } title = string.Format("挑战{0}次", NumberUtil.GetChiniseNumberText(times)); } public static void GetTotalProgress(out int count, out int totalCount) { List storyChapters = StoryChapterCfgArray.Instance.GetCfgsBysubType(ConstInstanceZonesSubType.Normal); totalCount = storyChapters.Count - 1; count = 0; for (int i = 1; i < storyChapters.Count; i++) { bool isPass = InstanceZonesDataManager.CheckChapterPass(storyChapters[i].type, storyChapters[i].subType, storyChapters[i].id, storyChapters[i].levelCount); if (isPass) { count++; } else { break; } } } } }