123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- using System.Collections.Generic;
- using ET;
- using GFGGame;
- namespace ET
- {
- public class NoticeDailyTaskInfoChange : AMHandler<M2C_DailyTaskInfoChange>
- {
- protected override async ETTask Run(Session session, M2C_DailyTaskInfoChange message)
- {
- TaskInfo taskInfo = new TaskInfo();
- taskInfo.id = message.TaskInfo.Id;
- taskInfo.state = message.TaskInfo.Status;
- taskInfo.progress = message.TaskInfo.Progress;
- DailyTaskDataManager.Instance.UpdateTaskInfo(taskInfo.id, taskInfo);
- await ETTask.CompletedTask;
- }
- }
- public class NoticeLivenessBoxChange : AMHandler<M2C_LivenessBoxChange>
- {
- protected override async ETTask Run(Session session, M2C_LivenessBoxChange message)
- {
- for (int i = 0; i < message.kLivenessBox.Count; i++)
- {
- DailyTaskDataManager.Instance.UpdateLivenessBoxInfo(message.kLivenessBox[i], message.vLivenessBox[i]);
- }
- await ETTask.CompletedTask;
- }
- }
- }
- namespace GFGGame
- {
- public static class DailyTaskSProxy
- {
- public static async ETTask<bool> ReqDailyTaskInfos(List<int> itemIds, List<int> itemNums)
- {
- M2C_GetDailyTaskInfos response = null;
- response = (M2C_GetDailyTaskInfos)await MessageHelper.SendToServer(new C2M_GetDailyTaskInfos());
- if (response != null)
- {
- if (response.Error == ErrorCode.ERR_Success)
- {
- for (int i = 0; i < response.TaskList.Count; i++)
- {
- TaskInfo taskInfo = new TaskInfo();
- taskInfo.id = response.TaskList[i].Id;
- taskInfo.state = response.TaskList[i].Status;
- taskInfo.progress = response.TaskList[i].Progress;
- DailyTaskDataManager.Instance.UpdateTaskInfo(taskInfo.id, taskInfo);
- }
- for (int i = 0; i < response.kLivenessBox.Count; i++)
- {
- DailyTaskDataManager.Instance.UpdateLivenessBoxInfo(response.kLivenessBox[i], response.vLivenessBox[i]);
- }
- return true;
- }
- }
- return false;
- }
- public static async ETTask<bool> ReqDailyTaskBonus(int taskId)
- {
- M2C_GetDailyTaskBonus response = null;
- response = (M2C_GetDailyTaskBonus)await MessageHelper.SendToServer(new C2M_GetDailyTaskBonus() { Id = taskId });
- if (response != null)
- {
- if (response.Error == ErrorCode.ERR_Success)
- {
- DailyTaskDataManager.Instance.UpdateTaskState(response.Id, response.Status);
- int[][] bonus = DailyTaskCfgArray.Instance.GetCfg(response.Id).rewardsArr;
- BonusController.TryShowBonusList(bonus);
- return true;
- }
- }
- return false;
- }
- public static async ETTask<bool> ReqAllDailyTaskBonus(List<int> itemIds, List<int> itemNums)
- {
- M2C_GetAllDailyTaskBonus response = null;
- response = (M2C_GetAllDailyTaskBonus)await MessageHelper.SendToServer(new C2M_GetAllDailyTaskBonus());
- if (response != null)
- {
- if (response.Error == ErrorCode.ERR_Success)
- {
- // BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(response.bonusList));
- for (int i = 0; i < response.TaskList.Count; i++)
- {
- TaskInfo taskInfo = new TaskInfo();
- taskInfo.id = response.TaskList[i].Id;
- taskInfo.state = response.TaskList[i].Status;
- taskInfo.progress = response.TaskList[i].Progress;
- DailyTaskDataManager.Instance.UpdateTaskInfo(taskInfo.id, taskInfo);
- }
- List<ItemData> itemDatas = ItemUtil.CreateItemDataList(response.BonusList);
- BonusController.TryShowBonusList(itemDatas);
- return true;
- }
- }
- return false;
- }
- public static async ETTask<bool> ReqLivenessBox(int boxId)
- {
- M2C_GetLivenessBox response = null;
- response = (M2C_GetLivenessBox)await MessageHelper.SendToServer(new C2M_GetLivenessBox() { Id = boxId });
- if (response != null)
- {
- if (response.Error == ErrorCode.ERR_Success)
- {
- // BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(response.bonusList));
- DailyTaskDataManager.Instance.UpdateLivenessBoxInfo(response.Id, response.Status);
- int[][] bonus = DailyActiveRewardCfgArray.Instance.GetCfg(response.Id).rewardsArr;
- BonusController.TryShowBonusList(bonus);
- return true;
- }
- }
- return false;
- }
- }
- }
|