using System; using System.Collections.Generic; using System.Linq; using cfg.GfgCfg; using UnityEngine; using ET; namespace GFGGame { public class TimeTracingDataManager : SingletonBase { public List IdList = new List() { 5017, 5018 }; public List chapterIdList = new List(); //时光回溯,关卡编号 public static int _currentChapterId = 62001; //时光回溯,合成套装副本当前展示套装 public static int SuitID = 201030; //时光回溯刷新时间 public static long RefreshTime = 0; //章节积分奖励列表 public static List ChapterRewardDic = new List(); //关卡评分奖励列表 public static Dictionary> LevelRewardDic = new Dictionary>(); //关卡信息 public static Dictionary> _LevelMaxInfoDic = new Dictionary>(); public Dictionary mySuitRankInfo = new Dictionary() { { 0, new SuitCollectRankProto() }, { 1, new SuitCollectRankProto() }, }; public Dictionary myLevelRankInfo = new Dictionary() { { 0, new LevelRankProto() }, { 1, new LevelRankProto() }, }; //套装排行榜数据 public Dictionary> SuitRankDatasDic = new Dictionary>() { { 0, new List() }, { 1, new List() }, }; //关卡排行榜数据 public Dictionary> LevelRankDatasDic = new Dictionary>() { { 0, new List() }, { 1, new List() }, }; public void InitRewardDic() { chapterIdList.Clear(); if (chapterIdList.Count > 0) { return; } foreach (int i in IdList) { chapterIdList.Add(CommonDataManager.Tables.TblActivityOpenCfg.GetOrDefault(i).Params3[0]); } } //获取关卡奖励状态 public bool GetLevelRewardStatus(int levelID = 0) { if (ActivityDataManager.Instance.GetCurOpenActiveByType(21) == 0) { return false; } if (levelID == 0) { return GetAllLevelRewardStatus(true); } else { if (!LevelRewardDic.ContainsKey(levelID)) { return false; } foreach (var status in LevelRewardDic[levelID]) { if (status.Value == ConstBonusStatus.CAN_GET) { return true; } } } return false; } //获取套装奖励状态 public bool GetChapterRewardStatus(int levelID, int rewardID, int itemID) { //这里对已领取的id进行判断 if (levelID != 0) { foreach (var item in ChapterRewardDic) { if (rewardID == item) { return false; } } } return true; } //获取对应id奖励状态 public int GetChapterRewardIDStatus(int rewardID, int itemID) { long num = 0; ItemData itemdata; CompositebonusCfg comCfg = CommonDataManager.Tables.TblCompositebonusCfg.GetOrDefault(rewardID); if (BagDataManager.Instance.GetBagData().TryGetValue(itemID, out itemdata)) { num = itemdata.num; } else { num = 0; } if (num < comCfg.Count) { return ConstBonusStatus.CAN_NOT_GET; } //这里对已领取的id进行判断 foreach (var item in ChapterRewardDic) { if (rewardID == item) { return ConstBonusStatus.GOT; } } return ConstBonusStatus.CAN_GET; } //获取所有奖励(只用于红点判断) public bool GetAllLevelRewardStatus(bool isLevel = true) { if (isLevel) { foreach (var item in LevelRewardDic) { Dictionary rewardStatusDic = new Dictionary(0); int key = item.Key; rewardStatusDic = item.Value; foreach (var id in rewardStatusDic) { if (id.Value == ConstBonusStatus.CAN_GET) { return true; } } } return false; } else { return false; } } //通过章节id判断所有奖励状态 public bool GetChapterIDRewardStatus(int chapID) { List comBonusList = CommonDataManager.Tables.TblCompositebonusCfg.DataList.Where(a => a.ChapterId == chapID).ToList(); foreach (CompositebonusCfg item in comBonusList) { if (GetChapterRewardIDStatus(item.Id, item.Params1[0]) == 1) { return true; } } List levelList = CommonDataManager.Tables.TblStoryLevelCfg.DataList.Where(a => a.Type == 6 && a.SubType == 2 && a.ChapterId == chapID).ToList(); foreach (StoryLevelCfg levelItem in levelList) { if (GetLevelRewardStatus(levelItem.Id)) { return true; } } return false; } public bool GetAllChapterReward() { if (ActivityDataManager.Instance.GetCurOpenActiveByType(21) == 0) { return false; } foreach (int i in chapterIdList) { if (GetChapterIDRewardStatus(i)) { return true; } } return false; } public string ChangeTime(long totalSeconds) { string timeStr = ""; TimeSpan t = TimeSpan.FromSeconds(totalSeconds); if (t.Days != 0) { timeStr = string.Format("{0}天{1}时", t.Days, t.Hours); } else if (t.Hours != 0) { timeStr = string.Format("{0}时{1}分", t.Hours, t.Minutes); } else { timeStr = string.Format("{0}分{1}秒", t.Minutes, t.Seconds); } return timeStr; } } }