ActivityDataManager.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. using ET;
  2. using System.Collections.Generic;
  3. namespace GFGGame
  4. {
  5. public class ActivityDataManager : SingletonBase<ActivityDataManager>
  6. {
  7. public void Clear()
  8. {
  9. luckyBoxActBonusState.Clear();
  10. allPlayTimes = 0;
  11. lastActLuckyBoxId = 0;
  12. lastActLimitChargeId = 0;
  13. luckyActTsyBonusState.Clear();
  14. allTsyPlayTimes = 0;
  15. lastActLimitTsyId = 0;
  16. limitStlycActBonusState.Clear();
  17. allLimitStlycTimes = 0;
  18. lastActLimitStlycId = 0;
  19. NewYearLoginInfoDic.Clear();
  20. }
  21. /**********************************************************活动*************************************************/
  22. /// <summary>
  23. /// 获取指定类型活动当前开启的活动id
  24. /// </summary>
  25. /// <returns></returns>
  26. public int GetCurOpenActiveByType(int type)
  27. {
  28. ActivityInfo info = ActivityGlobalDataManager.Instance.GetActivityInfoOneByType(type);
  29. return (info == null) ? 0 : info.ActivityId;
  30. }
  31. /**********************************************************活动弹窗*************************************************/
  32. public int todayActivityTips = 0;
  33. public int todayMonthlyCardTips = 0;
  34. /**********************************************************限时累充*************************************************/
  35. public int lastActLimitChargeId = 0;
  36. private int _actLimitChargeId = 0;
  37. /**********************************************************限时累充*************************************************/
  38. public bool IsGetNewPlayerReward = false;
  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. public int lastActLimitStlycId = 0;
  48. private int _actLuckyBoxId = 0;
  49. private int _actLuckyTsyId = 0;
  50. private int _actLimitStlycId = 0;
  51. /// <summary>
  52. /// 当前抽奖活动id
  53. /// </summary>
  54. /// <value></value>
  55. public int actLuckyBoxId { get { return _actLuckyBoxId; } set { _actLuckyBoxId = value; } }
  56. /// <summary>
  57. /// 抽奖总次数
  58. /// </summary>
  59. /// <value></value>
  60. public long allPlayTimes { get; set; }
  61. /// <summary>
  62. /// 限时抽奖必掉次数
  63. /// </summary>
  64. /// <value></value>
  65. public int lastDrawCount { get; set; }
  66. /// <summary>
  67. /// </summary>
  68. /// <typeparam name="int">奖励key,这里对应抽奖次数</typeparam>
  69. /// <typeparam name="int">值由ConstBonusStatus定义</typeparam>
  70. /// <returns></returns>
  71. public Dictionary<int, int> luckyBoxActBonusState = new Dictionary<int, int>();
  72. /// <summary>
  73. /// 当前天市垣抽奖活动id
  74. /// </summary>
  75. /// <value></value>
  76. public int actLimitTsyId { get { return _actLuckyTsyId; } set { _actLuckyTsyId = value; } }
  77. /// <summary>
  78. /// 天市垣抽奖总次数
  79. /// </summary>
  80. /// <value></value>
  81. public long allTsyPlayTimes { get; set; }
  82. /// <summary>
  83. /// 限时天市垣抽奖必掉次数
  84. /// </summary>
  85. /// <value></value>
  86. public int lastTsyDrawCount { get; set; }
  87. /// <summary>
  88. /// </summary>
  89. /// <typeparam name="int">奖励key,这里对应天市垣抽奖次数</typeparam>
  90. /// <typeparam name="int">值由ConstBonusStatus定义</typeparam>
  91. /// <returns></returns>
  92. public Dictionary<int, int> luckyActTsyBonusState = new Dictionary<int, int>();
  93. /// <summary>
  94. /// 当前隋唐洛阳城活动id
  95. /// </summary>
  96. /// <value></value>
  97. public int actLimitStlycId { get { return _actLimitStlycId; } set { _actLimitStlycId = value; } }
  98. /// <summary>
  99. /// 开服活动抽奖总次数
  100. /// </summary>
  101. /// <value></value>
  102. public long allLimitStlycTimes { get; set; }
  103. /// <summary>
  104. /// 开服抽奖必掉次数
  105. /// </summary>
  106. /// <value></value>
  107. public int lastStlycDrawCount { get; set; }
  108. /// <summary>
  109. /// </summary>
  110. /// <typeparam name="int">奖励key,这里对应抽奖次数</typeparam>
  111. /// <typeparam name="int">值由ConstBonusStatus定义</typeparam>
  112. /// <returns></returns>
  113. public Dictionary<int, int> limitStlycActBonusState = new Dictionary<int, int>();
  114. public List<ActivityLuckybonusCfg> SortActivityLuckybonusCfg(List<ActivityLuckybonusCfg> list,int typeId)
  115. {
  116. list.Sort((ActivityLuckybonusCfg a, ActivityLuckybonusCfg b) =>
  117. {
  118. long allPlayTimes = 0;
  119. int stateA = 0;
  120. int stateB = 0;
  121. if (typeId == ConstLimitTimeActivityType.ActLimitLuckyBox) {
  122. allPlayTimes = ActivityDataManager.Instance.allPlayTimes;// GameGlobal.myNumericComponent.GetAsInt(NumericType.TotalRechargeScore);
  123. stateA = ActivityDataManager.Instance.luckyBoxActBonusState.ContainsKey(a.num) ? 1 : -1;
  124. stateB = ActivityDataManager.Instance.luckyBoxActBonusState.ContainsKey(b.num) ? 1 : -1;
  125. }
  126. else if(typeId == ConstLimitTimeActivityType.ActLimitTsy)
  127. {
  128. allPlayTimes = ActivityDataManager.Instance.allTsyPlayTimes;// GameGlobal.myNumericComponent.GetAsInt(NumericType.TotalRechargeScore);
  129. stateA = ActivityDataManager.Instance.luckyActTsyBonusState.ContainsKey(a.num) ? 1 : -1;
  130. stateB = ActivityDataManager.Instance.luckyActTsyBonusState.ContainsKey(b.num) ? 1 : -1;
  131. }
  132. else if (typeId == ConstLimitTimeActivityType.ActLimitStlyc)
  133. {
  134. allPlayTimes = ActivityDataManager.Instance.allTsyPlayTimes;// GameGlobal.myNumericComponent.GetAsInt(NumericType.TotalRechargeScore);
  135. stateA = ActivityDataManager.Instance.luckyActTsyBonusState.ContainsKey(a.num) ? 1 : -1;
  136. stateB = ActivityDataManager.Instance.luckyActTsyBonusState.ContainsKey(b.num) ? 1 : -1;
  137. }
  138. if (allPlayTimes >= a.num && allPlayTimes < b.num && stateA < 0) return -1;
  139. if (allPlayTimes >= b.num && allPlayTimes < a.num && stateB < 0) return 1;
  140. if (stateA >= 0 && stateB < 0) return 1;
  141. if (stateB >= 0 && stateA < 0) return -1;
  142. return a.num - b.num;
  143. });
  144. return list;
  145. }
  146. /**********************************************************每日登录*************************************************/
  147. private int _sevenDayLoginLoginId = 1;
  148. /// <summary>
  149. /// 七日登录 当日奖励id
  150. /// </summary>
  151. /// <value></value>
  152. public int sevenDayLoginLoginId
  153. {
  154. get { return _sevenDayLoginLoginId; }
  155. set { _sevenDayLoginLoginId = value; }
  156. }
  157. private int _sevenDayLoginBonusStatus = 0;
  158. /// <summary>
  159. /// 七日登录 当前奖励状态
  160. /// </summary>
  161. /// <value></value>
  162. public int sevenDayLoginBonusStatus
  163. {
  164. get { return _sevenDayLoginBonusStatus; }
  165. set { _sevenDayLoginBonusStatus = value; }
  166. }
  167. /******************************************************************************************************************/
  168. /**********************************************************每日登录修改*************************************************/
  169. public List<int> sevenDayLoginLoginIdList = new List<int>();
  170. /// <summary>
  171. /// 七日登录 当日奖励id
  172. /// </summary>
  173. /// <value></value>
  174. public List<int> sevenDayLoginBonusStatusList = new List<int>();
  175. /// <summary>
  176. /// 七日登录 当前奖励状态
  177. /// </summary>
  178. /// <value></value>
  179. ///
  180. public bool CanGetSevenDayBonus()
  181. {
  182. foreach(int a in sevenDayLoginBonusStatusList)
  183. {
  184. if (a == 1) return true;
  185. }
  186. return false;
  187. }
  188. public bool AllSevenDayBonusGot()
  189. {
  190. foreach (int a in sevenDayLoginBonusStatusList)
  191. {
  192. if (a != 2) return false;
  193. }
  194. return true;
  195. }
  196. public bool HaveGetSevenDayBonus()
  197. {
  198. foreach (int a in sevenDayLoginBonusStatusList)
  199. {
  200. if (a == 0) return true;
  201. }
  202. return false;
  203. }
  204. //判断最后可领取的奖励索引
  205. public int NowSevenDayBonusDay(bool day = false)
  206. {
  207. if(AllSevenDayBonusGot())
  208. {
  209. return 8;
  210. }
  211. int a = 0;
  212. int flog = -1;
  213. if (day)
  214. {
  215. for (int j = 0; j < sevenDayLoginBonusStatusList.Count; j++)
  216. {
  217. a = sevenDayLoginBonusStatusList[j];
  218. if (a == 1)
  219. {
  220. flog = j;
  221. return flog;
  222. }
  223. }
  224. }
  225. else
  226. {
  227. for (int j = 0; j < sevenDayLoginBonusStatusList.Count; j++)
  228. {
  229. a = sevenDayLoginBonusStatusList[j];
  230. if (a == 2) flog = j;
  231. }
  232. }
  233. return flog;
  234. }
  235. /******************************************************************************************************************/
  236. private int _firstChargeBonusStatus = 0;
  237. /// <summary>
  238. /// 首冲奖励 当前奖励状态,ConstBonusStatus 0不可领,1可领,2已领
  239. /// </summary>
  240. /// <value></value>
  241. public int firstChargeBonusStatus
  242. {
  243. get
  244. {
  245. var status = GameGlobal.myNumericComponent.GetAsInt(ET.NumericType.FirstRechargeBonusStatus);
  246. if (status == ConstBonusStatus.GOT)
  247. {
  248. return ConstBonusStatus.GOT;
  249. }
  250. if (GameGlobal.myNumericComponent.GetAsLong(ET.NumericType.FirstRechargeTotal) > 0)
  251. {
  252. return ConstBonusStatus.CAN_GET;
  253. }
  254. return ConstBonusStatus.CAN_NOT_GET;
  255. }
  256. }
  257. //招财进宝活动
  258. public List<int> ActivityZCJBList = new List<int>();
  259. public int activityZCJBId = 61101;
  260. public bool CheckZCJBRed()
  261. {
  262. List<ActivityDressCfg> zcjbCfgList = new List<ActivityDressCfg>();
  263. int activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(17);
  264. zcjbCfgList = ActivityDressCfgArray.Instance.GetCfgsByactivityId(activityId);
  265. if (zcjbCfgList == null || zcjbCfgList.Count == 0)
  266. {
  267. return false;
  268. }
  269. ItemData numItem;
  270. long num;
  271. if(BagDataManager.Instance.GetBagData().TryGetValue(zcjbCfgList[0].comsumeArr[0][0], out numItem))
  272. {
  273. num = numItem.num;
  274. }
  275. else
  276. {
  277. num = 0;
  278. }
  279. for (int i = 0; i < zcjbCfgList.Count; i++)
  280. {
  281. if (i == ActivityDataManager.Instance.ActivityZCJBList.Count)
  282. {
  283. if (num >= zcjbCfgList[i].comsumeArr[0][1])
  284. {
  285. return true;
  286. }
  287. }
  288. }
  289. return false;
  290. }
  291. /**********************************************************每日登录修改*************************************************/
  292. /// <summary>
  293. /// 新年签到 登录第几天列表 奖励状态列表
  294. /// </summary>
  295. /// <value></value>
  296. public Dictionary<int,int> NewYearLoginInfoDic = new Dictionary<int, int>();
  297. public bool CanGetNewYearLoginRed()
  298. {
  299. //foreach (var a in NewYearLoginInfoDic)
  300. //{
  301. // if (a.Value == 1) return true;
  302. //}
  303. return false;
  304. }
  305. //返回直购时间内打折扣的套装id
  306. private int GetCheckDiscountSuitId()
  307. {
  308. return 0;
  309. }
  310. public Dictionary<long, long> TipsStatusDic = new Dictionary<long, long>();
  311. //珍珠赠礼是否弹窗
  312. public bool CheckPearRebateTips(int id)
  313. {
  314. bool flog = true;
  315. ActivityOpenCfg activityCfg = ActivityOpenCfgArray.Instance.GetCfg(id);
  316. for(int i =0;i< activityCfg.paramsArr.Length;i++)
  317. {
  318. ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(activityCfg.paramsArr[i]);
  319. int buyNum = ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id);
  320. if (shopCfg.maxBuyNum == 0 || buyNum < shopCfg.maxBuyNum)
  321. {
  322. flog = false;
  323. }
  324. }
  325. if(!flog)
  326. {
  327. if (ActivityGlobalDataManager.Instance.IsActivityOpen(id))
  328. {
  329. return true;
  330. }
  331. else
  332. {
  333. return false;
  334. }
  335. }
  336. else
  337. {
  338. return false;
  339. }
  340. }
  341. //根据创角时间判断活动是否开启
  342. public bool CheckActivityByRoleTime(int id)
  343. {
  344. return ActivityGlobalDataManager.Instance.IsActivityOpen(id);
  345. //ActivityOpenCfg item = ActivityOpenCfgArray.Instance.GetCfg(id);
  346. //if (item == null || item.CreatTime == 0)
  347. //{
  348. // return false;
  349. //}
  350. ////创角时间
  351. //long time = GameGlobal.zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRole().CreateTime;
  352. //long laterTime = (TimeHelper.ServerNow() - time) / 1000 / 60;
  353. //if (laterTime >= item.CreatTime && laterTime < (item.CreatTime + item.OpenLastTime))
  354. //{
  355. // return true;
  356. //}
  357. //return false;
  358. }
  359. public long GetActivityTime(int id)
  360. {
  361. ActivityOpenCfg _activityCfg = ActivityOpenCfgArray.Instance.GetCfg(id);
  362. int endTime = (_activityCfg.AfterCreatRoleTime * 24 * 60) + _activityCfg.OpenLastTime;
  363. endTime = endTime * 60;
  364. long time = GameGlobal.zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRole().CreateTime;
  365. long laterTime = (TimeHelper.ServerNow() - time)/1000;
  366. long curTime = (endTime - laterTime)* 1000;
  367. return curTime;
  368. }
  369. public bool isExtendTime(int day)
  370. {
  371. int id = ActivityDataManager.Instance.GetCurOpenActiveByType(17);
  372. ActivityOpenCfg activityCfg = ActivityOpenCfgArray.Instance.GetCfg(id);
  373. if (activityCfg != null)
  374. {
  375. long endTime = TimeUtil.DateTimeToTimestamp(activityCfg.endTime);
  376. long ExtendTime = (day * 24 * 60 * 60 * 1000);
  377. long currentTime = TimeHelper.ServerNow();
  378. if (currentTime > endTime)
  379. {
  380. if ((currentTime - endTime) <= ExtendTime)
  381. {
  382. return true;
  383. }
  384. }
  385. }
  386. return false;
  387. }
  388. /***************************转盘活动*******************************/
  389. public int TurnTableActivityType = 102;
  390. public int TurnTableTimes = 300;
  391. public int TipsDropId = 0;
  392. public int StartDropId = 40000002;
  393. //奖励状态
  394. public Dictionary<int, int> TurnRewardStateDic = new Dictionary<int, int>();
  395. //抽奖结果
  396. public Dictionary<int, List<ItemInfoProto>> threeTurnResult = new Dictionary<int, List<ItemInfoProto>>() {};
  397. public List<ItemInfoProto> TurnRewardList = new List<ItemInfoProto>();
  398. public List<ItemInfoProto> TurnSpecialRewardList = new List<ItemInfoProto>();
  399. public bool TurnTableRewardRed()
  400. {
  401. foreach(var item in TurnRewardStateDic)
  402. {
  403. if(item.Value == 1)
  404. {
  405. return true;
  406. }
  407. }
  408. return false;
  409. }
  410. /*****************************************************************/
  411. }
  412. }