TimeTracingDataManager.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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(levelID == 0)
  53. {
  54. return GetAllLevelRewardStatus(true);
  55. }
  56. else
  57. {
  58. if(!LevelRewardDic.ContainsKey(levelID))
  59. {
  60. return false;
  61. }
  62. foreach (var status in LevelRewardDic[levelID])
  63. {
  64. if (status.Value == ConstBonusStatus.CAN_GET)
  65. {
  66. return true;
  67. }
  68. }
  69. }
  70. return false;
  71. }
  72. //获取套装奖励状态
  73. public bool GetChapterRewardStatus(int levelID,int rewardID,int itemID)
  74. {
  75. //这里对已领取的id进行判断
  76. if (levelID != 0)
  77. {
  78. foreach (var item in ChapterRewardDic)
  79. {
  80. if(rewardID == item)
  81. {
  82. return false;
  83. }
  84. }
  85. }
  86. return true;
  87. }
  88. //获取对应id奖励状态
  89. public int GetChapterRewardIDStatus(int rewardID, int itemID)
  90. {
  91. long num = 0;
  92. ItemData itemdata;
  93. CompositebonusCfg comCfg = CompositebonusCfgArray.Instance.GetCfg(rewardID);
  94. if (BagDataManager.Instance.GetBagData().TryGetValue(itemID, out itemdata))
  95. {
  96. num = itemdata.num;
  97. }
  98. else
  99. {
  100. num = 0;
  101. }
  102. if(num < comCfg.count)
  103. {
  104. return ConstBonusStatus.CAN_NOT_GET;
  105. }
  106. //这里对已领取的id进行判断
  107. foreach (var item in ChapterRewardDic)
  108. {
  109. if (rewardID == item)
  110. {
  111. return ConstBonusStatus.GOT;
  112. }
  113. }
  114. return ConstBonusStatus.CAN_GET;
  115. }
  116. //获取所有奖励(只用于红点判断)
  117. public bool GetAllLevelRewardStatus(bool isLevel = true)
  118. {
  119. if (isLevel)
  120. {
  121. foreach (var item in LevelRewardDic)
  122. {
  123. Dictionary<int, int> rewardStatusDic = new Dictionary<int, int>(0);
  124. int key = item.Key;
  125. rewardStatusDic = item.Value;
  126. foreach (var id in rewardStatusDic)
  127. {
  128. if (id.Value == ConstBonusStatus.CAN_GET)
  129. {
  130. return true;
  131. }
  132. }
  133. }
  134. return false;
  135. }
  136. else
  137. {
  138. return false;
  139. }
  140. }
  141. //通过章节id判断所有奖励状态
  142. public bool GetChapterIDRewardStatus(int chapID)
  143. {
  144. List<CompositebonusCfg> comBonusList = CompositebonusCfgArray.Instance.GetCfgsBychapterId(chapID);
  145. foreach(CompositebonusCfg item in comBonusList)
  146. {
  147. if (GetChapterRewardIDStatus(item.id, item.paramsArr[0]) == 1)
  148. {
  149. return true;
  150. }
  151. }
  152. List<StoryLevelCfg> levelList = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(6, 2, chapID);
  153. foreach(StoryLevelCfg levelItem in levelList)
  154. {
  155. if(GetLevelRewardStatus(levelItem.id))
  156. {
  157. return true;
  158. }
  159. }
  160. return false;
  161. }
  162. public bool GetAllChapterReward()
  163. {
  164. foreach(int i in chapterIdList)
  165. {
  166. if(GetChapterIDRewardStatus(i))
  167. {
  168. return true;
  169. }
  170. }
  171. return false;
  172. }
  173. public string ChangeTime(long totalSeconds)
  174. {
  175. string timeStr = "";
  176. TimeSpan t = TimeSpan.FromSeconds(totalSeconds);
  177. if(t.Days != 0)
  178. {
  179. timeStr = string.Format("{0}天{1}时", t.Days, t.Hours);
  180. }
  181. else if(t.Hours != 0)
  182. {
  183. timeStr = string.Format("{0}时{1}分", t.Hours, t.Minutes);
  184. }
  185. else
  186. {
  187. timeStr = string.Format("{0}分{1}秒", t.Minutes, t.Seconds);
  188. }
  189. return timeStr;
  190. }
  191. }
  192. }