ActivityDataManager.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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. limitStlycActBonusState.Clear();
  16. allLimitStlycTimes = 0;
  17. lastActLimitStlycId = 0;
  18. NewYearLoginInfoDic.Clear();
  19. }
  20. /**********************************************************活动*************************************************/
  21. /// <summary>
  22. /// 获取指定类型活动当前开启的活动id
  23. /// </summary>
  24. /// <returns></returns>
  25. public int GetCurOpenActiveByType(int type)
  26. {
  27. ActivityInfo info = ActivityGlobalDataManager.Instance.GetActivityInfoOneByType(type);
  28. return (info == null) ? 0 : info.ActivityId;
  29. }
  30. /**********************************************************活动弹窗*************************************************/
  31. public int todayActivityTips = 0;
  32. public int todayMonthlyCardTips = 0;
  33. /**********************************************************限时累充*************************************************/
  34. public int lastActLimitChargeId = 0;
  35. private int _actLimitChargeId = 0;
  36. /**********************************************************限时累充*************************************************/
  37. public bool IsGetNewPlayerReward = false;
  38. /// <summary>
  39. /// 当前限时累充活动id
  40. /// </summary>
  41. /// <value></value>
  42. public int actLimitChargeId { get { return _actLimitChargeId; } set { _actLimitChargeId = value; } }
  43. /**********************************************************限时抽奖活动*********************************************/
  44. public int lastActLuckyBoxId = 0;
  45. public int lastActLimitTsyId = 0;
  46. public int lastActLimitStlycId = 0;
  47. private int _actLuckyBoxId = 0;
  48. private int _actLuckyTsyId = 0;
  49. private int _actLimitStlycId = 0;
  50. /// <summary>
  51. /// 当前抽奖活动id
  52. /// </summary>
  53. /// <value></value>
  54. public int actLuckyBoxId { get { return _actLuckyBoxId; } set { _actLuckyBoxId = value; } }
  55. /// <summary>
  56. /// 抽奖总次数
  57. /// </summary>
  58. /// <value></value>
  59. public long allPlayTimes { get; set; }
  60. /// <summary>
  61. /// 限时抽奖必掉次数
  62. /// </summary>
  63. /// <value></value>
  64. public int lastDrawCount { get; set; }
  65. /// <summary>
  66. /// </summary>
  67. /// <typeparam name="int">奖励key,这里对应抽奖次数</typeparam>
  68. /// <typeparam name="int">值由ConstBonusStatus定义</typeparam>
  69. /// <returns></returns>
  70. public Dictionary<int, int> luckyBoxActBonusState = new Dictionary<int, int>();
  71. /// <summary>
  72. /// 当前天市垣抽奖活动id
  73. /// </summary>
  74. /// <value></value>
  75. public int actLimitTsyId { get { return _actLuckyTsyId; } set { _actLuckyTsyId = value; } }
  76. /// <summary>
  77. /// 天市垣抽奖总次数
  78. /// </summary>
  79. /// <value></value>
  80. public long allTsyPlayTimes { get; set; }
  81. /// <summary>
  82. /// 限时天市垣抽奖必掉次数
  83. /// </summary>
  84. /// <value></value>
  85. public int lastTsyDrawCount { get; set; }
  86. /// <summary>
  87. /// </summary>
  88. /// <typeparam name="int">奖励key,这里对应天市垣抽奖次数</typeparam>
  89. /// <typeparam name="int">值由ConstBonusStatus定义</typeparam>
  90. /// <returns></returns>
  91. public Dictionary<int, int> luckyActTsyBonusState = new Dictionary<int, int>();
  92. /// <summary>
  93. /// 当前隋唐洛阳城活动id
  94. /// </summary>
  95. /// <value></value>
  96. public int actLimitStlycId { get { return _actLimitStlycId; } set { _actLimitStlycId = value; } }
  97. /// <summary>
  98. /// 开服活动抽奖总次数
  99. /// </summary>
  100. /// <value></value>
  101. public long allLimitStlycTimes { get; set; }
  102. /// <summary>
  103. /// 开服抽奖必掉次数
  104. /// </summary>
  105. /// <value></value>
  106. public int lastStlycDrawCount { get; set; }
  107. /// <summary>
  108. /// </summary>
  109. /// <typeparam name="int">奖励key,这里对应抽奖次数</typeparam>
  110. /// <typeparam name="int">值由ConstBonusStatus定义</typeparam>
  111. /// <returns></returns>
  112. public Dictionary<int, int> limitStlycActBonusState = new Dictionary<int, int>();
  113. public List<ActivityLuckybonusCfg> SortActivityLuckybonusCfg(List<ActivityLuckybonusCfg> list,int typeId)
  114. {
  115. list.Sort((ActivityLuckybonusCfg a, ActivityLuckybonusCfg b) =>
  116. {
  117. long allPlayTimes = 0;
  118. int stateA = 0;
  119. int stateB = 0;
  120. if (typeId == ConstLimitTimeActivityType.ActLimitLuckyBox) {
  121. allPlayTimes = ActivityDataManager.Instance.allPlayTimes;// GameGlobal.myNumericComponent.GetAsInt(NumericType.TotalRechargeScore);
  122. stateA = ActivityDataManager.Instance.luckyBoxActBonusState.ContainsKey(a.num) ? 1 : -1;
  123. stateB = ActivityDataManager.Instance.luckyBoxActBonusState.ContainsKey(b.num) ? 1 : -1;
  124. }
  125. else if(typeId == ConstLimitTimeActivityType.ActLimitTsy)
  126. {
  127. allPlayTimes = ActivityDataManager.Instance.allTsyPlayTimes;// GameGlobal.myNumericComponent.GetAsInt(NumericType.TotalRechargeScore);
  128. stateA = ActivityDataManager.Instance.luckyActTsyBonusState.ContainsKey(a.num) ? 1 : -1;
  129. stateB = ActivityDataManager.Instance.luckyActTsyBonusState.ContainsKey(b.num) ? 1 : -1;
  130. }
  131. else if (typeId == ConstLimitTimeActivityType.ActLimitStlyc)
  132. {
  133. allPlayTimes = ActivityDataManager.Instance.allTsyPlayTimes;// GameGlobal.myNumericComponent.GetAsInt(NumericType.TotalRechargeScore);
  134. stateA = ActivityDataManager.Instance.luckyActTsyBonusState.ContainsKey(a.num) ? 1 : -1;
  135. stateB = ActivityDataManager.Instance.luckyActTsyBonusState.ContainsKey(b.num) ? 1 : -1;
  136. }
  137. if (allPlayTimes >= a.num && allPlayTimes < b.num && stateA < 0) return -1;
  138. if (allPlayTimes >= b.num && allPlayTimes < a.num && stateB < 0) return 1;
  139. if (stateA >= 0 && stateB < 0) return 1;
  140. if (stateB >= 0 && stateA < 0) return -1;
  141. return a.num - b.num;
  142. });
  143. return list;
  144. }
  145. /**********************************************************每日登录*************************************************/
  146. private int _sevenDayLoginLoginId = 1;
  147. /// <summary>
  148. /// 七日登录 当日奖励id
  149. /// </summary>
  150. /// <value></value>
  151. public int sevenDayLoginLoginId
  152. {
  153. get { return _sevenDayLoginLoginId; }
  154. set { _sevenDayLoginLoginId = value; }
  155. }
  156. private int _sevenDayLoginBonusStatus = 0;
  157. /// <summary>
  158. /// 七日登录 当前奖励状态
  159. /// </summary>
  160. /// <value></value>
  161. public int sevenDayLoginBonusStatus
  162. {
  163. get { return _sevenDayLoginBonusStatus; }
  164. set { _sevenDayLoginBonusStatus = value; }
  165. }
  166. /******************************************************************************************************************/
  167. /**********************************************************每日登录修改*************************************************/
  168. public List<int> sevenDayLoginLoginIdList = new List<int>();
  169. /// <summary>
  170. /// 七日登录 当日奖励id
  171. /// </summary>
  172. /// <value></value>
  173. public List<int> sevenDayLoginBonusStatusList = new List<int>();
  174. /// <summary>
  175. /// 七日登录 当前奖励状态
  176. /// </summary>
  177. /// <value></value>
  178. ///
  179. public bool CanGetSevenDayBonus()
  180. {
  181. foreach(int a in sevenDayLoginBonusStatusList)
  182. {
  183. if (a == 1) return true;
  184. }
  185. return false;
  186. }
  187. public bool AllSevenDayBonusGot()
  188. {
  189. foreach (int a in sevenDayLoginBonusStatusList)
  190. {
  191. if (a != 2) return false;
  192. }
  193. return true;
  194. }
  195. public bool HaveGetSevenDayBonus()
  196. {
  197. foreach (int a in sevenDayLoginBonusStatusList)
  198. {
  199. if (a == 0) return true;
  200. }
  201. return false;
  202. }
  203. //判断最后可领取的奖励索引
  204. public int NowSevenDayBonusDay(bool day = false)
  205. {
  206. if(AllSevenDayBonusGot())
  207. {
  208. return 8;
  209. }
  210. int a = 0;
  211. int flog = -1;
  212. if (day)
  213. {
  214. for (int j = 0; j < sevenDayLoginBonusStatusList.Count; j++)
  215. {
  216. a = sevenDayLoginBonusStatusList[j];
  217. if (a == 1)
  218. {
  219. flog = j;
  220. return flog;
  221. }
  222. }
  223. }
  224. else
  225. {
  226. for (int j = 0; j < sevenDayLoginBonusStatusList.Count; j++)
  227. {
  228. a = sevenDayLoginBonusStatusList[j];
  229. if (a == 2) flog = j;
  230. }
  231. }
  232. return flog;
  233. }
  234. /******************************************************************************************************************/
  235. private int _firstChargeBonusStatus = 0;
  236. /// <summary>
  237. /// 首冲奖励 当前奖励状态,ConstBonusStatus 0不可领,1可领,2已领
  238. /// </summary>
  239. /// <value></value>
  240. public int firstChargeBonusStatus
  241. {
  242. get
  243. {
  244. var status = GameGlobal.myNumericComponent.GetAsInt(ET.NumericType.FirstRechargeBonusStatus);
  245. if (status == ConstBonusStatus.GOT)
  246. {
  247. return ConstBonusStatus.GOT;
  248. }
  249. if (GameGlobal.myNumericComponent.GetAsLong(ET.NumericType.FirstRechargeTotal) > 0)
  250. {
  251. return ConstBonusStatus.CAN_GET;
  252. }
  253. return ConstBonusStatus.CAN_NOT_GET;
  254. }
  255. }
  256. //招财进宝活动
  257. public List<int> ActivityZCJBList = new List<int>();
  258. public bool CheckZCJBRed()
  259. {
  260. ItemData numItem;
  261. long num;
  262. if(BagDataManager.Instance.GetBagData().TryGetValue(3000023, out numItem))
  263. {
  264. num = numItem.num;
  265. }
  266. else
  267. {
  268. num = 0;
  269. }
  270. for (int i = 0; i < ActivityDressCfgArray.Instance.dataArray.Length - 1; i++)
  271. {
  272. if (i == ActivityDataManager.Instance.ActivityZCJBList.Count)
  273. {
  274. if (num >= ActivityDressCfgArray.Instance.dataArray[i].comsumeArr[0][1])
  275. {
  276. return true;
  277. }
  278. }
  279. }
  280. return false;
  281. }
  282. /**********************************************************每日登录修改*************************************************/
  283. /// <summary>
  284. /// 新年签到 登录第几天列表 奖励状态列表
  285. /// </summary>
  286. /// <value></value>
  287. public Dictionary<int,int> NewYearLoginInfoDic = new Dictionary<int, int>();
  288. public bool CanGetNewYearLoginRed()
  289. {
  290. foreach (var a in NewYearLoginInfoDic)
  291. {
  292. if (a.Value == 1) return true;
  293. }
  294. return false;
  295. }
  296. //返回直购时间内打折扣的套装id
  297. private int GetCheckDiscountSuitId()
  298. {
  299. return 0;
  300. }
  301. //珍珠赠礼是否弹窗
  302. public bool CheckPearRebateTips(int id)
  303. {
  304. bool flog = true;
  305. ActivityOpenCfg activityCfg = ActivityOpenCfgArray.Instance.GetCfg(id);
  306. for(int i =0;i< activityCfg.paramsArr.Length;i++)
  307. {
  308. ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(activityCfg.paramsArr[i]);
  309. int buyNum = ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id);
  310. if (shopCfg.maxBuyNum == 0 || buyNum < shopCfg.maxBuyNum)
  311. {
  312. flog = false;
  313. }
  314. }
  315. if(!flog)
  316. {
  317. if (ActivityGlobalDataManager.Instance.IsActivityOpen(id))
  318. {
  319. return true;
  320. }
  321. else
  322. {
  323. return false;
  324. }
  325. }
  326. else
  327. {
  328. return false;
  329. }
  330. }
  331. }
  332. }