TimeTracingDataManager.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using cfg.GfgCfg;
  5. using UnityEngine;
  6. using ET;
  7. namespace GFGGame
  8. {
  9. public class TimeTracingDataManager : SingletonBase<TimeTracingDataManager>
  10. {
  11. public List<int> IdList = new List<int>() { 5017, 5018 };
  12. public List<int> chapterIdList = new List<int>();
  13. //时光回溯,关卡编号
  14. public static int _currentChapterId = 62001;
  15. //时光回溯,合成套装副本当前展示套装
  16. public static int SuitID = 201030;
  17. //时光回溯刷新时间
  18. public static long RefreshTime = 0;
  19. //章节积分奖励列表
  20. public static List<int> ChapterRewardDic = new List<int>();
  21. //关卡评分奖励列表
  22. public static Dictionary<int, Dictionary<int, int>>
  23. LevelRewardDic = new Dictionary<int, Dictionary<int, int>>();
  24. //关卡信息
  25. public static Dictionary<int, Dictionary<int, LevelRoleInfoProto>> _LevelMaxInfoDic =
  26. new Dictionary<int, Dictionary<int, LevelRoleInfoProto>>();
  27. public Dictionary<int, SuitCollectRankProto> mySuitRankInfo = new Dictionary<int, SuitCollectRankProto>()
  28. {
  29. { 0, new SuitCollectRankProto() },
  30. { 1, new SuitCollectRankProto() },
  31. };
  32. public Dictionary<int, LevelRankProto> myLevelRankInfo = new Dictionary<int, LevelRankProto>()
  33. {
  34. { 0, new LevelRankProto() },
  35. { 1, new LevelRankProto() },
  36. };
  37. //套装排行榜数据
  38. public Dictionary<int, List<SuitCollectRankProto>> SuitRankDatasDic =
  39. new Dictionary<int, List<SuitCollectRankProto>>()
  40. {
  41. { 0, new List<SuitCollectRankProto>() },
  42. { 1, new List<SuitCollectRankProto>() },
  43. };
  44. //关卡排行榜数据
  45. public Dictionary<int, List<LevelRankProto>> LevelRankDatasDic = new Dictionary<int, List<LevelRankProto>>()
  46. {
  47. { 0, new List<LevelRankProto>() },
  48. { 1, new List<LevelRankProto>() },
  49. };
  50. public void InitRewardDic()
  51. {
  52. chapterIdList.Clear();
  53. if (chapterIdList.Count > 0)
  54. {
  55. return;
  56. }
  57. foreach (int i in IdList)
  58. {
  59. chapterIdList.Add(CommonDataManager.Tables.TblActivityOpenCfg.GetOrDefault(i).Params3[0]);
  60. }
  61. }
  62. //获取关卡奖励状态
  63. public bool GetLevelRewardStatus(int levelID = 0)
  64. {
  65. if (ActivityDataManager.Instance.GetCurOpenActiveByType(21) == 0)
  66. {
  67. return false;
  68. }
  69. if (levelID == 0)
  70. {
  71. return GetAllLevelRewardStatus(true);
  72. }
  73. else
  74. {
  75. if (!LevelRewardDic.ContainsKey(levelID))
  76. {
  77. return false;
  78. }
  79. foreach (var status in LevelRewardDic[levelID])
  80. {
  81. if (status.Value == ConstBonusStatus.CAN_GET)
  82. {
  83. return true;
  84. }
  85. }
  86. }
  87. return false;
  88. }
  89. //获取套装奖励状态
  90. public bool GetChapterRewardStatus(int levelID, int rewardID, int itemID)
  91. {
  92. //这里对已领取的id进行判断
  93. if (levelID != 0)
  94. {
  95. foreach (var item in ChapterRewardDic)
  96. {
  97. if (rewardID == item)
  98. {
  99. return false;
  100. }
  101. }
  102. }
  103. return true;
  104. }
  105. //获取对应id奖励状态
  106. public int GetChapterRewardIDStatus(int rewardID, int itemID)
  107. {
  108. long num = 0;
  109. ItemData itemdata;
  110. CompositebonusCfg comCfg = CommonDataManager.Tables.TblCompositebonusCfg.GetOrDefault(rewardID);
  111. if (BagDataManager.Instance.GetBagData().TryGetValue(itemID, out itemdata))
  112. {
  113. num = itemdata.num;
  114. }
  115. else
  116. {
  117. num = 0;
  118. }
  119. if (num < comCfg.Count)
  120. {
  121. return ConstBonusStatus.CAN_NOT_GET;
  122. }
  123. //这里对已领取的id进行判断
  124. foreach (var item in ChapterRewardDic)
  125. {
  126. if (rewardID == item)
  127. {
  128. return ConstBonusStatus.GOT;
  129. }
  130. }
  131. return ConstBonusStatus.CAN_GET;
  132. }
  133. //获取所有奖励(只用于红点判断)
  134. public bool GetAllLevelRewardStatus(bool isLevel = true)
  135. {
  136. if (isLevel)
  137. {
  138. foreach (var item in LevelRewardDic)
  139. {
  140. Dictionary<int, int> rewardStatusDic = new Dictionary<int, int>(0);
  141. int key = item.Key;
  142. rewardStatusDic = item.Value;
  143. foreach (var id in rewardStatusDic)
  144. {
  145. if (id.Value == ConstBonusStatus.CAN_GET)
  146. {
  147. return true;
  148. }
  149. }
  150. }
  151. return false;
  152. }
  153. else
  154. {
  155. return false;
  156. }
  157. }
  158. //通过章节id判断所有奖励状态
  159. public bool GetChapterIDRewardStatus(int chapID)
  160. {
  161. List<CompositebonusCfg> comBonusList =
  162. CommonDataManager.Tables.TblCompositebonusCfg.DataList.Where(a => a.ChapterId == chapID).ToList();
  163. foreach (CompositebonusCfg item in comBonusList)
  164. {
  165. if (GetChapterRewardIDStatus(item.Id, item.Params1[0]) == 1)
  166. {
  167. return true;
  168. }
  169. }
  170. List<StoryLevelCfg> levelList = CommonDataManager.Tables.TblStoryLevelCfg.DataList.Where(a =>
  171. a.Type == 6 && a.SubType == 2 &&
  172. a.ChapterId == chapID).ToList();
  173. foreach (StoryLevelCfg levelItem in levelList)
  174. {
  175. if (GetLevelRewardStatus(levelItem.Id))
  176. {
  177. return true;
  178. }
  179. }
  180. return false;
  181. }
  182. public bool GetAllChapterReward()
  183. {
  184. if (ActivityDataManager.Instance.GetCurOpenActiveByType(21) == 0)
  185. {
  186. return false;
  187. }
  188. foreach (int i in chapterIdList)
  189. {
  190. if (GetChapterIDRewardStatus(i))
  191. {
  192. return true;
  193. }
  194. }
  195. return false;
  196. }
  197. public string ChangeTime(long totalSeconds)
  198. {
  199. string timeStr = "";
  200. TimeSpan t = TimeSpan.FromSeconds(totalSeconds);
  201. if (t.Days != 0)
  202. {
  203. timeStr = string.Format("{0}天{1}时", t.Days, t.Hours);
  204. }
  205. else if (t.Hours != 0)
  206. {
  207. timeStr = string.Format("{0}时{1}分", t.Hours, t.Minutes);
  208. }
  209. else
  210. {
  211. timeStr = string.Format("{0}分{1}秒", t.Minutes, t.Seconds);
  212. }
  213. return timeStr;
  214. }
  215. }
  216. }