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