ActivityDataManager.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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 int lastActLimitChargeId = 0;
  35. private int _actLimitChargeId = 0;
  36. /// <summary>
  37. /// 当前限时累充活动id
  38. /// </summary>
  39. /// <value></value>
  40. public int actLimitChargeId { get { return _actLimitChargeId; } set { _actLimitChargeId = value; } }
  41. /**********************************************************限时抽奖活动*********************************************/
  42. public int lastActLuckyBoxId = 0;
  43. public int lastActLimitTsyId = 0;
  44. private int _actLuckyBoxId = 0;
  45. private int _actLuckyTsyId = 0;
  46. /// <summary>
  47. /// 当前抽奖活动id
  48. /// </summary>
  49. /// <value></value>
  50. public int actLuckyBoxId { get { return _actLuckyBoxId; } set { _actLuckyBoxId = value; } }
  51. /// <summary>
  52. /// 抽奖总次数
  53. /// </summary>
  54. /// <value></value>
  55. public long allPlayTimes { get; set; }
  56. /// <summary>
  57. /// 限时抽奖必掉次数
  58. /// </summary>
  59. /// <value></value>
  60. public int lastDrawCount { get; set; }
  61. /// <summary>
  62. /// </summary>
  63. /// <typeparam name="int">奖励key,这里对应抽奖次数</typeparam>
  64. /// <typeparam name="int">值由ConstBonusStatus定义</typeparam>
  65. /// <returns></returns>
  66. public Dictionary<int, int> luckyBoxActBonusState = new Dictionary<int, int>();
  67. /// <summary>
  68. /// 当前天市垣抽奖活动id
  69. /// </summary>
  70. /// <value></value>
  71. public int actLimitTsyId { get { return _actLuckyTsyId; } set { _actLuckyTsyId = value; } }
  72. /// <summary>
  73. /// 天市垣抽奖总次数
  74. /// </summary>
  75. /// <value></value>
  76. public long allTsyPlayTimes { get; set; }
  77. /// <summary>
  78. /// 限时天市垣抽奖必掉次数
  79. /// </summary>
  80. /// <value></value>
  81. public int lastTsyDrawCount { get; set; }
  82. /// <summary>
  83. /// </summary>
  84. /// <typeparam name="int">奖励key,这里对应天市垣抽奖次数</typeparam>
  85. /// <typeparam name="int">值由ConstBonusStatus定义</typeparam>
  86. /// <returns></returns>
  87. public Dictionary<int, int> luckyActTsyBonusState = new Dictionary<int, int>();
  88. public List<ActivityLuckybonusCfg> SortActivityLuckybonusCfg(List<ActivityLuckybonusCfg> list,int typeId)
  89. {
  90. list.Sort((ActivityLuckybonusCfg a, ActivityLuckybonusCfg b) =>
  91. {
  92. long allPlayTimes = 0;
  93. int stateA = 0;
  94. int stateB = 0;
  95. if (typeId == ConstLimitTimeActivityType.ActLimitLuckyBox) {
  96. allPlayTimes = ActivityDataManager.Instance.allPlayTimes;// GameGlobal.myNumericComponent.GetAsInt(NumericType.TotalRechargeScore);
  97. stateA = ActivityDataManager.Instance.luckyBoxActBonusState.ContainsKey(a.num) ? 1 : -1;
  98. stateB = ActivityDataManager.Instance.luckyBoxActBonusState.ContainsKey(b.num) ? 1 : -1;
  99. }
  100. else if(typeId == ConstLimitTimeActivityType.ActLimitTsy)
  101. {
  102. allPlayTimes = ActivityDataManager.Instance.allTsyPlayTimes;// GameGlobal.myNumericComponent.GetAsInt(NumericType.TotalRechargeScore);
  103. stateA = ActivityDataManager.Instance.luckyActTsyBonusState.ContainsKey(a.num) ? 1 : -1;
  104. stateB = ActivityDataManager.Instance.luckyActTsyBonusState.ContainsKey(b.num) ? 1 : -1;
  105. }
  106. if (allPlayTimes >= a.num && allPlayTimes < b.num && stateA < 0) return -1;
  107. if (allPlayTimes >= b.num && allPlayTimes < a.num && stateB < 0) return 1;
  108. if (stateA >= 0 && stateB < 0) return 1;
  109. if (stateB >= 0 && stateA < 0) return -1;
  110. return a.num - b.num;
  111. });
  112. return list;
  113. }
  114. /**********************************************************每日登录*************************************************/
  115. private int _sevenDayLoginLoginId = 1;
  116. /// <summary>
  117. /// 七日登录 当日奖励id
  118. /// </summary>
  119. /// <value></value>
  120. public int sevenDayLoginLoginId
  121. {
  122. get { return _sevenDayLoginLoginId; }
  123. set { _sevenDayLoginLoginId = value; }
  124. }
  125. private int _sevenDayLoginBonusStatus = 0;
  126. /// <summary>
  127. /// 七日登录 当前奖励状态
  128. /// </summary>
  129. /// <value></value>
  130. public int sevenDayLoginBonusStatus
  131. {
  132. get { return _sevenDayLoginBonusStatus; }
  133. set { _sevenDayLoginBonusStatus = value; }
  134. }
  135. /******************************************************************************************************************/
  136. /**********************************************************每日登录修改*************************************************/
  137. public List<int> sevenDayLoginLoginIdList = new List<int>();
  138. /// <summary>
  139. /// 七日登录 当日奖励id
  140. /// </summary>
  141. /// <value></value>
  142. public List<int> sevenDayLoginBonusStatusList = new List<int>();
  143. /// <summary>
  144. /// 七日登录 当前奖励状态
  145. /// </summary>
  146. /// <value></value>
  147. ///
  148. public bool CanGetSevenDayBonus()
  149. {
  150. foreach(int a in sevenDayLoginBonusStatusList)
  151. {
  152. if (a == 1) return true;
  153. }
  154. return false;
  155. }
  156. public bool AllSevenDayBonusGot()
  157. {
  158. foreach (int a in sevenDayLoginBonusStatusList)
  159. {
  160. if (a != 2) return false;
  161. }
  162. return true;
  163. }
  164. /******************************************************************************************************************/
  165. private int _firstChargeBonusStatus = 0;
  166. /// <summary>
  167. /// 首冲奖励 当前奖励状态,ConstBonusStatus 0不可领,1可领,2已领
  168. /// </summary>
  169. /// <value></value>
  170. public int firstChargeBonusStatus
  171. {
  172. get
  173. {
  174. var status = GameGlobal.myNumericComponent.GetAsInt(ET.NumericType.FirstRechargeBonusStatus);
  175. if (status == ConstBonusStatus.GOT)
  176. {
  177. return ConstBonusStatus.GOT;
  178. }
  179. if (GameGlobal.myNumericComponent.GetAsLong(ET.NumericType.FirstRechargeTotal) > 0)
  180. {
  181. return ConstBonusStatus.CAN_GET;
  182. }
  183. return ConstBonusStatus.CAN_NOT_GET;
  184. }
  185. }
  186. }
  187. }