local Base = require("Battle/Expression/ExpLevel/ExpLevelFunction/ExpSyncWorldBossLevelFunction") local EventSystem = require('Event/EventSystem') local IgnoreBossWhenNoRewardChanceBuffID = LuaConst.SpecialBuffs.IgnoreBoss --LevelFunction的视图代码 local ExpSyncWarZoneWorldBossLevelFunction = class("ExpSyncWarZoneWorldBossLevelFunction", Base) local STANDARD_OCCUPIER_EFF_SCALE = 0.01 local STANDARD_OCCUPIER_EFF_HEIGHT = 4 function ExpSyncWarZoneWorldBossLevelFunction:Update() Base.Update(self) if self.showingOccupyEntity and self.showingOccupyEntity ~= LogicUpdateManager._curEntity then self:RefreshOccupierEffect(self.showingOccupyEntity) end end function ExpSyncWarZoneWorldBossLevelFunction:OnOccupierChanged(oldPlayerID, newPlayerID) if oldPlayerID then local entity = LevelPlayerManager.GetPlayerActiveEntity(oldPlayerID) if entity then entity.ExpEntity:StopEffectByType(LuaConst.EffectType.Occupier) entity.ExpEntity:StopEffectByType(LuaConst.EffectType.OccupierFoot) self.showingOccupyEntity = nil if self.waitingShowRivalPlayerID then local entity = LevelPlayerManager.GetPlayerActiveEntity(self.waitingShowRivalPlayerID) if entity then self:ShowRivalEffect(self.waitingShowRivalPlayerID, entity) end self.waitingShowRivalPlayerID = nil end end end if newPlayerID then local entity = LevelPlayerManager.GetPlayerActiveEntity(newPlayerID) if entity then entity.ExpEntity:PlayEffectByType(LuaConst.EffectType.Occupier) entity.ExpEntity:PlayEffectByType(LuaConst.EffectType.OccupierFoot) --↓ 因为特效给的是UI特效想加在头顶血条上,但头顶血条拓展需要改c#,所以无法加头顶血条,只能作为3d特效显示,所以这里要手动调整高度和尺寸↓ if LogicUpdateManager._curEntity == entity then entity.ExpEntity:SetEffectPosByType(LuaConst.EffectType.Occupier, 0, STANDARD_OCCUPIER_EFF_HEIGHT, 0) entity.ExpEntity:SetEffectScaleByType(LuaConst.EffectType.Occupier, STANDARD_OCCUPIER_EFF_SCALE, STANDARD_OCCUPIER_EFF_SCALE, STANDARD_OCCUPIER_EFF_SCALE) else self:RefreshOccupierEffect(entity) end self.showingOccupyEntity = entity end end end function ExpSyncWarZoneWorldBossLevelFunction:ShowRivalEffect(playerID, entity) if entity then if self.showingOccupyEntity == nil or entity ~= self.showingOccupyEntity then Base.ShowRivalEffect(self, playerID, entity) else -- entity是当前占领者,不立刻显示仇敌特效 但加入等待(同一时间只可能有一个占领者,所以只需要存1个等待playerID) self.waitingShowRivalPlayerID = playerID end end end function ExpSyncWarZoneWorldBossLevelFunction:RefreshOccupierEffect(entity) if entity then if LogicUpdateManager._curEntity then if Camera.main then local cameraPosX, cameraPosY, cameraPosZ = Camera.main.transform:GetPosition() if not self.camToMainDist then local mainPosX, mainPosY, mainPosZ = LogicUpdateManager._curEntity.ExpEntity.RenderEntity.Transform:GetPosition() local camToMainDistX = cameraPosX - mainPosX local camToMainDistY = cameraPosY - mainPosY local camToMainDistZ = cameraPosZ - mainPosZ self.camToMainDist = math.sqrt(camToMainDistX * camToMainDistX + camToMainDistY * camToMainDistY + camToMainDistZ * camToMainDistZ) end local occupierPosX, occupierPosY, occupierPosZ = entity.ExpEntity.RenderEntity.Transform:GetPosition() local camToOccupierDistX = cameraPosX - occupierPosX local camToOccupierDistY = cameraPosY - occupierPosY local camToOccupierDistZ = cameraPosZ - occupierPosZ local camToOccupierDist = math.sqrt(camToOccupierDistX * camToOccupierDistX + camToOccupierDistY * camToOccupierDistY + camToOccupierDistZ * camToOccupierDistZ) local effectHeight = STANDARD_OCCUPIER_EFF_HEIGHT * math.sqrt(camToOccupierDist / self.camToMainDist) entity.ExpEntity:SetEffectPosByType(LuaConst.EffectType.Occupier, 0, effectHeight, 0) local effectScale = STANDARD_OCCUPIER_EFF_SCALE * camToOccupierDist / self.camToMainDist entity.ExpEntity:SetEffectScaleByType(LuaConst.EffectType.Occupier, effectScale, effectScale, effectScale) end end entity.ExpEntity:SetModelRivalVisible(false) end end function ExpSyncWarZoneWorldBossLevelFunction:RefreshNo1Icon() local rankList = self.levelFunction.occupyRankList local rank = rankList[1] if rank then local occupierID = self.levelFunction:GetCurOccupierPlayerID() local occupierCamp if occupierID then local occupierInfo = LevelPlayerManager.GetPlayerInfoByPlayerIDInRoom(occupierID) if occupierInfo then occupierCamp = occupierInfo.campID end end local firstEntityList = LevelPlayerManager.GetAliveAndActiveEntitiesOfTeam(rank.teamId) for _,entity in ipairs(firstEntityList) do if not entity:HasBuff(IgnoreBossWhenNoRewardChanceBuffID) then entity.ExpEntity:SetModelNo1IconVisible(entity:GetCampID() == occupierCamp) end end for i=2,#rankList do for j,record in ipairs(rankList[i].teamRecordList) do local otherEntityList = LevelPlayerManager.GetPlayerEntitysByPlayerIDInRoom(record.playerID) for m,entity in ipairs(otherEntityList) do entity.ExpEntity:SetModelNo1IconVisible(entity:GetCampID() == occupierCamp) end end end end end function ExpSyncWarZoneWorldBossLevelFunction:HideNo1IconOfTeam(teamId) local firstEntityList = LevelPlayerManager.GetAliveAndActiveEntitiesOfTeam(teamId) if firstEntityList then for i,entity in ipairs(firstEntityList) do entity.ExpEntity:SetModelNo1IconVisible(false) end end end function ExpSyncWarZoneWorldBossLevelFunction:OnSwitchHero(fromEntity, toEntity) Base.OnSwitchHero(self, fromEntity, toEntity) if #self.levelFunction.occupyRankList > 0 then if not toEntity:HasBuff(IgnoreBossWhenNoRewardChanceBuffID) then if toEntity:GetTeamID() == self.levelFunction.occupyRankList[1].teamId then toEntity.ExpEntity:SetModelNo1IconVisible(true) end end end end return ExpSyncWarZoneWorldBossLevelFunction