TimeTracingDataManager.cs 7.1 KB

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