TimeTracingDataManager.cs 6.7 KB

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