local UIBattleMultiBossPanel = UIViewClass() -- 从 UIBattleLevelPanel 分离出来的界面 local DISTANCE_AM_BREAK_SQR = 900 --显示破甲特效的距离 local BOSS_LIFE_BAR_STRIDE = -100 local DISTANCE_IN_TARGET = 35*35 -- 和 ExpUISystem 一样 local DISTANCE_OUT_TARGET = 60*60 -- 和 ExpUISystem 一样 function UIBattleMultiBossPanel:OnCreated() self.bossLifeBarDic = {} self.bossLifeBarList = {} -- 隐藏和显示的所有bossUI self.activeUIBossEntityIDList = {} -- 所显示的boss条的 boss的 EntityID end function UIBattleMultiBossPanel:OnOpened() self:RegistSystemEvent(EventID.UIBattle_Level_OnBossBorn, self.OnBossBorn) self:RegistSystemEvent(EventID.UIBattle_Level_OnBossListChanged, self.OnBossListChanged) self:RegistSystemEvent(EventID.Camera_TargetChange, self.SetCameraTarget) self:RegistSystemEvent(EventID.UIBattle_BossAMChanged, self.OnAMChanged) self:StartRepeatFunc(self.OnUpdateFun, 1) self:SetPushStyle(LuaConst.PushStyleEnum.HIDE) local entityDic = BattleDataGetter.GetEntityDic() for i,entity in pairs(entityDic) do if entity:IsBoss() then self:OnBossBorn(entity) end end end function UIBattleMultiBossPanel:OnUpdateFun(deltaTime, timeSinceUpdate) --组队副本得减去前置关卡的耗时 local mainEntityPos = BattleDataGetter.GetMainEntityLogicPos() if mainEntityPos then local bossList = BattleDataGetter.GetBossList() local changed = false for i,bossEntity in ipairs(bossList) do local bossEntityID = bossEntity.EntityID local distanceSqr = FP.tonumberV1(mainEntityPos:DistanceSqr(bossEntity:GetLogicPos())) if distanceSqr <= DISTANCE_IN_TARGET then if not table.containValue(self.activeUIBossEntityIDList, bossEntityID) then table.insert(self.activeUIBossEntityIDList, bossEntityID) local view = self.bossLifeBarDic[bossEntityID] if view then view:ActiveUI() else logging.error(LTAG.ERROR , " [gws]: 显示bossUI时发现它找不到了 :", bossEntityID) end changed = true end elseif distanceSqr > DISTANCE_OUT_TARGET then if table.containValue(self.activeUIBossEntityIDList, bossEntityID) then table.removebyvalue(self.activeUIBossEntityIDList, bossEntityID) local view = self.bossLifeBarDic[bossEntityID] if view then view:HideUI() else logging.error(LTAG.ERROR , " [gws]: 隐藏bossUI时发现它找不到了 :", bossEntityID) end changed = true end end end if changed then self:RefreshLayoutUI() end end end function UIBattleMultiBossPanel:CreateBossLifeBar(entityID) local view = self.canvas_BossInfo:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIBattleBossBattleInfoView), {entityID = entityID}) view:HideUI() self.bossLifeBarDic[entityID] = view table.insert(self.bossLifeBarList,view) return view end --region --*************** 关卡boss信息 ***************-- function UIBattleMultiBossPanel:OnBossBorn(entity) local entityID = entity.EntityID self:CreateBossLifeBar(entityID) end -- boss 死亡 function UIBattleMultiBossPanel:OnBossListChanged(entity, isDead) if isDead then local view = self.bossLifeBarDic[entity.EntityID] if view then table.removebyvalue(self.bossLifeBarList, view) self.bossLifeBarDic[entity.EntityID] = nil view:CloseView() if table.containValue(self.activeUIBossEntityIDList, entity.EntityID) then table.removebyvalue(self.activeUIBossEntityIDList, entity.EntityID) self:RefreshLayoutUI() end end end end --endregion 关卡boss信息 function UIBattleMultiBossPanel:OnAMChanged(am, maxAm, lastAm, entity) if am <= 0 and #self.activeUIBossEntityIDList == 1 then -- 只有一个boss的时候才播放特效 --破甲特效放在这里了。策划新需求是得判断距离。 local mainEntityPos = BattleDataGetter.GetMainEntityLogicPos() if mainEntityPos then if FP.tonumberV1(mainEntityPos:DistanceSqr(entity:GetLogicPos())) < DISTANCE_AM_BREAK_SQR then SystemManager.ShowPSEffect(entity, ConstAssetPathConfig.RelativeEffect.Func_BossWeak_Relative) end end end end function UIBattleMultiBossPanel:RefreshLayoutUI() local tooOften = self.lastSelectEntityTime and (UTL.Time.GetServerTimestamp() - self.lastSelectEntityTime < 0.2) local selectView = self.curSelectEntityID and self.bossLifeBarDic[self.curSelectEntityID] or nil local count = #self.activeUIBossEntityIDList if count > 1 then local width = count == 3 and 470 or 545 local scale = 0.6 -- 无选中 ,都一样的大小 local startPos = width * scale / 2 - (width * scale * count) / 2 for i =1 ,count do local view = self.bossLifeBarDic[self.activeUIBossEntityIDList[i]] view:SetBossHPBarWidth(width) --local viewTrans = self.activeUIBossEntityIDList[i].gameObject.transform self:SetBossHpUIPosAndScale(view, startPos, scale, tooOften) startPos = startPos + scale * width end elseif count > 0 then local view = self.bossLifeBarDic[self.activeUIBossEntityIDList[1]] view:SetBossHPBarWidth(620) view.gameObject.transform:SetLocalPosition(0, 0, 0) view.gameObject.transform:SetLocalScale(1, 1, 1) end end function UIBattleMultiBossPanel:SetCameraTarget(entityID) self.curSelectEntityID = entityID self:RefreshLayoutUI() self.lastSelectEntityTime = UTL.Time.GetServerTimestamp() end function UIBattleMultiBossPanel:SetBossHpUIPosAndScale(view, posX, scale, tooOften) local y = scale == 1 and 0 or 15 view.gameObject.transform:SetLocalPosition(posX, y, 0) view.gameObject.transform:SetLocalScale(scale, scale, scale) end return UIBattleMultiBossPanel