| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 | using ET;using GFGGame;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ET{    public class M2C_NoticeMainStoryBoxBonusStateHandler : AMHandler<M2C_NoticeMainStoryBoxBonusState>    {        protected override async ETTask Run(Session session, M2C_NoticeMainStoryBoxBonusState message)        {            MainStoryDataManager.UpdateBoxBonusStates(message.ChapterId, message.BoxStates);            EventAgent.DispatchEvent(ConstMessage.NOTICE_MAINSTORY_BOXBONUS_STATE);            await ETTask.CompletedTask;        }    }}namespace GFGGame{    public class MainStorySProxy    {        //请求剧情关卡数据        public static async ETTask GetStoryBonusInfos()        {            M2C_GetMainStoryInfos response = null;            response = (M2C_GetMainStoryInfos)await MessageHelper.SendToServer(new C2M_GetMainStoryInfos());            if (response != null)            {                if (response.Error == ErrorCode.ERR_Success)                {                    MainStoryDataManager.InitBoxBonusStates(response.KsBonusState, response.VsBonusState);                }            }        }        //请求剧情关卡数据        public static async ETTask<bool> GetMainStoryBoxBonus(int chapterId, int index)        {            M2C_GetMainStoryBoxBonus response = null;            response = (M2C_GetMainStoryBoxBonus)await MessageHelper.SendToServer(new C2M_GetMainStoryBoxBonus() { ChapterId = chapterId, Index = index });            if (response != null)            {                if (response.Error == ErrorCode.ERR_Success)                {                    MainStoryDataManager.UpdateBoxBonusStates(response.ChapterId, response.BoxStates);                    return true;                }            }            return false;        }        //请求章节奖励数据        public static async ETTask<bool> GetStoryBonusDate()        {            S2C_GetChapterPassStatus response = null;            response = (S2C_GetChapterPassStatus)await MessageHelper.SendToServer(new C2S_GetChapterPassStatus() {  });            if (response != null)            {                if (response.Error == ErrorCode.ERR_Success)                {                    MainStoryDataManager.ChapterRewardStatusDic.Clear();                    for(int i = 0;i < response.PassStatusKs.Count;i++)                    {                        MainStoryDataManager.ChapterRewardStatusDic.Add(response.PassStatusKs[i], response.PassStatusVs[i]);                    }                        return true;                }            }            return false;        }        //领取章节奖励数据        public static async ETTask<bool> GetStoryBonusReward(int id)        {            S2C_GethapterPassReward response = null;            response = (S2C_GethapterPassReward)await MessageHelper.SendToServer(new C2S_GethapterPassReward() { ChapterId = id});            if (response != null)            {                if (response.Error == ErrorCode.ERR_Success)                {                    for (int i = 0; i < response.PassStatusKs.Count; i++)                    {                        if(response.PassStatusKs[i] == id)                        {                            MainStoryDataManager.ChapterRewardStatusDic[id] = response.PassStatusVs[i];                        }                      }                    BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(response.BonusList));                    return true;                }            }            return false;        }    }}
 |