local Base = require("Battle/Logic/AI/Decision/Decision_Base") local Decision_MultiBossChangeTarget = class("Decision_MultiBossChangeTarget", Base) --[[ 初始化 --]] function Decision_MultiBossChangeTarget:initialize(entity) --类型 self.Type = LuaConst.DecisionType.MultiBossChangeTarget --瞬时 self.IsOnce = true end --[[ 输出指令 --]] function Decision_MultiBossChangeTarget:SetCommand(entity, decisionData, command) command.DecisionID = decisionData.ID return command end --[[ 执行 --]] function Decision_MultiBossChangeTarget:Handle(entity, decisionData, stateType, animName) if entity.components.target.Target == nil or not entity.components.target.Target:IsAlive() or not entity.components.target.Target:IsActive() then local bossPriority = LevelManager.CurLevelFunc:GetBossPriority(entity.EntityID) if bossPriority > 0 then local heroEntities = LevelPlayerManager.GetPlayerEntitysByPlayerIDInRoom(1) if heroEntities then if bossPriority == 1 then --第一顺位Boss,是主boss,锁定玩家操作的目标 SystemManager.SetTarget(entity, heroEntities[1]) else --后续顺位Boss,优先按照自己的顺位选择锁定目标,如果自己顺位没有对应目标,就从最低顺位开始找第一个活着且激活的目标 local heroCount = #heroEntities local hero = heroEntities[bossPriority] if hero and hero:IsAlive() and hero:IsActive() then SystemManager.SetTarget(entity, hero) else for i=heroCount,1,-1 do hero = heroEntities[i] if hero:IsAlive() and hero:IsActive() then SystemManager.SetTarget(entity, hero) break end end end end end end end return LuaConst.StateType.None,nil end return Decision_MultiBossChangeTarget