using System; using System.Collections.Generic; using System.Linq; using cfg.GfgCfg; using ET; using GFGGame; namespace GFGGame { public class StudioDataManager : SingletonBase { private Dictionary _StudioInfoById = new Dictionary(); // public int TYPE_SELECT_INDEX = 0;//界面类型0无属性选择,1有属性选择 public int PROPERTY_SELECT_INDEX = 0; //属性类型 public string VIEW_NAME = ""; //界面名称 public int filingChapterId; //查阅建档当前副本Id public int npcFilingChapterId; //记录查阅建档工作室入口id,为与限时活动章节做区分。 private int luckyBoxFilingChapterId; //查阅建档这个章节是限时抽奖活动专属 public int PorcelainTheme = 1; //瓷器修复当天主题 public List FilingDatas { get { return CommonDataManager.Tables.TblStudioCfg.GetGroup1ByFunId(typeof(StudioFilingView).Name); } } public void Clear() { _StudioInfoById.Clear(); } public void RspStudioInfos(StudioData studioData) { if (!_StudioInfoById.ContainsKey(studioData.ChapterId)) { _StudioInfoById.Add(studioData.ChapterId, studioData); } _StudioInfoById[studioData.ChapterId] = studioData; } public void RspFilingScoreReward(int chapterId, int index) { _StudioInfoById[chapterId].RewardsStatus[index] = ConstBonusStatus.GOT; } public void NoticeFilingScoreBonusChanged(int chapterId, int chapterScore, List rewardsStatus) { _StudioInfoById[chapterId].ChapterScore = chapterScore; _StudioInfoById[chapterId].RewardsStatus = rewardsStatus; } public StudioData GetStudioDataById(int id) { if (_StudioInfoById.ContainsKey(id)) { return _StudioInfoById[id]; } else { StudioData studioData = new StudioData() { ChapterId = id }; RspStudioInfos(studioData); return studioData; } } public void IsCanFight(List storyLevelCfgs, int index, out bool canFight, out string content) { StoryLevelCfg storyLevelCfg = storyLevelCfgs[index]; bool isPass = InstanceZonesDataManager.CheckLevelPass(storyLevelCfg.NeedStoryLevelId); bool isRoleLv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= storyLevelCfg.NeedRoleLv; bool isLastPast = true; if (index > 0 && index < storyLevelCfgs.Count) { isLastPast = InstanceZonesDataManager.CheckLevelPass(storyLevelCfgs[index - 1].Id); } content = ""; if (!isRoleLv) content = string.Format("主角等级达到{0}级解锁", storyLevelCfg.NeedRoleLv); if (!isLastPast) content = "需通关前置关卡"; StoryLevelCfg needStoryLevelCfg = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(storyLevelCfg.NeedStoryLevelId); if (!isPass) content = string.Format("完成主线{0}-{1}解锁", needStoryLevelCfg.ChapterId, needStoryLevelCfg.Order); canFight = isPass && isRoleLv && isLastPast; } public void IsCanFight(int levelId, out bool canFight, out string content) { StoryLevelCfg storyLevelCfg = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(levelId); StudioCfg cfg = CommonDataManager.Tables.TblStudioCfg.GetOrDefault(storyLevelCfg.ChapterId); int needStoryLevelId = 0; if (cfg.FunId == typeof(StudioFilingView).Name) { needStoryLevelId = cfg.StoryLevelId; } else { needStoryLevelId = storyLevelCfg.NeedStoryLevelId; } bool isPass; if (needStoryLevelId == 0) { isPass = true; } else { isPass = InstanceZonesDataManager.CheckLevelPass(needStoryLevelId); } StoryLevelCfg needStoryLevelCfg = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(needStoryLevelId); if (!isPass && needStoryLevelCfg != null) content = string.Format("完成主线{0}-{1}解锁", needStoryLevelCfg.ChapterId, needStoryLevelCfg.Order); bool isRoleLv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= storyLevelCfg.NeedRoleLv; if (!isRoleLv) content = string.Format("主角等级达到{0}级解锁", storyLevelCfg.NeedRoleLv); bool isLastPast = true; int lastIndex = storyLevelCfg.Order - 1 - 1; List storyLevelCfgs = CommonDataManager.Tables.TblStoryLevelCfg.DataList.Where(a => a.Type == storyLevelCfg.Type && a.SubType == storyLevelCfg.SubType && a.ChapterId == storyLevelCfg.ChapterId).ToList(); if (lastIndex >= 0) { isLastPast = InstanceZonesDataManager.CheckLevelPass(storyLevelCfgs[lastIndex].Id); } if (!isLastPast) content = string.Format("需通关{0}", storyLevelCfgs[lastIndex].Name); content = ""; canFight = isPass && isRoleLv && isLastPast; } public void OnFinishStudioStoryLevel(int levelCfgId, bool firstPass, bool success) { ViewManager.Show(VIEW_NAME, PROPERTY_SELECT_INDEX); } public void OnFinishZCJBStoryLevel(int levelCfgId, bool firstPass, bool success) { ViewManager.Show(new object[] { ActivityDataManager.Instance.activityZCJBId, 2 }); } public void OnFinishTimeTracingLevel(int levelCfgId, bool firstPass, bool success) { ViewManager.Show(new object[] { TimeTracingDataManager._currentChapterId, TimeTracingDataManager.SuitID }); } public void OnFinishFilingStoryLevel(int levelCfgId, bool firstPass, bool success) { ViewManager.Show(MainStoryDataManager.currentChapterCfgId, true); } private float GetAdditionBySuitId(int suitId) { float addition = 0; SuitCfg cfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(suitId); for (int i = 0; i < cfg.Parts.Count; i++) { if (ItemDataManager.GetItemNum(cfg.Parts[i]) > 0) { ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(cfg.Parts[i]); addition += itemCfg.Addition; } } return addition; } private float GetAdditionBySuitIds(List suitIds) { float addition = 0; for (int i = 0; i < suitIds.Count; i++) { addition += GetAdditionBySuitId(suitIds[i]); } return addition; } public float GetAddition(int type = 0) { float addition; // 开服活动 if (type == ConstInstanceZonesType.PureFight) { ActivityFightCfg fightCfg = CommonDataManager.Tables.TblActivityFightCfg.GetOrDefault(filingChapterId); addition = GetAdditionBySuitIds(fightCfg.ActivitySuitId); } else { StudioCfg filingCfg = CommonDataManager.Tables.TblStudioCfg.GetOrDefault(filingChapterId); // 活动 if (IsluckyBoxFilingChapter()) addition = GetAdditionBySuitIds(filingCfg.ActivitySuitId); // 查阅建档 else addition = GetAdditionBySuitId(filingCfg.SuitId); } return addition; } public bool GetFilingRewardState(int chapterId) { StudioData studioData = GetStudioDataById(chapterId); if (studioData.RewardsStatus.Count == 0) return false; for (int i = 0; i < studioData.RewardsStatus.Count; i++) { if (studioData.RewardsStatus[i] == ConstBonusStatus.CAN_GET) { return true; } else if (studioData.RewardsStatus[i] == ConstBonusStatus.CAN_NOT_GET) { return false; //奖励按顺序领取,第一个不可领则没有可领奖励 } } return false; } public int GetFilingRewardStateByIndex(int chapterId, int index) { StudioData studioData = GetStudioDataById(chapterId); return studioData.RewardsStatus.Count > index ? studioData.RewardsStatus[index] : 0; } public List GetFilingRewardList(int id) { StudioData studioData = GetStudioDataById(id); return studioData.RewardsStatus; } public bool IsluckyBoxFilingChapter() { return filingChapterId == GetLuckyBoxActivityID(); } public int GetLuckyBoxActivityID() { if (luckyBoxFilingChapterId == 0) { int activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(ConstLimitTimeActivityType.ActLimitLuckyBox); ActivityOpenCfg activityCfg = CommonDataManager.Tables.TblActivityOpenCfg.GetOrDefault(activityId); luckyBoxFilingChapterId = (activityCfg != null && activityCfg.Params3 != null) ? activityCfg.Params3[0] : 0; } return luckyBoxFilingChapterId; } public bool GetStudioFilingRewardRed() { var rewardList = StudioDataManager.Instance.GetFilingRewardList(StudioDataManager.Instance.filingChapterId); for (int i = 0; i < rewardList.Count; i++) { if (i < rewardList.Count && rewardList[i] == ConstBonusStatus.CAN_GET) { return true; } } return false; } } }