local ExpUISystem = require "Battle/Expression/ExpEntity/System/ExpUISystem" local FirstPersonEventDispatcher = require"Battle/Logic/Event/FirstPersonEventDispatcher" local Base = require("Battle/Expression/ExpLevel/ExpLevelFunction/ExpSyncLevelFunction") local ExpSyncWorldBossLevelFunction = class("ExpSyncWorldBossLevelFunction",Base) local EStatisticType = LuaConst.EStatisticType local EventSystem = require('Event/EventSystem') local private = { isArrowInited = false, } local IgnoreBossWhenNoRewardChanceBuffID = LuaConst.SpecialBuffs.IgnoreBoss local BOSS_ARROW_PATH = ConstAssetPathConfig.BOSS_ARROW_PATH local FORCE_PLAYER_ARROW_PATH = ConstAssetPathConfig.FORCE_PLAYER_ARROW_PATH local TEAMMATE_ARROW_PATH = ConstAssetPathConfig.TEAMMATE_ARROW_PATH local CIRCLE_PATH = ConstAssetPathConfig.CIRCLE_PATH function ExpSyncWorldBossLevelFunction:OnInitLevel() Base.OnInitLevel(self) private.isArrowInited = false self.circleEffects = {} end function ExpSyncWorldBossLevelFunction:View_InitArrowView(entityTable) if not LogicUpdateManager.IsInReconnectFastPlay() then if entityTable then private.isArrowInited = true private.arrowGroupDic = {} private.bossList = {} for k,v in pairs(LogicUpdateManager._entityDic) do if v:IsBoss() then table.insert(private.bossList,v) end end self:SetBossLockVisible(true) local arrowGroup for i,entity in ipairs(entityTable) do arrowGroup = {} local expEntity = entity.ExpEntity local parent = expEntity.RenderEntity.Transform local layer = expEntity.components.model.Layer table.insert(self.circleEffects, AuxUtil.PlayDynamicObject(CIRCLE_PATH, -1, parent, layer)) if private.ShouldShowBossArrow then arrowGroup.bossArrows = {} for i=1,#private.bossList do arrowGroup.bossArrows[i] = AuxUtil.PlayDynamicObject(BOSS_ARROW_PATH, -1, parent, layer) end end if private.ShouldShowForcePlayerArrow then arrowGroup.targetPlayerArrows = {} arrowGroup.targetPlayerArrow = AuxUtil.PlayDynamicObject(FORCE_PLAYER_ARROW_PATH, -1, parent, layer) AuxUtil.SetDynamicObjectScale(arrowGroup.targetPlayerArrow,0.001,0.001,0.001) arrowGroup.targetPlayerArrows[1] = arrowGroup.targetPlayerArrow end private.arrowGroupDic[entity.EntityID] = arrowGroup end end end end function ExpSyncWorldBossLevelFunction:SetBossLockVisible(isVisible) if private.bossList then for i,bossEntity in ipairs(private.bossList) do self:SetTargetEffectOfEntity(bossEntity,isVisible) end end end local _tempVec2 = FP.newV2(0,0) function ExpSyncWorldBossLevelFunction:GetRotYTowardsTarget(entity,target) _tempVec2:Reset(target:GetLogicPos()) _tempVec2:Sub(entity:GetLogicPos()) return FP.V2.AngleToRight360(_tempVec2):Negative():Sub(90) end function ExpSyncWorldBossLevelFunction:GetMyForceTeamId() return self.levelFunction:GetForceTeamId(LevelPlayerManager.MyPlayerIDInRoom) end function ExpSyncWorldBossLevelFunction:SetModelUIImageColorOfPlayerEntities(playerID, campID, entities) if LogicUpdateManager._curEntity and LogicUpdateManager._curEntity:GetPlayerID() ~= playerID and CampManager.IsEnemyCamp(campID, LogicUpdateManager._curEntity:GetCampID()) then ExpUISystem.RefreshEnemyModelUINameColor(LogicUpdateManager._curEntity) end end function ExpSyncWorldBossLevelFunction:Update() if self.levelFunction.HadStopLevel then return end Base.Update(self) if private.isArrowInited then if LogicUpdateManager._curEntity then local entityRotY = LogicUpdateManager._curEntity.ExpEntity:GetEulerAngleY() local arrowGroup = private.arrowGroupDic[LogicUpdateManager._curEntity.EntityID] if arrowGroup then if private.ShouldShowBossArrow then for i,bossEntity in ipairs(private.bossList) do if bossEntity:IsAlive() then local angle = self:GetRotYTowardsTarget(LogicUpdateManager._curEntity,bossEntity) angle:Sub(entityRotY) AuxUtil.SetDynamicObjectScale(arrowGroup.bossArrows[i], 1,1,1) AuxUtil.SetDynamicObjectRotationY(arrowGroup.bossArrows[i], FP.tonumberV1(angle)) else AuxUtil.SetDynamicObjectScale(arrowGroup.bossArrows[i], 0.001,0.001,0.001) end end end if private.ShouldShowForcePlayerArrow then if LogicUpdateManager._curEntity:GetFightMode() ~= LuaConst.EFightMode.PEACE then -- new↓ 显示多个箭头 local targetEntities = LevelPlayerManager.GetAliveAndActiveEntitiesOfTeam(LogicUpdateManager._curEntity.components.target.forceTeamID) for i,arrow in ipairs(arrowGroup.targetPlayerArrows) do AuxUtil.SetDynamicObjectScale(arrow, 0.001, 0.001, 0.001) end local arrow = nil for i,targetEntity in ipairs(targetEntities) do arrow = arrowGroup.targetPlayerArrows[i] if not arrow then local expEntity = LogicUpdateManager._curEntity.ExpEntity arrow = AuxUtil.PlayDynamicObject(FORCE_PLAYER_ARROW_PATH, -1, expEntity.RenderEntity._entityTransform, expEntity.components.model.Layer) arrowGroup.targetPlayerArrows[i] = arrow end local angle = self:GetRotYTowardsTarget(LogicUpdateManager._curEntity, targetEntity) angle:Sub(entityRotY) AuxUtil.SetDynamicObjectScale(arrow, 1, 1, 1) AuxUtil.SetDynamicObjectRotationY(arrow, FP.tonumberV1(angle)) end -- new↑ end end end -- if private.ShouldShowTeammateArrow then -- AuxUtil.SetDynamicObjectRotationY(arrowGroup.teammateArrow1,-entityRotY + 60) -- end end elseif self.isBossBorn then self:View_InitArrowView(LevelPlayerManager.GetPlayerEntitysByPlayerIDInRoom(LevelPlayerManager.MyPlayerIDInRoom)) end end function ExpSyncWorldBossLevelFunction:OnBossBorn(entity) self.isBossBorn = true end function ExpSyncWorldBossLevelFunction:OnHandleHeroDead(killer, deadEntity, involveKillPlayerIDList, assistHeroEntityIDList, kStatistic) -- 不调用base --世界boss、战区boss视图层不再有助攻的概念 --世界boss、战区boss视图层的斩杀概念 = 逻辑层参与击杀数 local entity local statistic for i,playerID in ipairs(involveKillPlayerIDList) do entity = LevelPlayerManager.GetPlayerActiveEntity(playerID) if entity then statistic = self.levelFunction.PlayerStatisticDic[playerID] if statistic then EventSystem.Dispatch(EventID.Level_UpdateKillHeroNum, entity, statistic and statistic[EStatisticType.InvolvedHeroKillNum]) --显示 n 斩 end if entity:IsPlayerSelf() then EventSystem.Dispatch(EventID.UI_WorldBoss_Kill, deadEntity) -- 显示tips end local playerInfo = LevelPlayerManager.GetPlayerInfoByPlayerIDInRoom(entity:GetPlayerID()) if playerInfo then if self.levelFunction:IsAssitant(playerInfo) then --FirstPersonEventDispatcher.OnAssistantKill(playerInfo) --这个不能主视角了,要全部都抛 EventSystem.Dispatch(EventID.UI_WorldBoss_My_Assistant_Kill, playerInfo) end --else --正常现象,Killer不一定是玩家 end end end end function ExpSyncWorldBossLevelFunction:OnCreatePlayerEntitys(worldBossData) if worldBossData then private.ShouldShowBossArrow = worldBossData.BossArrow private.ShouldShowForcePlayerArrow = worldBossData.EnemyArrow private.ShouldShowTeammateArrow = worldBossData.TeammateArrow else if not LevelManager.IsMonsterTest() then logging.error(LTAG.ERROR, "HYW : 错误!!worldBossData为空!!!") end end end function ExpSyncWorldBossLevelFunction:OnSetPlayerActive(playerID) Base.OnSetPlayerActive(self, playerID) local playerInfo = LevelPlayerManager.GetPlayerInfoByPlayerIDInRoom(playerID) self:RefreshHelpIcon(playerID, playerInfo) local entity = LevelPlayerManager.GetPlayerActiveEntity(playerID) --EventSystem.Dispatch(EventID.UI_ShowRivalEffect, playerID, entity) self:ShowRivalEffect(playerID, entity) end function ExpSyncWorldBossLevelFunction:OnSwitchHero(fromEntity, toEntity) Base.OnSwitchHero(self, fromEntity, toEntity) self:RefreshHelpIcon(toEntity:GetPlayerID()) --EventSystem.Dispatch(EventID.UI_ShowRivalEffect,toEntity:GetPlayerID(), toEntity) self:ShowRivalEffect(toEntity:GetPlayerID(), toEntity) end function ExpSyncWorldBossLevelFunction:RefreshHelpIcon(playerID, playerInfo) playerInfo = playerInfo or LevelPlayerManager.GetPlayerInfoByPlayerIDInRoom(playerID) local isAssistant = self.levelFunction:IsAssitant(playerInfo) local entityTable = LevelPlayerManager.GetPlayerEntitysByPlayerIDInRoom(playerID) if entityTable then for i,entity in ipairs(entityTable) do entity.ExpEntity:SetModelHelpIconVisible(isAssistant) end end end function ExpSyncWorldBossLevelFunction:OnFightModeChanged(entity, fightMode) local damageRecord = self.levelFunction:GetDamageRecord(entity:GetTeamID()) if damageRecord then if fightMode == LuaConst.EFightMode.PEACE then if entity:IsPlayerSelf() then if private.isArrowInited then if private.ShouldShowForcePlayerArrow then AuxUtil.SetDynamicObjectScale(private.arrowGroupDic[entity.EntityID].targetPlayerArrow,0.001,0.001,0.001) end end self:SetTargetEffectByTeamID(entity.components.target.oldForceTeamID, false) self:SetBossLockVisible(true) end end end end function ExpSyncWorldBossLevelFunction:OnSwitchForceTeamByIndex(isSet, entity, oldTargetDmgRecord, targetDmgRecord) if isSet then if entity:IsPlayerSelf() then if private.isArrowInited then if private.ShouldShowForcePlayerArrow then AuxUtil.SetDynamicObjectScale(private.arrowGroupDic[entity.EntityID].targetPlayerArrow,1,1,1) end end self:SetBossLockVisible(false) end else if entity:IsPlayerSelf() then if private.isArrowInited then if private.ShouldShowForcePlayerArrow then AuxUtil.SetDynamicObjectScale(private.arrowGroupDic[entity.EntityID].targetPlayerArrow,0.001,0.001,0.001) end end self:SetBossLockVisible(true) end end if entity:IsPlayerSelf() then self:SetTargetEffectByTeamID(targetDmgRecord.teamId, isSet) if oldTargetDmgRecord and (oldTargetDmgRecord.teamId ~= targetDmgRecord.teamId or (not isSet)) then self:SetTargetEffectByTeamID(oldTargetDmgRecord.teamId, false) end end end function ExpSyncWorldBossLevelFunction:SetTargetEffectByTeamID(teamId, isVisible) local playerIDList = LevelPlayerManager.GetPlayerIDListOfTeam(teamId) if playerIDList then for i,playerID in ipairs(playerIDList) do self:SetTargetEffectByPlayerID(playerID, isVisible) end end end function ExpSyncWorldBossLevelFunction:OnTeamQuitRoom(teamId) if self:GetMyForceTeamId() == teamId then local entityTable = LevelPlayerManager.GetPlayerEntitysByPlayerIDInRoom(LevelPlayerManager.MyPlayerIDInRoom) for i,v in ipairs(entityTable) do AuxUtil.SetDynamicObjectScale(private.arrowGroupDic[v.EntityID].targetPlayerArrow,0.001,0.001,0.001) end self:SetBossLockVisible(true) end end function ExpSyncWorldBossLevelFunction:RefreshNo1Icon(damageList) local damageRecord = damageList[1] if damageRecord then local isShow = damageRecord.damage > FP.Const.Zero local firstEntityList = LevelPlayerManager.GetAliveAndActiveEntitiesOfTeam(damageRecord.teamId) for _,entity in ipairs(firstEntityList) do if not entity:HasBuff(IgnoreBossWhenNoRewardChanceBuffID) then entity.ExpEntity:SetModelNo1IconVisible(isShow) end end for i=2,#damageList do local otherEntityList = damageList[i].entityList for i,entity in ipairs(otherEntityList) do entity.ExpEntity:SetModelNo1IconVisible(false) end end end end -- 追帧完毕 function ExpSyncWorldBossLevelFunction:OnFastPlayOver() Base.OnFastPlayOver(self) -- 刷新特效: 仇敌 for i,playerID in ipairs(LevelPlayerManager.SyncPlayerIDList) do local entity = LevelPlayerManager.GetPlayerActiveEntity(playerID) --EventSystem.Dispatch(EventID.UI_ShowRivalEffect, playerID, entity) self:ShowRivalEffect(playerID, entity) end end function ExpSyncWorldBossLevelFunction:OnStopLevel() Base.OnStopLevel(self) for i,circleEffect in ipairs(self.circleEffects) do AuxUtil.StopDynamicObject(circleEffect) end if private.arrowGroupDic then for k,arrowGroup in pairs(private.arrowGroupDic) do if arrowGroup.targetPlayerArrows then for i,arrow in ipairs(arrowGroup.targetPlayerArrows) do AuxUtil.StopDynamicObject(arrow) end end if arrowGroup.bossArrows then for i,arrow in ipairs(arrowGroup.bossArrows) do AuxUtil.StopDynamicObject(arrow) end end end end end return ExpSyncWorldBossLevelFunction