DailyTaskSProxy.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using System.Collections.Generic;
  2. using ET;
  3. using GFGGame;
  4. namespace ET
  5. {
  6. public class NoticeDailyTaskInfoChange : AMHandler<M2C_DailyTaskInfoChange>
  7. {
  8. protected override async ETTask Run(Session session, M2C_DailyTaskInfoChange message)
  9. {
  10. TaskInfo taskInfo = new TaskInfo();
  11. taskInfo.id = message.TaskInfo.Id;
  12. taskInfo.state = message.TaskInfo.Status;
  13. taskInfo.progress = message.TaskInfo.Progress;
  14. DailyTaskDataManager.Instance.UpdateTaskInfo(taskInfo.id, taskInfo);
  15. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  16. await ETTask.CompletedTask;
  17. }
  18. }
  19. public class NoticeLivenessBoxChange : AMHandler<M2C_LivenessBoxChange>
  20. {
  21. protected override async ETTask Run(Session session, M2C_LivenessBoxChange message)
  22. {
  23. for (int i = 0; i < message.kLivenessBox.Count; i++)
  24. {
  25. DailyTaskDataManager.Instance.UpdateLivenessBoxInfo(message.kLivenessBox[i], message.vLivenessBox[i]);
  26. }
  27. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  28. await ETTask.CompletedTask;
  29. }
  30. }
  31. }
  32. namespace GFGGame
  33. {
  34. public static class DailyTaskSProxy
  35. {
  36. public static async ETTask<bool> ReqDailyTaskInfos()
  37. {
  38. M2C_GetDailyTaskInfos response = null;
  39. response = (M2C_GetDailyTaskInfos)await MessageHelper.SendToServer(new C2M_GetDailyTaskInfos());
  40. if (response != null)
  41. {
  42. if (response.Error == ErrorCode.ERR_Success)
  43. {
  44. for (int i = 0; i < response.TaskList.Count; i++)
  45. {
  46. TaskInfo taskInfo = new TaskInfo();
  47. taskInfo.id = response.TaskList[i].Id;
  48. taskInfo.state = response.TaskList[i].Status;
  49. taskInfo.progress = response.TaskList[i].Progress;
  50. DailyTaskDataManager.Instance.UpdateTaskInfo(taskInfo.id, taskInfo);
  51. }
  52. for (int i = 0; i < response.kLivenessBox.Count; i++)
  53. {
  54. DailyTaskDataManager.Instance.UpdateLivenessBoxInfo(response.kLivenessBox[i], response.vLivenessBox[i]);
  55. }
  56. return true;
  57. }
  58. }
  59. return false;
  60. }
  61. public static async ETTask<bool> ReqDailyTaskBonus(int taskId)
  62. {
  63. M2C_GetDailyTaskBonus response = null;
  64. response = (M2C_GetDailyTaskBonus)await MessageHelper.SendToServer(new C2M_GetDailyTaskBonus() { Id = taskId });
  65. if (response != null)
  66. {
  67. if (response.Error == ErrorCode.ERR_Success)
  68. {
  69. DailyTaskDataManager.Instance.UpdateTaskState(response.Id, response.Status);
  70. int[][] bonus = DailyTaskCfgArray.Instance.GetCfg(response.Id).rewardsArr;
  71. BonusController.TryShowBonusList(bonus);
  72. return true;
  73. }
  74. }
  75. return false;
  76. }
  77. public static async ETTask<bool> ReqAllDailyTaskBonus()
  78. {
  79. M2C_GetAllDailyTaskBonus response = null;
  80. response = (M2C_GetAllDailyTaskBonus)await MessageHelper.SendToServer(new C2M_GetAllDailyTaskBonus());
  81. if (response != null)
  82. {
  83. if (response.Error == ErrorCode.ERR_Success)
  84. {
  85. // BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(response.bonusList));
  86. for (int i = 0; i < response.TaskList.Count; i++)
  87. {
  88. TaskInfo taskInfo = new TaskInfo();
  89. taskInfo.id = response.TaskList[i].Id;
  90. taskInfo.state = response.TaskList[i].Status;
  91. taskInfo.progress = response.TaskList[i].Progress;
  92. DailyTaskDataManager.Instance.UpdateTaskInfo(taskInfo.id, taskInfo);
  93. }
  94. List<ItemData> itemDatas = ItemUtil.CreateItemDataList(response.BonusList);
  95. BonusController.TryShowBonusList(itemDatas);
  96. return true;
  97. }
  98. }
  99. return false;
  100. }
  101. public static async ETTask<bool> ReqLivenessBox(int boxId)
  102. {
  103. M2C_GetLivenessBox response = null;
  104. response = (M2C_GetLivenessBox)await MessageHelper.SendToServer(new C2M_GetLivenessBox() { Id = boxId });
  105. if (response != null)
  106. {
  107. if (response.Error == ErrorCode.ERR_Success)
  108. {
  109. // BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(response.bonusList));
  110. DailyTaskDataManager.Instance.UpdateLivenessBoxInfo(response.Id, response.Status);
  111. int[][] bonus = DailyActiveRewardCfgArray.Instance.GetCfg(response.Id).rewardsArr;
  112. BonusController.TryShowBonusList(bonus);
  113. return true;
  114. }
  115. }
  116. return false;
  117. }
  118. }
  119. }