ActivitySProxy.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. using System;
  2. using System.Collections.Generic;
  3. using ET;
  4. using GFGGame;
  5. using Hutool;
  6. namespace GFGGame
  7. {
  8. public class NoticeTimeLimitLuckyBoxDropOutCount : AMHandler<S2C_NoticeTimeLimitLuckyBoxDropOutCount>
  9. {
  10. protected override async ETTask Run(Session session, S2C_NoticeTimeLimitLuckyBoxDropOutCount message)
  11. {
  12. var activityOpenCfg = ActivityOpenCfgArray.Instance.GetCfg(message.ActivityId);
  13. if (activityOpenCfg.type == ConstLimitTimeActivityType.ActLimitLuckyBox)
  14. {
  15. ActivityDataManager.Instance.allPlayTimes = message.AllPlayTimes;
  16. ActivityDataManager.Instance.lastDrawCount = message.Count;
  17. }
  18. else if (activityOpenCfg.type == ConstLimitTimeActivityType.ActLimitTsy)
  19. {
  20. ActivityDataManager.Instance.allTsyPlayTimes = message.AllPlayTimes;
  21. ActivityDataManager.Instance.lastTsyDrawCount = message.Count;
  22. }
  23. else if (activityOpenCfg.type == ConstLimitTimeActivityType.ActLimitStlyc)
  24. {
  25. ActivityDataManager.Instance.allLimitStlycTimes = message.AllPlayTimes;
  26. ActivityDataManager.Instance.lastStlycDrawCount = message.Count;
  27. }
  28. EventAgent.DispatchEvent(ConstMessage.ACTIVITY_LUCKY_BOX);
  29. await ETTask.CompletedTask;
  30. }
  31. }
  32. /**********************************************************七日登录*************************************************/
  33. public static class ActivitySProxy
  34. {
  35. public static async ETTask<bool> ReqSevenDayLoginInfos()
  36. {
  37. M2C_GetDailySignInBonusInfoList response = null;
  38. response = (M2C_GetDailySignInBonusInfoList)await MessageHelper.SendToServer(new C2M_GetDailySignInBonusInfoList());
  39. if (response != null)
  40. {
  41. if (response.Error == ErrorCode.ERR_Success)
  42. {
  43. ActivityDataManager.Instance.sevenDayLoginLoginIdList = response.KsBonusId;
  44. ActivityDataManager.Instance.sevenDayLoginBonusStatusList = response.VsBonusStatus;
  45. return true;
  46. }
  47. }
  48. return false;
  49. }
  50. public static async ETTask<bool> ReqSevenDayLoginRewards(int id)
  51. {
  52. M2C_GetDailySinInBonus response = null;
  53. response = (M2C_GetDailySinInBonus)await MessageHelper.SendToServer(new C2M_GetDailySinInBonus() { BonusId = id });
  54. if (response != null)
  55. {
  56. if (response.Error == ErrorCode.ERR_Success)
  57. {
  58. ActivityDataManager.Instance.sevenDayLoginBonusStatusList[response.BonusId - 1] = response.BonusStatus;
  59. int[][] rewards = DailyLoginCfgArray.Instance.GetCfg(response.BonusId).rewardsArr;
  60. BonusController.TryShowBonusList(rewards);
  61. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  62. return true;
  63. }
  64. }
  65. return false;
  66. }
  67. /*************************************************************首冲奖励*****************************************************/
  68. //领取首冲奖励
  69. public static async ETTask<bool> ReqFirstChargeBonusRewards()
  70. {
  71. S2C_GetFirstRechargeBonus response = null;
  72. response = (S2C_GetFirstRechargeBonus)await MessageHelper.SendToServer(new C2S_GetFirstRechargeBonus() { });
  73. if (response != null)
  74. {
  75. if (response.Error == ErrorCode.ERR_Success)
  76. {
  77. BonusController.TryShowBonusList(GlobalCfgArray.globalCfg.firstChargeBonusArr);
  78. return true;
  79. }
  80. }
  81. return false;
  82. }
  83. /*************************************************************限时抽奖活动*****************************************************/
  84. //请求限时抽奖活动信息
  85. public static async ETTask<bool> ReqGetTimeLimitLuckyBoxInfo(int activityId)
  86. {
  87. S2C_GetTimeLimitLuckyBoxInfo response = null;
  88. response = (S2C_GetTimeLimitLuckyBoxInfo)await MessageHelper.SendToServer(new C2S_GetTimeLimitLuckyBoxInfo() { ActivityId = activityId });
  89. if (response != null)
  90. {
  91. if (response.Error == ErrorCode.ERR_Success)
  92. {
  93. var activityCfg = ActivityOpenCfgArray.Instance.GetCfg(response.ActivityId);
  94. if (activityCfg.type == ConstLimitTimeActivityType.ActLimitLuckyBox)
  95. {
  96. if (ActivityDataManager.Instance.actLuckyBoxId != response.ActivityId)
  97. {
  98. ActivityDataManager.Instance.luckyBoxActBonusState.Clear();
  99. }
  100. ActivityDataManager.Instance.actLuckyBoxId = response.ActivityId;
  101. ActivityDataManager.Instance.allPlayTimes = response.AllPlayTimes;
  102. ActivityDataManager.Instance.lastDrawCount = response.Count;
  103. for (int i = 0; i < response.KsBonusState.Count; i++)
  104. {
  105. ActivityDataManager.Instance.luckyBoxActBonusState[response.KsBonusState[i]] = response.VsBonusState[i];
  106. }
  107. }
  108. else if (activityCfg.type == ConstLimitTimeActivityType.ActLimitTsy)
  109. {
  110. if (ActivityDataManager.Instance.actLimitTsyId != response.ActivityId)
  111. {
  112. ActivityDataManager.Instance.luckyActTsyBonusState.Clear();
  113. }
  114. ActivityDataManager.Instance.actLimitTsyId = response.ActivityId;
  115. ActivityDataManager.Instance.allTsyPlayTimes = response.AllPlayTimes;
  116. ActivityDataManager.Instance.lastTsyDrawCount = response.Count;
  117. for (int i = 0; i < response.KsBonusState.Count; i++)
  118. {
  119. ActivityDataManager.Instance.luckyActTsyBonusState[response.KsBonusState[i]] = response.VsBonusState[i];
  120. }
  121. }
  122. else if (activityCfg.type == ConstLimitTimeActivityType.ActLimitStlyc)
  123. {
  124. if (ActivityDataManager.Instance.actLimitStlycId != response.ActivityId)
  125. {
  126. ActivityDataManager.Instance.limitStlycActBonusState.Clear();
  127. }
  128. ActivityDataManager.Instance.actLimitStlycId = response.ActivityId;
  129. ActivityDataManager.Instance.allLimitStlycTimes = response.AllPlayTimes;
  130. ActivityDataManager.Instance.lastStlycDrawCount = response.Count;
  131. for (int i = 0; i < response.KsBonusState.Count; i++)
  132. {
  133. ActivityDataManager.Instance.limitStlycActBonusState[response.KsBonusState[i]] = response.VsBonusState[i];
  134. }
  135. }
  136. return true;
  137. }
  138. }
  139. return false;
  140. }
  141. /// <summary>
  142. /// 领取抽奖奖励
  143. /// </summary>
  144. /// <param name="activityId"></param>
  145. /// <param name="bonusKey">奖励key,这里对应抽奖次数</param>
  146. /// <returns></returns>
  147. public static async ETTask<bool> ReqGetTimeLimitLuckyBoxBonus(int activityId, int bonusKey)
  148. {
  149. S2C_GetTimeLimitLuckyBoxBonus response = null;
  150. response = (S2C_GetTimeLimitLuckyBoxBonus)await MessageHelper.SendToServer(new C2S_GetTimeLimitLuckyBoxBonus() { ActivityId = activityId, BonusKey = bonusKey });
  151. if (response != null)
  152. {
  153. if (response.Error == ErrorCode.ERR_Success)
  154. {
  155. var activityCfg = ActivityOpenCfgArray.Instance.GetCfg(response.ActivityId);
  156. if (activityCfg.type == ConstLimitTimeActivityType.ActLimitLuckyBox)
  157. {
  158. if (ActivityDataManager.Instance.actLuckyBoxId != response.ActivityId)
  159. {
  160. return false;
  161. }
  162. ActivityDataManager.Instance.luckyBoxActBonusState[response.BonusKey] = response.BonusStatus;
  163. }
  164. else if (activityCfg.type == ConstLimitTimeActivityType.ActLimitTsy)
  165. {
  166. if (ActivityDataManager.Instance.actLimitTsyId != response.ActivityId)
  167. {
  168. return false;
  169. }
  170. ActivityDataManager.Instance.luckyActTsyBonusState[response.BonusKey] = response.BonusStatus;
  171. }
  172. else if (activityCfg.type == ConstLimitTimeActivityType.ActLimitStlyc)
  173. {
  174. if (ActivityDataManager.Instance.actLimitStlycId != response.ActivityId)
  175. {
  176. return false;
  177. }
  178. ActivityDataManager.Instance.limitStlycActBonusState[response.BonusKey] = response.BonusStatus;
  179. }
  180. // int[][] bonus = ActivityLuckybonusCfgArray.Instance.GetCfgByidAndnum(response.ActivityId, response.BonusKey).bonusArr;
  181. BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(response.BonusList));
  182. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  183. EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_ACTIVITY_REWARD);
  184. return true;
  185. }
  186. }
  187. return false;
  188. }
  189. /*************************************************************限时累充*****************************************************/
  190. // /// <summary>
  191. // /// 领取累充奖励
  192. // /// </summary>
  193. // /// <param name="activityId"></param>
  194. // /// <param name="bonusKey">奖励key,这里对应抽奖次数</param>
  195. // /// <returns></returns>
  196. // public static async ETTask<bool> ReqGetLimitChargeBonus(int activityId, int bonusKey)
  197. // {
  198. // S2C_GetTimeLimitLuckyBoxBonus response = null;
  199. // response = (S2C_GetTimeLimitLuckyBoxBonus)await MessageHelper.SendToServer(new C2S_GetTimeLimitLuckyBoxBonus() { ActivityId = activityId, BonusKey = bonusKey });
  200. // if (response != null)
  201. // {
  202. // if (response.Error == ErrorCode.ERR_Success)
  203. // {
  204. // if (ActivityDataManager.Instance.actLuckyBoxId != response.ActivityId)
  205. // {
  206. // return false;
  207. // }
  208. // ActivityDataManager.Instance.luckyBoxActBonusState[response.BonusKey] = response.BonusStatus;
  209. // int[][] bonus = ActivityLuckybonusCfgArray.Instance.GetCfgByidAndnum(response.ActivityId, response.BonusKey).bonusArr;
  210. // BonusController.TryShowBonusList(bonus);
  211. // return true;
  212. // }
  213. // }
  214. // return false;
  215. // }
  216. /*************************************************************活动弹窗*****************************************************/
  217. public static async ETTask<bool> ReqActivityTips(int type , int val)
  218. {
  219. S2C_UpLimitNumericValue response = null;
  220. response = (S2C_UpLimitNumericValue)await MessageHelper.SendToServer(new C2S_UpLimitNumericValue() { NumericType = type,NumericVal = val });
  221. if (response != null)
  222. {
  223. if (response.Error == ErrorCode.ERR_Success)
  224. {
  225. GameGlobal.myNumericComponent.Set(response.NumericType, response.NumericVal);
  226. return true;
  227. }
  228. }
  229. return false;
  230. }
  231. //招财进宝活动
  232. public static async ETTask<bool> ReqActivityZCJBInfo(int id = 5006)
  233. {
  234. S2C_GetDressRewrdStatusList response = null;
  235. response = (S2C_GetDressRewrdStatusList)await MessageHelper.SendToServer(new C2S_GetDressRewrdStatusList() { ActivityId = id });
  236. if (response != null)
  237. {
  238. if (response.Error == ErrorCode.ERR_Success)
  239. {
  240. ActivityDataManager.Instance.ActivityZCJBList = response.RewrdIds;
  241. return true;
  242. }
  243. }
  244. return false;
  245. }
  246. public static async ETTask<bool> ReqActivityZCJBReward(int id,int rewardId)
  247. {
  248. S2C_GetDressRewrd response = null;
  249. response = (S2C_GetDressRewrd)await MessageHelper.SendToServer(new C2S_GetDressRewrd() { ActivityId = id ,RewrdId = rewardId});
  250. if (response != null)
  251. {
  252. if (response.Error == ErrorCode.ERR_Success)
  253. {
  254. ActivityDataManager.Instance.ActivityZCJBList = response.RewrdIds;
  255. BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(response.BonusList));
  256. return true;
  257. }
  258. }
  259. return false;
  260. }
  261. public static async ETTask SetOnceStatus(int k,long id,int type)
  262. {
  263. S2C_UpdateDataRecord response = (S2C_UpdateDataRecord)await MessageHelper.SendToServer(new C2S_UpdateDataRecord() { K = k, V = id ,ResetType = type });
  264. }
  265. public static async ETTask<bool> GetOnceStatus(long k)
  266. {
  267. S2C_GetDataRecord response = (S2C_GetDataRecord)await MessageHelper.SendToServer(new C2S_GetDataRecord() { });
  268. for (int i = 0; i < response.AllKs.Count; i++)
  269. {
  270. if (response.AllKs[i] == k)
  271. {
  272. if (response.AllVs[i] == 1)
  273. {
  274. GameGlobal.AutoZCJBTips = false;
  275. return true;
  276. }
  277. else
  278. {
  279. GameGlobal.AutoZCJBTips = true;
  280. return true;
  281. }
  282. }
  283. }
  284. GameGlobal.AutoZCJBTips = true;
  285. return true;
  286. }
  287. /**********************************************************新年签到*************************************************/
  288. public static async ETTask<bool> ReqGetActivitySignInfos()
  289. {
  290. int activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(ActivityType.ShenDuChenYou);
  291. if (activityId < 0 || ActivitySignCfgArray.Instance.GetCfgsByactivityId(activityId).Count <= 0 )
  292. return false;
  293. S2C_GetActivitySignInfos response = null;
  294. response = (S2C_GetActivitySignInfos)await MessageHelper.SendToServer(new C2S_GetActivitySignInfos() { ActivityId = activityId });
  295. if (response != null)
  296. {
  297. if (response.Error == ErrorCode.ERR_Success)
  298. {
  299. ActivityDataManager.Instance.NewYearLoginInfoDic.Clear();
  300. for(int i = 0;i< response.ksDay.Count; i++) {
  301. ActivityDataManager.Instance.NewYearLoginInfoDic.Add(response.ksDay[i], response.vsStatus[i]);
  302. }
  303. return true;
  304. }
  305. }
  306. return false;
  307. }
  308. public static async ETTask<bool> ReqGetAcitivitySignBonus(int activityId,int day)
  309. {
  310. S2C_ReqGetAcitivitySignBonus response = null;
  311. response = (S2C_ReqGetAcitivitySignBonus)await MessageHelper.SendToServer(new C2S_ReqGetAcitivitySignBonus() { ActivityId = activityId, Day = day });
  312. if (response != null)
  313. {
  314. if (response.Error == ErrorCode.ERR_Success)
  315. {
  316. ActivityDataManager.Instance.NewYearLoginInfoDic[response.Day] = ConstBonusStatus.GOT;
  317. int[][] rewards = ActivitySignCfgArray.Instance.GetCfgByactivityIdAndday(activityId,response.Day).bonusArr;
  318. BonusController.TryShowBonusList(rewards);
  319. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  320. return true;
  321. }
  322. }
  323. return false;
  324. }
  325. //**************************新人礼包领取
  326. public static async ETTask<bool> ReqGetNewPlayerBonus()
  327. {
  328. S2C_GetNewcomerRewards response = null;
  329. response = (S2C_GetNewcomerRewards)await MessageHelper.SendToServer(new C2S_GetNewcomerRewards() { });
  330. if (response != null)
  331. {
  332. if (response.Error == ErrorCode.ERR_Success)
  333. {
  334. ActivityDataManager.Instance.IsGetNewPlayerReward = response.Status;
  335. BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(response.BonusList));
  336. return true;
  337. }
  338. }
  339. return false;
  340. }
  341. //获取新人礼包状态
  342. public static async ETTask<bool> ReqGetNewPlayerBonusStatus()
  343. {
  344. S2C_GetNewcomerRewardStatus response = null;
  345. response = (S2C_GetNewcomerRewardStatus)await MessageHelper.SendToServer(new C2S_GetNewcomerRewardStatus() { });
  346. if (response != null)
  347. {
  348. if (response.Error == ErrorCode.ERR_Success)
  349. {
  350. ActivityDataManager.Instance.IsGetNewPlayerReward = response.Status;
  351. GameGlobal.AutoNewPlayersTips = response.OpenStatus;
  352. return true;
  353. }
  354. }
  355. return false;
  356. }
  357. public static async ETTask SetNewPlayerOnceStatus(long id)
  358. {
  359. S2C_UpdateDataRecord response = (S2C_UpdateDataRecord)await MessageHelper.SendToServer(new C2S_UpdateDataRecord (){ K = 100001, V = id });
  360. }
  361. public static async ETTask<bool> GetNewPlayerOnceStatus()
  362. {
  363. S2C_GetDataRecord response = (S2C_GetDataRecord)await MessageHelper.SendToServer(new C2S_GetDataRecord() { });
  364. for (int i = 0; i < response.AllKs.Count; i++)
  365. {
  366. if (response.AllKs[i] == 100001)
  367. {
  368. if(response.AllVs[i] == 0)
  369. {
  370. GameGlobal.NewPlayerOnceTips = false;
  371. return true;
  372. }
  373. else
  374. {
  375. GameGlobal.NewPlayerOnceTips = true;
  376. return true;
  377. }
  378. }
  379. }
  380. GameGlobal.NewPlayerOnceTips = true;
  381. return true;
  382. }
  383. //弹窗状态设置
  384. public static async ETTask SetTipsStatus(long tips,long value,int type = 1)
  385. {
  386. S2C_UpdateDataRecord response = (S2C_UpdateDataRecord)await MessageHelper.SendToServer(new C2S_UpdateDataRecord() { K = tips,V = value, ResetType = type});
  387. }
  388. public static async ETTask GetTipsStatus()
  389. {
  390. S2C_GetDataRecord response = (S2C_GetDataRecord)await MessageHelper.SendToServer(new C2S_GetDataRecord() { });
  391. for (int i = 0; i < response.AllKs.Count; i++)
  392. {
  393. if(ActivityDataManager.Instance.TipsStatusDic.ContainsKey(response.AllKs[i]))
  394. {
  395. ActivityDataManager.Instance.TipsStatusDic[response.AllKs[i]] = response.AllVs[i];
  396. }
  397. else
  398. {
  399. ActivityDataManager.Instance.TipsStatusDic.Add(response.AllKs[i], response.AllVs[i]);
  400. }
  401. //
  402. }
  403. }
  404. }
  405. //新人活动开启状态推送
  406. public class NewPlayerOpenStatus : AMHandler<S2C_PushNewcomerRewardStatus>
  407. {
  408. protected override async ETTask Run(Session session, S2C_PushNewcomerRewardStatus message)
  409. {
  410. GameGlobal.AutoNewPlayersTips = message.OpenStatus;
  411. await ETTask.CompletedTask;
  412. }
  413. }
  414. }