ActivityDataManager.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. using System.Collections.Generic;
  2. namespace GFGGame
  3. {
  4. public class ActivityDataManager : SingletonBase<ActivityDataManager>
  5. {
  6. public void Clear()
  7. {
  8. luckyBoxActBonusState.Clear();
  9. allPlayTimes = 0;
  10. lastActLuckyBoxId = 0;
  11. lastActLimitChargeId = 0;
  12. luckyActTsyBonusState.Clear();
  13. allTsyPlayTimes = 0;
  14. lastActLimitTsyId = 0;
  15. }
  16. /**********************************************************活动*************************************************/
  17. /// <summary>
  18. /// 获取指定类型活动当前开启的活动id
  19. /// </summary>
  20. /// <returns></returns>
  21. public int GetCurOpenActiveByType(int type)
  22. {
  23. List<ActivityOpenCfg> activityOpenCfgs = ActivityOpenCfgArray.Instance.GetCfgsBytype(type);
  24. for (int i = 0; i < activityOpenCfgs.Count; i++)
  25. {
  26. if (TimeUtil.IsBeforeCurTime(activityOpenCfgs[i].openTime) && TimeUtil.IsLaterCurTime(activityOpenCfgs[i].endTime))
  27. {
  28. return activityOpenCfgs[i].id;
  29. }
  30. }
  31. return 0;
  32. }
  33. /**********************************************************活动弹窗*************************************************/
  34. public bool todayActivityTips = true;
  35. public bool todayMonthlyCardTips = true;
  36. /**********************************************************限时累充*************************************************/
  37. public int lastActLimitChargeId = 0;
  38. private int _actLimitChargeId = 0;
  39. /// <summary>
  40. /// 当前限时累充活动id
  41. /// </summary>
  42. /// <value></value>
  43. public int actLimitChargeId { get { return _actLimitChargeId; } set { _actLimitChargeId = value; } }
  44. /**********************************************************限时抽奖活动*********************************************/
  45. public int lastActLuckyBoxId = 0;
  46. public int lastActLimitTsyId = 0;
  47. private int _actLuckyBoxId = 0;
  48. private int _actLuckyTsyId = 0;
  49. /// <summary>
  50. /// 当前抽奖活动id
  51. /// </summary>
  52. /// <value></value>
  53. public int actLuckyBoxId { get { return _actLuckyBoxId; } set { _actLuckyBoxId = value; } }
  54. /// <summary>
  55. /// 抽奖总次数
  56. /// </summary>
  57. /// <value></value>
  58. public long allPlayTimes { get; set; }
  59. /// <summary>
  60. /// 限时抽奖必掉次数
  61. /// </summary>
  62. /// <value></value>
  63. public int lastDrawCount { get; set; }
  64. /// <summary>
  65. /// </summary>
  66. /// <typeparam name="int">奖励key,这里对应抽奖次数</typeparam>
  67. /// <typeparam name="int">值由ConstBonusStatus定义</typeparam>
  68. /// <returns></returns>
  69. public Dictionary<int, int> luckyBoxActBonusState = new Dictionary<int, int>();
  70. /// <summary>
  71. /// 当前天市垣抽奖活动id
  72. /// </summary>
  73. /// <value></value>
  74. public int actLimitTsyId { get { return _actLuckyTsyId; } set { _actLuckyTsyId = value; } }
  75. /// <summary>
  76. /// 天市垣抽奖总次数
  77. /// </summary>
  78. /// <value></value>
  79. public long allTsyPlayTimes { get; set; }
  80. /// <summary>
  81. /// 限时天市垣抽奖必掉次数
  82. /// </summary>
  83. /// <value></value>
  84. public int lastTsyDrawCount { get; set; }
  85. /// <summary>
  86. /// </summary>
  87. /// <typeparam name="int">奖励key,这里对应天市垣抽奖次数</typeparam>
  88. /// <typeparam name="int">值由ConstBonusStatus定义</typeparam>
  89. /// <returns></returns>
  90. public Dictionary<int, int> luckyActTsyBonusState = new Dictionary<int, int>();
  91. public List<ActivityLuckybonusCfg> SortActivityLuckybonusCfg(List<ActivityLuckybonusCfg> list,int typeId)
  92. {
  93. list.Sort((ActivityLuckybonusCfg a, ActivityLuckybonusCfg b) =>
  94. {
  95. long allPlayTimes = 0;
  96. int stateA = 0;
  97. int stateB = 0;
  98. if (typeId == ConstLimitTimeActivityType.ActLimitLuckyBox) {
  99. allPlayTimes = ActivityDataManager.Instance.allPlayTimes;// GameGlobal.myNumericComponent.GetAsInt(NumericType.TotalRechargeScore);
  100. stateA = ActivityDataManager.Instance.luckyBoxActBonusState.ContainsKey(a.num) ? 1 : -1;
  101. stateB = ActivityDataManager.Instance.luckyBoxActBonusState.ContainsKey(b.num) ? 1 : -1;
  102. }
  103. else if(typeId == ConstLimitTimeActivityType.ActLimitTsy)
  104. {
  105. allPlayTimes = ActivityDataManager.Instance.allTsyPlayTimes;// GameGlobal.myNumericComponent.GetAsInt(NumericType.TotalRechargeScore);
  106. stateA = ActivityDataManager.Instance.luckyActTsyBonusState.ContainsKey(a.num) ? 1 : -1;
  107. stateB = ActivityDataManager.Instance.luckyActTsyBonusState.ContainsKey(b.num) ? 1 : -1;
  108. }
  109. else if (typeId == ConstLimitTimeActivityType.ActLimitStlyc)
  110. {
  111. allPlayTimes = ActivityDataManager.Instance.allTsyPlayTimes;// GameGlobal.myNumericComponent.GetAsInt(NumericType.TotalRechargeScore);
  112. stateA = ActivityDataManager.Instance.luckyActTsyBonusState.ContainsKey(a.num) ? 1 : -1;
  113. stateB = ActivityDataManager.Instance.luckyActTsyBonusState.ContainsKey(b.num) ? 1 : -1;
  114. }
  115. if (allPlayTimes >= a.num && allPlayTimes < b.num && stateA < 0) return -1;
  116. if (allPlayTimes >= b.num && allPlayTimes < a.num && stateB < 0) return 1;
  117. if (stateA >= 0 && stateB < 0) return 1;
  118. if (stateB >= 0 && stateA < 0) return -1;
  119. return a.num - b.num;
  120. });
  121. return list;
  122. }
  123. /**********************************************************每日登录*************************************************/
  124. private int _sevenDayLoginLoginId = 1;
  125. /// <summary>
  126. /// 七日登录 当日奖励id
  127. /// </summary>
  128. /// <value></value>
  129. public int sevenDayLoginLoginId
  130. {
  131. get { return _sevenDayLoginLoginId; }
  132. set { _sevenDayLoginLoginId = value; }
  133. }
  134. private int _sevenDayLoginBonusStatus = 0;
  135. /// <summary>
  136. /// 七日登录 当前奖励状态
  137. /// </summary>
  138. /// <value></value>
  139. public int sevenDayLoginBonusStatus
  140. {
  141. get { return _sevenDayLoginBonusStatus; }
  142. set { _sevenDayLoginBonusStatus = value; }
  143. }
  144. /******************************************************************************************************************/
  145. /**********************************************************每日登录修改*************************************************/
  146. public List<int> sevenDayLoginLoginIdList = new List<int>();
  147. /// <summary>
  148. /// 七日登录 当日奖励id
  149. /// </summary>
  150. /// <value></value>
  151. public List<int> sevenDayLoginBonusStatusList = new List<int>();
  152. /// <summary>
  153. /// 七日登录 当前奖励状态
  154. /// </summary>
  155. /// <value></value>
  156. ///
  157. public bool CanGetSevenDayBonus()
  158. {
  159. foreach(int a in sevenDayLoginBonusStatusList)
  160. {
  161. if (a == 1) return true;
  162. }
  163. return false;
  164. }
  165. public bool AllSevenDayBonusGot()
  166. {
  167. foreach (int a in sevenDayLoginBonusStatusList)
  168. {
  169. if (a != 2) return false;
  170. }
  171. return true;
  172. }
  173. /******************************************************************************************************************/
  174. private int _firstChargeBonusStatus = 0;
  175. /// <summary>
  176. /// 首冲奖励 当前奖励状态,ConstBonusStatus 0不可领,1可领,2已领
  177. /// </summary>
  178. /// <value></value>
  179. public int firstChargeBonusStatus
  180. {
  181. get
  182. {
  183. var status = GameGlobal.myNumericComponent.GetAsInt(ET.NumericType.FirstRechargeBonusStatus);
  184. if (status == ConstBonusStatus.GOT)
  185. {
  186. return ConstBonusStatus.GOT;
  187. }
  188. if (GameGlobal.myNumericComponent.GetAsLong(ET.NumericType.FirstRechargeTotal) > 0)
  189. {
  190. return ConstBonusStatus.CAN_GET;
  191. }
  192. return ConstBonusStatus.CAN_NOT_GET;
  193. }
  194. }
  195. }
  196. }