local Base = require("Battle/Logic/Level/LevelFunction/SyncCityWarBaseLevelFunction") local SyncCityWarMainSecondStageLevelFunction = class("SyncCityWarMainSecondStageLevelFunction", Base) local SyncCityWarMainFirstStageLevelFunction = require("Battle/Logic/Level/LevelFunction/SyncCityWarMainFirstStageLevelFunction") local siege_city_battlecheck_pb = require 'Proto/siege_city_battlecheck_pb' local STATUE_KING_FEATURE_ID = 622041 local STATUE_SIKONG_FEATURE_ID = 622042 local STATUE_SIMA_FEATURE_ID = 622043 local SiegeCityFinalBattleKillPoint = DataSheetManager.ConstData:GetDataByID("SiegeCityFinalBattleKillPoint").IntValue local SiegeCityFinalBattleAssistPoint = DataSheetManager.ConstData:GetDataByID("SiegeCityFinalBattleAssistPoint").IntValue local SiegeCityDefaultStatueHeroID = DataSheetManager.ConstData:GetDataByID("SiegeCityDefaultStatueHeroID").IntValue local SiegeCityDefaultStatueHeroStar = DataSheetManager.ConstData:GetDataByID("SiegeCityDefaultStatueHeroStar").IntValue local SiegeCityDefaultStatueHaveMagicWeapon = DataSheetManager.ConstData:GetDataByID("SiegeCityDefaultStatueHaveMagicWeapon").IntValue local SiegeCityDefaultStatueMagicWeaponStar = DataSheetManager.ConstData:GetDataByID("SiegeCityDefaultStatueMagicWeaponStar").IntValue local SiegeCityMBFBossClientBloodRate = DataSheetManager.ConstData:GetDataByID("SiegeCityMBFBossClientBloodRate").FloatValue local SiegeCityCentralStatueSize = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("SiegeCityCentralStatueSize").FloatValue) local SiegeCityLeftStatueSize = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("SiegeCityLeftStatueSize").FloatValue) local LuaConst = LuaConst local EStatisticType = LuaConst.EStatisticType local tonumberV1 = FP.tonumberV1 local ZERO_SCORE = FP.newV1(0) function SyncCityWarMainSecondStageLevelFunction:InitLevel() Base.InitLevel(self) self.statue1HpLoss = FP.newV1(0) --君主雕像血量损失 self.statue2HpLoss = FP.newV1(0) --大司马雕像血量损失 self.statue3HpLoss = FP.newV1(0) --大司空雕像血量损失 local preBattleResults = LevelManager.GetPreBattleResult() if IsServerDataNotNil(preBattleResults) then self.preBattleResults = preBattleResults else logging.error(LTAG.ERROR, "HYW : preBattleResults nil Warning!! If happening in battlecheck is OK!") end self.statueBaseEntityIDList = {} --雕像底座EntityID列表 self.jobId2StatueEntityDic = {} --金色雕像单位列表 end function SyncCityWarMainSecondStageLevelFunction:IsStatue(entity) local entityID = entity.EntityID for i,statueEntityID in ipairs(self.statueBaseEntityIDList) do if statueEntityID == entityID then return true end end return false end function SyncCityWarMainSecondStageLevelFunction:CreateStatues() local battleStatueInfoList = LevelManager.GetBattleStatueInfoList() if battleStatueInfoList and #battleStatueInfoList > 0 then --如果缺失数据,则填充假数据 if #battleStatueInfoList == 1 then local fakeInfoSima = { countryInfo = {countryJobId = 11}, Name = "", HeroId = SiegeCityDefaultStatueHeroID, heroBreakNums = SiegeCityDefaultStatueHaveMagicWeapon, weaponBreak = SiegeCityDefaultStatueMagicWeaponStar, } table.insert(battleStatueInfoList, fakeInfoSima) local fakeInfoSikong = { countryInfo = {countryJobId = 12}, Name = "", HeroId = SiegeCityDefaultStatueHeroID, heroBreakNums = SiegeCityDefaultStatueHaveMagicWeapon, weaponBreak = SiegeCityDefaultStatueMagicWeaponStar, } table.insert(battleStatueInfoList, fakeInfoSikong) elseif #battleStatueInfoList == 2 then local jobId if battleStatueInfoList[1].countryInfo.countryJobId > 1 then jobId = battleStatueInfoList[1].countryInfo.countryJobId else jobId = battleStatueInfoList[2].countryInfo.countryJobId end if jobId == 11 then jobId = 12 else jobId = 11 end local fakeInfo = { countryInfo = {countryJobId = jobId}, Name = "", HeroId = SiegeCityDefaultStatueHeroID, heroBreakNums = SiegeCityDefaultStatueHaveMagicWeapon, weaponBreak = SiegeCityDefaultStatueMagicWeaponStar, } table.insert(battleStatueInfoList, fakeInfo) end --↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ for i,info in ipairs(battleStatueInfoList) do local posV2 local dirV2 local countryJobId = info.countryInfo.countryJobId local defaultSize = 2.1 if countryJobId == 1 then posV2 = self.kingStatueEntity:GetLogicPos() dirV2 = self.kingStatueEntity.components.move.LogicRotateDir defaultSize = SiegeCityCentralStatueSize elseif countryJobId == 11 then posV2 = self.sikongStatueEntity:GetLogicPos() dirV2 = self.sikongStatueEntity.components.move.LogicRotateDir defaultSize = SiegeCityLeftStatueSize elseif countryJobId == 12 then posV2 = self.simaStatueEntity:GetLogicPos() dirV2 = self.simaStatueEntity.components.move.LogicRotateDir defaultSize = SiegeCityLeftStatueSize end EntityFactory.SetParams("Name", info.Name) EntityFactory.SetType_ID(LuaConst.CharacterType.Hero, info.HeroId) EntityFactory.SetPos_Dir(posV2, dirV2) EntityFactory.SetEffectBreak_Weapon(info.heroBreakNums, info.isActiveMagicWeapon, info.weaponBreak) EntityFactory.SetTitle_ID(info.titleID) EntityFactory.SetAcid(info.accid) EntityFactory.SetHeroAppearance_ID(info.heroAppearanceId) -- 设置时装 ,这个 appearanceId 和 heroAppearanceId 是有区别的:临时变装、时装; 千万注意别搞错了。 EntityFactory.SetWeaponAppearance_ID(info.weaponAppearanceId) EntityFactory.SetDyeAppearanceList(info.mainDyeCurPartList) EntityFactory.SetParams("ForceVisualPriority", -1)--不做裁剪 EntityFactory.SetParams("IsStatue", true)--设置为雕像 EntityFactory.SetParams("ExpModelScaleRate", defaultSize)--设置为雕像大小系数 local entity = EntityFactory.DoCreateEntity() --去(停)掉动作,设置替换优先级 SystemManager.OnAddTimeScale(entity, "statue", 0, -1, LuaConst.TimeScaleBreakType.NeverBreak, LuaConst.ETimeScaleChannel.SKILL_ANIM_SOUND_ENTITY_POS_ROT) SystemManager.AddBuff(entity, 100043)--不与他人发生挤压 SystemManager.AddBuff(entity, 100044)--子弹打不到 SystemManager.OnConvey(entity, posV2, dirV2, true, nil, true) self.jobId2StatueEntityDic[countryJobId] = entity end else logging.error(LTAG.ERROR, "HYW : battleStatueInfoList nil ERROR!") end end function SyncCityWarMainSecondStageLevelFunction:CreatePlayerStatistic(playerID) Base.CreatePlayerStatistic(self, playerID) if self.preBattleResults then local acid = LevelPlayerManager.GetPlayerInfoByPlayerIDInRoom(playerID).acid for i,preBattleResult in ipairs(self.preBattleResults) do if acid == preBattleResult.playerAcid then local playerStatistic = self.PlayerStatisticDic[playerID] playerStatistic[LuaConst.EStatisticType.FirstStageKillScore] = SyncCityWarMainFirstStageLevelFunction.GetKillScore(preBattleResult.killNum or 0) playerStatistic[LuaConst.EStatisticType.FirstStageAssistScore] = SyncCityWarMainFirstStageLevelFunction.GetAssistScore(preBattleResult.assistNum or 0) if preBattleResult.totalContribute then playerStatistic[EStatisticType.FirstStageOtherScore] = preBattleResult.totalContribute - playerStatistic[EStatisticType.FirstStageKillScore] - playerStatistic[EStatisticType.FirstStageAssistScore] else playerStatistic[EStatisticType.FirstStageOtherScore] = 0 end break end -- // 上一场战斗的战斗结果 -- message PreBattleResult { -- required uint32 playerID = 1; -- required string playerAcid = 2; -- optional uint32 killNum = 3; // 击杀数 -- optional uint32 assistNum = 4;// 助攻数 -- // 物资贡献 -- optional uint32 goodsContribute = 5; -- // 总贡献 -- optional uint32 totalContribute = 6; -- // 是否是防守方 -- optional bool isDefend = 7; -- } end end end function SyncCityWarMainSecondStageLevelFunction:BeginLevel() Base.BeginLevel(self) local serverBattleTime = LevelManager.GetBattleTime() if serverBattleTime then LevelItemManager.Global:SetRemainTime(serverBattleTime) end end function SyncCityWarMainSecondStageLevelFunction:OnEntityBorn(entity) Base.OnEntityBorn(self, entity) if entity.featureID == STATUE_KING_FEATURE_ID then self.kingStatueEntity = entity local monsterHpInfos = LevelManager.GetMonsterHpInfos() for i,monsterHpInfo in ipairs(monsterHpInfos) do if monsterHpInfo.monsterId == 1 then local hp = FP.newV1(monsterHpInfo.hp) hp:Mul(SiegeCityMBFBossClientBloodRate) entity:SetAttrBaseValue(LuaConst.AttrType.hplmt, hp) entity:SetAttrBaseValue(LuaConst.RealtimeAttrType.hp, hp) break end end self.statueBaseEntityIDList[#self.statueBaseEntityIDList + 1] = entity.EntityID if #self.statueBaseEntityIDList == 3 then self:CreateStatues() end elseif entity.featureID == STATUE_SIKONG_FEATURE_ID then self.sikongStatueEntity = entity local monsterHpInfos = LevelManager.GetMonsterHpInfos() for i,monsterHpInfo in ipairs(monsterHpInfos) do if monsterHpInfo.monsterId == 3 then local hp = FP.newV1(monsterHpInfo.hp) hp:Mul(SiegeCityMBFBossClientBloodRate) entity:SetAttrBaseValue(LuaConst.AttrType.hplmt, hp) entity:SetAttrBaseValue(LuaConst.RealtimeAttrType.hp, hp) break end end self.statueBaseEntityIDList[#self.statueBaseEntityIDList + 1] = entity.EntityID if #self.statueBaseEntityIDList == 3 then self:CreateStatues() end elseif entity.featureID == STATUE_SIMA_FEATURE_ID then self.simaStatueEntity = entity local monsterHpInfos = LevelManager.GetMonsterHpInfos() for i,monsterHpInfo in ipairs(monsterHpInfos) do if monsterHpInfo.monsterId == 2 then local hp = FP.newV1(monsterHpInfo.hp) hp:Mul(SiegeCityMBFBossClientBloodRate) entity:SetAttrBaseValue(LuaConst.AttrType.hplmt, hp) entity:SetAttrBaseValue(LuaConst.RealtimeAttrType.hp, hp) break end end self.statueBaseEntityIDList[#self.statueBaseEntityIDList + 1] = entity.EntityID if #self.statueBaseEntityIDList == 3 then self:CreateStatues() end end end function SyncCityWarMainSecondStageLevelFunction:OnEntityDead(entity) Base.OnEntityDead(self, entity) if entity.featureID == STATUE_SIKONG_FEATURE_ID then if self.jobId2StatueEntityDic[11] then SystemManager.DeadQuit(self.jobId2StatueEntityDic[11]) end elseif entity.featureID == STATUE_SIMA_FEATURE_ID then if self.jobId2StatueEntityDic[12] then SystemManager.DeadQuit(self.jobId2StatueEntityDic[12]) end end end function SyncCityWarMainSecondStageLevelFunction:OnHpChange(entity, caster, delta, op, realDelta) Base.OnHpChange(self, entity, caster, delta, op, realDelta) if op == "sub" and realDelta < FP.Const.Zero then if entity.featureID == STATUE_KING_FEATURE_ID then self.statue1HpLoss:Sub(realDelta) elseif entity.featureID == STATUE_SIKONG_FEATURE_ID then self.statue2HpLoss:Sub(realDelta) elseif entity.featureID == STATUE_SIMA_FEATURE_ID then self.statue3HpLoss:Sub(realDelta) end end end function SyncCityWarMainSecondStageLevelFunction:GetPlayerScoreInfo(playerID) local playerStatistic = self.PlayerStatisticDic[playerID] if playerStatistic then local playerInfo = LevelPlayerManager.GetPlayerInfoByPlayerIDInRoom(playerID) local info = {} local killNum = playerStatistic[EStatisticType.HeroKillNum] local assistNum = playerStatistic[EStatisticType.AssistHeroKillNum] info.killScore = killNum * SiegeCityFinalBattleKillPoint + playerStatistic[EStatisticType.FirstStageKillScore] info.assistScore = assistNum * SiegeCityFinalBattleAssistPoint + playerStatistic[EStatisticType.FirstStageAssistScore] info.otherScore = playerStatistic[EStatisticType.FirstStageOtherScore] info.playerInfo = playerInfo return info end end function SyncCityWarMainSecondStageLevelFunction:GetResultPlayerScoreInfo(playerID) local playerStatistic = self.PlayerStatisticDic[playerID] if playerStatistic then local playerInfo = LevelPlayerManager.GetPlayerInfoByPlayerIDInRoom(playerID) local info = {} local killNum = playerStatistic[EStatisticType.HeroKillNum] local assistNum = playerStatistic[EStatisticType.AssistHeroKillNum] info.killScore = killNum * SiegeCityFinalBattleKillPoint info.assistScore = assistNum * SiegeCityFinalBattleAssistPoint info.otherScore = 0 info.playerInfo = playerInfo return info end end function SyncCityWarMainSecondStageLevelFunction:GetStatueHpLossListPbBytes() local msg = siege_city_battlecheck_pb.SiegeCityStatueHpList() local hpState = siege_city_battlecheck_pb.SiegeCityStatueHp() hpState.id = 1 hpState.statueHp = tonumberV1(self.statue1HpLoss) table.insert(msg.hpStateList, hpState) hpState = siege_city_battlecheck_pb.SiegeCityStatueHp() hpState.id = 2 hpState.statueHp = tonumberV1(self.statue2HpLoss) table.insert(msg.hpStateList, hpState) hpState = siege_city_battlecheck_pb.SiegeCityStatueHp() hpState.id = 3 hpState.statueHp = tonumberV1(self.statue3HpLoss) table.insert(msg.hpStateList, hpState) return msg:SerializeToString() end return SyncCityWarMainSecondStageLevelFunction