ActivityDataManager.cs 18 KB

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