StudioSProxy.cs 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using System.Collections.Generic;
  2. using ET;
  3. using GFGGame;
  4. namespace ET
  5. {
  6. public class NoticeStudioPlayTimes : AMHandler<M2C_NoticeStudioPlayTimes>
  7. {
  8. protected override async ETTask Run(Session session, M2C_NoticeStudioPlayTimes message)
  9. {
  10. StudioDataManager.Instance.NoticeStudioPlayTimes(message.ChapterId, message.PlayTimes);
  11. EventAgent.DispatchEvent(ConstMessage.NOTICE_STUDIO_PLAY_TIMES);
  12. await ETTask.CompletedTask;
  13. }
  14. }
  15. public class NoticeFilingScoreBonusChanged : AMHandler<S2C_FilingScoreBonusChanged>
  16. {
  17. protected override async ETTask Run(Session session, S2C_FilingScoreBonusChanged message)
  18. {
  19. StudioDataManager.Instance.NoticeFilingScoreBonusChanged(message.ChapterId, message.ChapterScore, message.BonusStatusList);
  20. EventAgent.DispatchEvent(ConstMessage.FILING_SCORE_CHANGE);
  21. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  22. await ETTask.CompletedTask;
  23. }
  24. }
  25. }
  26. namespace GFGGame
  27. {
  28. public class StudioSProxy
  29. {
  30. //请求工作室副本数据
  31. public static async ETTask ReqStudioInfos()
  32. {
  33. M2C_GetStudioInfos response = null;
  34. response = (M2C_GetStudioInfos)await MessageHelper.SendToServer(new C2M_GetStudioInfos());
  35. if (response != null)
  36. {
  37. if (response.Error == ErrorCode.ERR_Success)
  38. {
  39. for (int i = 0; i < response.infos.Count; i++)
  40. {
  41. StudioData studioData = new StudioData { ChapterId = response.infos[i].ChapterId, BuyTimes = response.infos[i].BuyTimes, PlayTimes = response.infos[i].PlayTimes, TotalPlayTimes = response.infos[i].TotalPlayTimes, ChapterScore = response.infos[i].ChapterScore, RewardsStatus = response.infos[i].BonusStatusList };
  42. StudioDataManager.Instance.RspStudioInfos(studioData);
  43. }
  44. StudioDataManager.Instance.PorcelainTheme = response.RepairPorcelainTheme;
  45. }
  46. }
  47. }
  48. //请求购买副本挑战次数
  49. public static async ETTask ReqBuyStudioPlayTimes(int chapterId, int buyType, int buyCount)
  50. {
  51. M2C_BuyStudioPlayTimes response = null;
  52. response = (M2C_BuyStudioPlayTimes)await MessageHelper.SendToServer(new C2M_BuyStudioPlayTimes() { ChapterId = chapterId, BuyType = buyType, BuyCount = buyCount });
  53. if (response != null)
  54. {
  55. if (response.Error == ErrorCode.ERR_Success)
  56. {
  57. StudioDataManager.Instance.RspBuyStudioPlayTimes(response.ChapterId, response.BuyTimes, response.TotalPlayTimes);
  58. EventAgent.DispatchEvent(ConstMessage.BUY_STUDIO_PLAY_TIMES);
  59. }
  60. }
  61. }
  62. //领取查阅建档分数宝箱
  63. public static async ETTask ReqFilingScoreRewards(int chapterId)
  64. {
  65. S2C_GetFilingScoreBonus response = null;
  66. response = (S2C_GetFilingScoreBonus)await MessageHelper.SendToServer(new C2S_GetFilingScoreBonus() { ChapterId = chapterId });
  67. if (response != null)
  68. {
  69. if (response.Error == ErrorCode.ERR_Success)
  70. {
  71. List<ItemData> itemDatas = new List<ItemData>();
  72. for (int i = 0; i < response.BonusIndexList.Count; i++)
  73. {
  74. StudioDataManager.Instance.RspFilingScoreReward(response.ChapterId, response.BonusIndexList[i]);
  75. List<FilingRewardCfg> filingRewards = FilingRewardCfgArray.Instance.GetCfgsByid(response.ChapterId);
  76. int[][] rewards = filingRewards[response.BonusIndexList[i]].itemsArr;
  77. for (int j = 0; j < rewards.Length; j++)
  78. {
  79. itemDatas.Add(ItemUtil.createItemData(rewards[j]));
  80. }
  81. }
  82. BonusController.TryShowBonusList(itemDatas);
  83. EventAgent.DispatchEvent(ConstMessage.FILING_SCORE_CHANGE);
  84. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  85. }
  86. }
  87. }
  88. }
  89. }