TimeTracingDataManager.cs 7.0 KB

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