ActivityDataManager.cs 17 KB

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