| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 | using System;using System.Collections.Generic;using System.Linq;using System.Text;using ET;namespace GFGGame{    public class InstanceZonesSProxy    {        //请求剧情关卡数据        public static async ETTask GetInstanceZonesInfos()        {            M2C_GetInstanceZonesInfos response = null;            response = (M2C_GetInstanceZonesInfos)await MessageHelper.SendToServer(new C2M_GetInstanceZonesInfos());            if (response != null)            {                if (response.Error == ErrorCode.ERR_Success)                {                    InstanceZonesDataManager.InitScoreList(response.ksScore, response.vsScore);                    InstanceZonesDataManager.InitStarList(response.ksStar, response.vsStar);                    InstanceZonesDataManager.InitLevelPass(response.ksPass, response.VsPass);                    EventAgent.DispatchEvent(ConstMessage.STORY_LEVEL_CHANGE);                }            }        }        //完成剧情对话关卡        public static async ETTask FinishStoryDialogLevel(int levelCfgId)        {            M2C_FinishInstanceZonesDialog response = null;            response = (M2C_FinishInstanceZonesDialog)await MessageHelper.SendToServer(new C2M_FinishInstanceZonesDialog()            {                LevelCfgId = levelCfgId            });            if (response != null)            {                if (response.Error == ErrorCode.ERR_Success)                {                    List<ItemData> bonusList = StoryBonusDataCache.GetBonusList(response.LevelCfgId, true);                    InstanceZonesDataManager.TrySetLevelPass(response.LevelCfgId);                    InstanceZonesController.OnFinishStoryLevel(levelCfgId, true, true);                    FunctionOpenDataManager.Instance.CheckHasChapterFunOpen(response.LevelCfgId);//首次通过要检查是否有功能开启                    BonusController.TryShowBonusList(bonusList);                    EventAgent.DispatchEvent(ConstMessage.STORY_LEVEL_CHANGE);                    return;                }            }            InstanceZonesController.OnFinishStoryLevel(levelCfgId, false, false);        }        //完成剧情战斗关卡        public static async ETTask FinishStoryFightLevel(int levelCfgId, int score, int npcScore, bool useRecomend)        {            M2C_FinishInstanceZonesFightLevel response = null;            response = (M2C_FinishInstanceZonesFightLevel)await MessageHelper.SendToServer(new C2M_FinishInstanceZonesFightLevel()            {                LevelCfgId = levelCfgId,                Score = score,                NpcScore = npcScore,                UseRecommend = false            });            bool isFirstFinish = false;            if (response != null)            {                if (response.Error == ErrorCode.ERR_Success)                {                    //更新数据                    InstanceZonesDataManager.TryUpdateScore(response.LevelCfgId, response.Score);                    InstanceZonesDataManager.TryUpdateLevelStar(response.LevelCfgId, response.Star);                    //展示奖励                    List<ItemData> bonusList = StoryBonusDataCache.GetBonusList(response.LevelCfgId, response.HasOnceBonus);                    if (response.RandomBonusList != null)                    {                        foreach (var item in response.RandomBonusList)                        {                            var itemData = ItemUtil.createItemData(item.ConfigId, item.Count);                            bonusList.Add(itemData);                        }                    }                    if (response.HasOnceBonus)                    {                        isFirstFinish = true;                    }                    InstanceZonesDataManager.TrySetLevelPass(response.LevelCfgId);                    ViewManager.Show(ViewName.STORY_FIGHT_RESULT_VIEW, new StoryFightResultData                    {                        Result = true,                        Score = response.Score,                        FirstPass = response.HasOnceBonus,                        Star = response.Star,                        BonusList = bonusList                    }, null, true);                    if (response.HasOnceBonus)                    {                        FunctionOpenDataManager.Instance.CheckHasChapterFunOpen(response.LevelCfgId);                    }                    return;                }            }            InstanceZonesController.OnFinishStoryLevel(levelCfgId, false, false);            if (isFirstFinish)            {                //首次通过要检查是否有功能开启                FunctionOpenDataManager.Instance.CheckHasChapterFunOpen(response.LevelCfgId);                EventAgent.DispatchEvent(ConstMessage.STORY_LEVEL_CHANGE);            }        }        //剧情战斗关卡失败,更新最高分        public static async ETTask StoryFightLevelFail(int levelCfgId, int score)        {            M2C_FinishInstanceZonesFightLevelFail response = null;            response = (M2C_FinishInstanceZonesFightLevelFail)await MessageHelper.SendToServer(new C2M_FinishInstanceZonesFightLevelFail()            {                LevelCfgId = levelCfgId,                Score = score,            });            if (response != null)            {                if (response.Error == ErrorCode.ERR_Success)                {                    InstanceZonesDataManager.TryUpdateScore(response.LevelCfgId, response.Score);                }            }        }        //快速完成关卡战斗        public static async ETTask FinishStoryFightQuickly(int levelCfgId, int times)        {            M2C_FinishInstanceZonesFightQuickly response = null;            response = (M2C_FinishInstanceZonesFightQuickly)await MessageHelper.SendToServer(new C2M_FinishInstanceZonesFightQuickly()            {                LevelCfgId = levelCfgId,                Times = times            });            if (response != null)            {                if (response.Error == ErrorCode.ERR_Success)                {                    List<List<ItemData>> bonusLists = new List<List<ItemData>>();                    List<ItemData> allList = new List<ItemData>();                    foreach (var proto in response.RandomBonusList)                    {                        var itemData = ItemUtil.createItemData(proto.ConfigId, proto.Count);                        allList.Add(itemData);                    }                    var index = 0;                    for (int i = 0; i < response.BonusLengths.Count; ++i)                    {                        var len = response.BonusLengths[i];                        var baseBonusList = StoryBonusDataCache.GetBaseBonusList(response.LevelCfgId);                        List<ItemData> bonusList = new List<ItemData>();                        if (baseBonusList != null)                        {                            bonusList.AddRange(baseBonusList);                        }                        if (len > 0)                        {                            bonusList.AddRange(allList.GetRange(index, len));                        }                        bonusLists.Add(bonusList);                        index += len;                    }                    EventAgent.DispatchEvent(ConstMessage.STORY_FIGHT_QUICKLY_SUCCESS, bonusLists);                }            }        }    }}
 |