--- ! 注意 ! Attention Attention Attention --- 一定 --- 要 --- 检查BattleSimulator脚本的 HandleRoleEnterSceneAndFrame 是否同样要修改。 --- 否则 --- 不能提交 --- --- 如果提交:需要在 提交描述 中写上 BattleSimulator ,否则提交不了。 --- local SyncMoveManagerExt = {} local EventSystem = require('Event/EventSystem') local enums_pb = require("Proto/enums_pb") local EFFECT_PATH = ConstAssetPathConfig.EFFECT_PATH --自己进入场景,主城、单机类关卡走这 function SyncMoveManagerExt.S2CRoleEnterSceneResp(msgResp, private) if not private.SkipClearPlayersArmy then LevelPlayerManager.BeforeStorePlayerInfo() end LevelManager.BeforeRoleEnterSceneResp() private.SkipClearPlayersArmy = false local levelInfo = DataSheetManager.LevelInfoData:GetDataByLevelID(msgResp.mapCfgId) --这里加个判断,如果场景资源没下载完,需要阻挡住,等待资源下完之后再切场景进去 if levelInfo and CTL.HotFix.HasLevelPackageDownload(nil, msgResp.mapCfgId) == false then private.ProcessStageUnDownload(msgResp.mapCfgId) return end ---- 从指定单机副本内直接跳转进入限时活动副本特殊处理(目前只有魔将来袭) if CTL.Activities.IsSkipTownScene(levelInfo) then logging.log(LTAG.LOG, "跳过进去主城 进入副本") return end if IsServerDataNotNil(msgResp.enemyInfo) then local playerInfo = { name = msgResp.enemyInfo.name, setting = { [1] = false }, officialPosition = msgResp.enemyInfo.officialTitle, fightScores = msgResp.enemyInfo.fightScores } private.SyncRoleGuildInfo(playerInfo, msgResp.enemyInfo.guildShow.emblemContent, msgResp.enemyInfo.guildShow.emblemFrame, msgResp.enemyInfo.guildShow.guildId, msgResp.enemyInfo.guildShow.guildName, msgResp.enemyInfo.guildShow.jobTitle, msgResp.enemyInfo.guildShow.identity, msgResp.enemyInfo.serId, msgResp.enemyInfo.portraitId, msgResp.enemyInfo.frameId) local robotEnemyRecommendGS = msgResp.enemyInfo.isRobot and msgResp.enemyInfo.recommendGS1 or nil NotSyncBattleSetter.SetPlayerArmyTable(LuaConst.STANDALONE_ENEMYPLAYER1_PLAYID, msgResp.enemyInfo.enemyHeroLineUpInfos, playerInfo, false, msgResp.enemyInfo.stratagemDevelopEffects, robotEnemyRecommendGS) local extraInfo = msgResp.enemyInfo.isRobot and {recommendGS1 = robotEnemyRecommendGS, recommendGS2 = msgResp.enemyInfo.recommendGS2, recommendGS3 = msgResp.enemyInfo.recommendGS3 } or nil NotSyncBattleSetter.SetPlayerReserveArmyInfo(LuaConst.STANDALONE_ENEMYPLAYER1_PLAYID, msgResp.enemyInfo.enemyHeroLineUpInfos, msgResp.enemyInfo.enemyHeroLineUpInfos2, msgResp.enemyInfo.enemyHeroLineUpInfos3, extraInfo) end if levelInfo and not CTL.HomeMain.CheckLevelTypeIsTown(levelInfo.LevelType) then --进入主城(一般都是主城进主城)不需要清空跟随信息 MDL.Team.ClearFollow() end local basicInfo = msgResp.BasicInfo NotSyncBattleSetter.SetTownHeroTable(basicInfo) MDL.WarHorse.SetCurShowId(basicInfo.horseId) MDL.WarHorse.SetCurAppearanceShowID(basicInfo.horseAppearanceId) local roleAccid = basicInfo.accid local roleName = basicInfo.Name PlayerInfoManager.SetMainBasicInfo(basicInfo) PlayerInfoManager.SetPlayerInfo(roleAccid, roleName) -- 起名事件注册 if string.isNilOrEmpty(roleName) then EventSystem.Regist(EventID.ChildTaskFinish, CTL.Name.OpenNameView) end --sceneUniqId是战斗外的ID,是主城带分线的ID,场景唯一ID local sceneID = msgResp.sceneUniqId LevelManager.CurUniqueSceneID = sceneID if msgResp.curTowerId > 0 then NotSyncBattleSetter.SetClimbTowerId(msgResp.curTowerId) end LogicUpdateManager.SetServerReplenishFrame(-1) -- 防止同步玩法断线重连后,异常退出关卡,再次进入pve出现表现不能动问题(暂时没有出现,理论上也不会有,多一个层保护而已) --玩家在场景中的状态 LevelManager.ScenePlayerState = msgResp.playerState -- 普通离线玩法,主城没有 local playerSet = {} for i,set in ipairs(basicInfo.settingInfo) do playerSet[set.settingId] = set.state end --当前非同步的公平竞技玩法 local isFairLevel = levelInfo.LevelType == LuaConst.LevelType.BossChallenge or levelInfo.LevelType == LuaConst.LevelType.FairNormalPVE or levelInfo.LevelType == LuaConst.LevelType.SubjectMonthBossChallenge --0代表无效值,忽略即可。 负数和正数都代表有效值,-1代表取消跟随 if basicInfo.snakeIndex ~= 0 then MDL.Team.SetFollowIndex(roleAccid, basicInfo.snakeIndex, basicInfo.leaderId) end if IsServerDataNotNil(msgResp.heroLineUpInfos) then local pos,dir = LevelPlayerManager.GetMoveFromSceneInfo(basicInfo.SceneInfo) local playerInfo = { acid = roleAccid, name = roleName, setting = playerSet, Pos = pos, Dir = dir, officialPosition = basicInfo.officialTitle, serId = basicInfo.serverShowId, countryId = basicInfo.countryInfo.countryId, countryJobId = basicInfo.countryInfo.countryJobId, fightScores = msgResp.fightScores} if BattleDataGetter.IsLevelShowHeadUI_Title(levelInfo.LevelType) then --指定关卡需要显示称号id playerInfo.titleID = basicInfo.titleID end private.SyncRoleGuildInfo(playerInfo, basicInfo.guildShow.emblemContent, basicInfo.guildShow.emblemFrame, basicInfo.guildShow.guildId, basicInfo.guildShow.guildName, basicInfo.guildShow.jobTitle, basicInfo.guildShow.identity) local myPlayerID = LevelManager.IsBattleWaitLevel(levelInfo.LevelType) and LuaConst.BATTLE_WAIT_PLAYER_PlayID or LuaConst.STANDALONE_PLAYER_PlayID NotSyncBattleSetter.SetPlayerArmyTable(myPlayerID, msgResp.heroLineUpInfos, playerInfo, isFairLevel, msgResp.stratagemDevelopEffects,nil, levelInfo.LevelType)--new 从LevelSelect_Model的OnEnterFubenResponse移过来的 NotSyncBattleSetter.SetPlayerReserveArmyInfo(myPlayerID, msgResp.heroLineUpInfos, msgResp.heroLineUpInfos2, msgResp.heroLineUpInfos3) end -- boss 挑战玩法,与上互斥 ;simpleAttrs 起名非常不好,其实意义是 HeroSampleInfo ,主城没有 if IsServerDataNotNil(msgResp.simpleAttrs) then local pos,dir = LevelPlayerManager.GetMoveFromSceneInfo(basicInfo.SceneInfo) local playerInfo = { acid = roleAccid, name = roleName, setting = playerSet, Pos = pos, Dir = dir, fightScores = msgResp.fightScores} NotSyncBattleSetter.SetPlayerArmyTable(LuaConst.STANDALONE_PLAYER_PlayID, msgResp.simpleAttrs, playerInfo, isFairLevel, msgResp.stratagemDevelopEffects) end if IsServerDataNotNil(msgResp.buffId) then NotSyncBattleSetter.SetLevelBuffIdList(msgResp.buffId) end if IsServerDataNotNil(msgResp.playerBuffs) then NotSyncBattleSetter.SetPlayerBuffInfoList(msgResp.playerBuffs) end NotSyncBattleSetter.SetClientIntermediateParamsBytes(msgResp.clientIntermediateParams) MDL.RebelStrike.SyncRebelStrikeSceneInfo(msgResp.rebels) --msgResp.sceneType : 1 主城 ;2 离线战斗 ;3 在线战斗 ;4 动态场景 boss准备 军团领地 logging.log(LTAG.LOG, "[进入关卡]-------RoleEnterScene----- sceneType = " , msgResp.sceneType , " ,mapid = " ,msgResp.mapCfgId ,"gotoType =" , msgResp.gotoType) local curLine = msgResp.lineId if SyncMoveManager.CurLine and curLine and SyncMoveManager.CurLine ~= curLine then SyncMoveManager.CurLine = curLine end SDKUtil.OnRoleEnterScene() -- 这句代码时应该在登录和重连时调用一次的 if IsServerDataNotNil(msgResp.goldHeroBoss) then LevelManager.SetServerGs(msgResp.goldHeroBoss.recommendGs) LevelManager.SetServerBossHp(msgResp.goldHeroBoss.curBossHp, msgResp.goldHeroBoss.maxBossHp) LevelManager.SetGsGroupId(msgResp.goldHeroBoss.gsGroupId) LevelManager.SetBossLevel(msgResp.goldHeroBoss.bossLevel) elseif msgResp.serverFightScore > 0 then LevelManager.SetServerGs(msgResp.serverFightScore) end if IsProtoDataNotNil(msgResp.gveInfo) then --slg关卡的服务器数据 LevelManager.SetServerGs(msgResp.gveInfo.recommendGs) LevelManager.SetServerBossHp(msgResp.gveInfo.curBossHp, msgResp.gveInfo.maxBossHp) LevelManager.SetSlgGveData(msgResp.gveInfo.landId, msgResp.gveInfo.thiefId, msgResp.gveInfo.enemyBuffId, msgResp.gveInfo.openDayId) end if msgResp.subjugateDataPVEID > 0 then LevelManager.SetSubjugateDataPVEID(msgResp.subjugateDataPVEID) else LevelManager.SetSubjugateDataPVEID(nil) end if not BattleDataGetter.ShouldKeepSyncLevel() then NotSyncBattleSetter.SetLevelSaveRecordBytes(msgResp.saveRecordStr) --proto传过来的改为了bytes,但是命名没改还是有str后缀 elseif msgResp.saveRecordStr and msgResp.saveRecordStr ~= "" then logging.error(LTAG.ERROR, "HYW : 在同步或者需要校验的关卡视图设置存档,这个是不支持的! LevelType : ", levelInfo.LevelType, " LevelID : ", levelInfo.LevelID, " msgResp.saveRecordStr : ", msgResp.saveRecordStr) end local randomSeed = msgResp.randomSeed if msgResp.gotoType == enums_pb.Goto_ChangeLine or (msgResp.gotoType == enums_pb.Goto_Assign_Mapline and LevelManager.GetCurLevelID() == msgResp.mapCfgId) then --切线成功上报下位置 SyncMoveManager.ForceC2SRoleCheck() private.OnSwitchBranch() -- 销毁场景中的非自己的事物 SystemManager.PlayPsEffect(EFFECT_PATH) EventSystem.Dispatch(EventID.UI_ChangeLineDone) elseif msgResp.gotoType == enums_pb.Goto_Online then -- 玩家上线 local curLevelID = LevelManager.GetCurLevelID() local firstOnline = curLevelID < 0 -- 第一次进入游戏的话 ,curLevelID = -1 if firstOnline then -- 如果有首次登录要处理的代码 ,注意InitFubenReconnect(它与此协议互斥)中也要处理 LevelManager.SwitchLevel(msgResp.mapCfgId, randomSeed, false, true) else -- 在游戏中 ,重新连接上的处理 if LevelManager.IsSyncLevel() then -- 在pvp收到这个 ,说明:一个人的战斗掉线了,重连成功后房间没有了 ,只能回到主城 logging.crit(LTAG.CRIT, "GWS : 发现没有同步玩法的房间了 ,只能回主城了!") LevelManager.CurLevelFunc:StopLevel() if LevelManager.IsReplayBattle() then BattleSimulator.EndPlay(true) LevelManager.SetIsReplayBattle(false) end LevelManager.SwitchLevel(msgResp.mapCfgId, randomSeed, false, true) else if curLevelID ~= msgResp.mapCfgId then -- 断线重连回来发现已经是在主城,但是主城和掉线前的不一样,那么就需要换地图的 LevelManager.SwitchLevel(msgResp.mapCfgId, randomSeed, false, true) else --一样的场景,直接处理真正进入场景 if LevelManager.IsTown then private.OnSwitchBranch() -- 销毁场景中的非自己的事物 end LevelManager.StartRealEnterScene() end end end else -- msgResp.gotoType==2 ,msgResp.gotoType==5(换城) --爬塔关走单独的关卡id if levelInfo and levelInfo.LevelType == LuaConst.LevelType.ClimbTower then local data= DataSheetManager.ClimbTowerLevel:GetDataByID(msgResp.curTowerId) LevelManager.SwitchCombinationLevel(data.CombinationLevelID, randomSeed, msgResp.needCheck, true) elseif levelInfo and levelInfo.LevelType == LuaConst.LevelType.NationClimbTower then local data= DataSheetManager.NationClimbTowerLevel:GetDataByID(msgResp.curTowerId) LevelManager.SwitchCombinationLevel(data.CombinationLevelID, randomSeed, msgResp.needCheck, true) else LevelManager.SwitchLevel(msgResp.mapCfgId, randomSeed, msgResp.needCheck, true) end end CTL.Replay.TrySaveAsyncEnterMsg(msgResp) SyncMoveManager.CanChangeLine = true end return SyncMoveManagerExt