ActivityDataManager.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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 bool CheckZCJBRed()
  260. {
  261. ItemData numItem;
  262. long num;
  263. if(BagDataManager.Instance.GetBagData().TryGetValue(3000023, out numItem))
  264. {
  265. num = numItem.num;
  266. }
  267. else
  268. {
  269. num = 0;
  270. }
  271. for (int i = 0; i < ActivityDressCfgArray.Instance.dataArray.Length - 1; i++)
  272. {
  273. if (i == ActivityDataManager.Instance.ActivityZCJBList.Count)
  274. {
  275. if (num >= ActivityDressCfgArray.Instance.dataArray[i].comsumeArr[0][1])
  276. {
  277. return true;
  278. }
  279. }
  280. }
  281. return false;
  282. }
  283. /**********************************************************每日登录修改*************************************************/
  284. /// <summary>
  285. /// 新年签到 登录第几天列表 奖励状态列表
  286. /// </summary>
  287. /// <value></value>
  288. public Dictionary<int,int> NewYearLoginInfoDic = new Dictionary<int, int>();
  289. public bool CanGetNewYearLoginRed()
  290. {
  291. foreach (var a in NewYearLoginInfoDic)
  292. {
  293. if (a.Value == 1) return true;
  294. }
  295. return false;
  296. }
  297. //返回直购时间内打折扣的套装id
  298. private int GetCheckDiscountSuitId()
  299. {
  300. return 0;
  301. }
  302. public Dictionary<long, long> TipsStatusDic = new Dictionary<long, long>();
  303. //珍珠赠礼是否弹窗
  304. public bool CheckPearRebateTips(int id)
  305. {
  306. bool flog = true;
  307. ActivityOpenCfg activityCfg = ActivityOpenCfgArray.Instance.GetCfg(id);
  308. for(int i =0;i< activityCfg.paramsArr.Length;i++)
  309. {
  310. ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(activityCfg.paramsArr[i]);
  311. int buyNum = ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id);
  312. if (shopCfg.maxBuyNum == 0 || buyNum < shopCfg.maxBuyNum)
  313. {
  314. flog = false;
  315. }
  316. }
  317. if(!flog)
  318. {
  319. if (ActivityGlobalDataManager.Instance.IsActivityOpen(id))
  320. {
  321. return true;
  322. }
  323. else
  324. {
  325. return false;
  326. }
  327. }
  328. else
  329. {
  330. return false;
  331. }
  332. }
  333. //根据创角时间判断活动是否开启
  334. public bool CheckActivityByRoleTime(int id)
  335. {
  336. return ActivityGlobalDataManager.Instance.IsActivityOpen(id);
  337. //ActivityOpenCfg item = ActivityOpenCfgArray.Instance.GetCfg(id);
  338. //if (item == null || item.CreatTime == 0)
  339. //{
  340. // return false;
  341. //}
  342. ////创角时间
  343. //long time = GameGlobal.zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRole().CreateTime;
  344. //long laterTime = (TimeHelper.ServerNow() - time) / 1000 / 60;
  345. //if (laterTime >= item.CreatTime && laterTime < (item.CreatTime + item.OpenLastTime))
  346. //{
  347. // return true;
  348. //}
  349. //return false;
  350. }
  351. public long GetActivityTime(int id)
  352. {
  353. ActivityOpenCfg _activityCfg = ActivityOpenCfgArray.Instance.GetCfg(id);
  354. int endTime = (_activityCfg.AfterCreatRoleTime * 24 * 60) + _activityCfg.OpenLastTime;
  355. endTime = endTime * 60;
  356. long time = GameGlobal.zoneScene.GetComponent<RoleInfosComponent>().GetCurrentRole().CreateTime;
  357. long laterTime = (TimeHelper.ServerNow() - time)/1000;
  358. long curTime = (endTime - laterTime)* 1000;
  359. return curTime;
  360. }
  361. }
  362. }