123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using ET;
- namespace GFGGame
- {
- public class StorySProxy
- {
- //请求剧情关卡数据
- public static async ETTask GetStoryInfos()
- {
- M2C_GetStoryInfos response = null;
- response = (M2C_GetStoryInfos)await MessageHelper.SendToServer(new C2M_GetStoryInfos());
- if(response != null)
- {
- if(response.Error == ErrorCode.ERR_Success)
- {
- StoryDataManager.InitScoreList(response.ksScore, response.vsScore);
- StoryDataManager.InitStarList(response.ksStar, response.vsStar);
- StoryDataManager.InitBoxBonusStates(response.ksBonusState, response.vsBonusState);
- }
- }
- }
- //完成剧情对话关卡
- public static async ETTask FinishStoryDialogLevel(int levelCfgId)
- {
- M2C_FinishStoryDialog response = null;
- response = (M2C_FinishStoryDialog)await MessageHelper.SendToServer(new C2M_FinishStoryDialog()
- {
- LevelCfgId = levelCfgId
- });
- if (response != null)
- {
- if (response.Error == ErrorCode.ERR_Success)
- {
- List<ItemData> bonusList = StoryBonusDataCache.GetBonusList(response.LevelCfgId, true, true);
- BonusController.TryShowBonusList(bonusList);
- }
- }
- }
- //完成剧情战斗关卡
- public static async ETTask FinishStoryFightLevel(int levelCfgId, int score, int npcScore, bool useRecomend)
- {
- M2C_FinishStoryFightLevel response = null;
- response = (M2C_FinishStoryFightLevel)await MessageHelper.SendToServer(new C2M_FinishStoryFightLevel()
- {
- LevelCfgId = levelCfgId,
- Score = score,
- NpcScore = npcScore,
- UseRecommend = useRecomend
- });
- if(response != null)
- {
- if(response.Error == ErrorCode.ERR_Success)
- {
- //更新数据
- StoryDataManager.TryUpdateScore(response.LevelCfgId, response.Score);
- StoryDataManager.TryUpdateLevelStar(response.LevelCfgId, response.Star);
- CalculateHelper.GetStoryChapterLevel(response.LevelCfgId, out var chapter, out var level);
- StoryDataManager.UpdateBoxBonusStates(chapter, response.BoxStates);
- //展示奖励
- 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)
- {
- //首次通过要检查是否有功能开启
- FunctionOpenDataManager.Instance.CheckHasChapterFunOpen(GameGlobal.myNumericComponent.GetAsInt(NumericType.Chapter) + 1, GameGlobal.myNumericComponent.GetAsInt(NumericType.ChapterLvl));
- }
- ViewManager.Show(ViewName.STORY_FIGHT_RESULT_VIEW, new StoryFightResultData
- {
- Result = true,
- Score = response.Score,
- FirstPass = response.HasOnceBonus,
- Star = response.Star,
- BonusList = bonusList
- }, null, true);
- return;
- }
- }
- //异常返回到关卡列表界面
- ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, StoryDataManager.currentChapter, ViewManager.GetGoBackDatas(ViewName.STORY_CHAPTER_VIEW));
- }
- //完成剧情战斗关卡失败,更新最高分
- public static async ETTask FinishStoryFightLevelFail(int levelCfgId, int score)
- {
- M2C_FinishStoryFightLevelFail response = null;
- response = (M2C_FinishStoryFightLevelFail)await MessageHelper.SendToServer(new C2M_FinishStoryFightLevelFail()
- {
- LevelCfgId = levelCfgId,
- Score = score,
- });
- if (response != null)
- {
- if (response.Error == ErrorCode.ERR_Success)
- {
- StoryDataManager.TryUpdateScore(response.LevelCfgId, response.Score);
- }
- }
- }
- }
- }
|