local UIBattleLevelPanel = UIViewClass() local STRING_PERCENT = "%d/%d" local COMBO_DURATION_TIME = 10 --连击持续时间 local tostring=tostring local string_format=string.format local UIUtils=UIUtils local Const_UI_Lua=Const_UI_Lua local Const_IDS=Const_IDS local math_ceil=math.ceil local DISTANCE_AM_BREAK_SQR = 900 --显示破甲特效的距离 local CheckFrame = 100 local BOSS_LIFE_BAR_STRIDE = -100 local BOSS_LIFE_BAR_SideScale = 0.6 local RAGE_LEVEL_LOW = 1 --狂暴初级 local RAGE_LEVEL_MIDDLE = 2 --狂暴中级 local RAGE_LEVEL_HIGH = 3 --狂暴高级 function UIBattleLevelPanel:OnCreated() self.isBossLifeBarActive = false self.obj_WaveTip = self.obj_WaveTip.gameObject self.bossLifeBarDelayCreateRequestDic = {} self.bossLifeBarDic = {} self.bossLifeBarList = {} self.animationPosHandleDic = {} self.animationScaleHandleDic = {} end function UIBattleLevelPanel:OnOpened() UIUtils.SetActive(self.obj_WaveTip,false) UIUtils.SetActive(self.group_Rampage,false) self:RegistSystemEvent(EventID.UIBattle_Level_UpdateWave, self.UpdateWave) self:RegistSystemEvent(EventID.UIBattle_Level_SetUpBoss, self.SetUpBoss) 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:RegistSystemEvent(EventID.UIBattle_RefereshRampageInClimbTower, self.RefereshRampageInClimbTower) if not BattleDataGetter.IsReplayBattle() and not BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.PersonalBoss) then self.subViewRoot:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIBattleMissionPanel)) end --BattleDataGetter.IsAllHeroJoinBattle()的字面意思感觉跟UIBattleCombo的类型没关系 不知道为啥这么写 关卡继承感觉不太好 我直接根据关卡类型判断了 --后续也根据关卡类型判断吧 if not BattleDataGetter.IsAllHeroJoinBattle() then if BattleDataGetter.IsFourCountry() then self.comboViewRoot:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIBattleCombo), {isShowComboType = LuaConst.ComboType.IsKillHero}) elseif BattleDataGetter.IsCityWarLevel() then self.comboViewRoot:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIBattleCombo), {isShowComboType = LuaConst.ComboType.IsKillHeroAndAssist}) else self.comboViewRoot:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIBattleCombo), {isShowComboType = LuaConst.ComboType.Default}) end end self.progressRoot:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIBattleBossProgress)) --设置按钮 if LevelManager.IsSyncCountryPVPLevel() or not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.SettingBack) or BattleDataGetter.IsReplayBattle() or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncFourCountryChaos) then UIUtils.SetActive(self.event_Setting, false) UIUtils.SetActive(self.btn_Exit, false) else UIUtils.SetActive(self.event_Setting, true) UIUtils.SetActive(self.btn_Exit, true) end -- 设置关卡时间按钮 if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.StormChallenge) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncFourCountryChaos) then UIUtils.SetActive(self.bg1.gameObject, false) else UIUtils.SetActive(self.bg1.gameObject, true) end --缓存狂暴ID数据 self.rageIdList = DataSheetManager.ConstData:GetDataByID("ClimbTowerBossRageIdList").IntListValue self:ShowClimbTowerInfo() if not BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.StormChallenge) and not BattleDataGetter.IsCityWarWaitingLevel() and not BattleDataGetter.IsCityWarLevel() then self:OnUpdateFun() self:StartRepeatFunc(self.OnUpdateFun, 1) end 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 if CTL.MiniMap.IsShowMiniMap() then self.Offset:SetState(1) else self.Offset:SetState(0) end if (GameAppInfo.IsGameStreamerPackage() or GameAppInfo.IsMarketPackage()) and LevelManager.GetCurLevelType() == LuaConst.LevelType.FairNormalPVE then self.subViewRoot:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIPCButton)) end end --region --*************** 关卡波次 ***************-- function UIBattleLevelPanel:UpdateWave(wave,maxWave) if wave == -1 then UIUtils.SetActive(self.obj_WaveTip,false) else UIUtils.SetActive(self.obj_WaveTip,true) self.labLocal_Wave.text = string_format(STRING_PERCENT,wave,maxWave) end end --战斗事件刷新爬塔的狂暴显示,rampageType 狂暴阶段 function UIBattleLevelPanel:RefereshRampageInClimbTower(rampageIds, buffId) if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.ClimbTower) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.NationClimbTower) then UIUtils.SetActive(self.group_Rampage,true) self.rampageIds = rampageIds --狂暴内容Ids self.rampageTipFrame=BattleDataGetter.GetCurFrameIndex() --记录当前帧 --无狂暴时 if buffId==0 then --无狂暴 self.currentRampageLevel= 0 local buffData = DataSheetManager.BuffData:GetDataByBuffID(self.rageIdList[1]) self.remainRampageTime = FP.tonumberV1(buffData.BuffDuration)/1000 --狂暴提示剩余时间 UIUtils.SetLabel(self.txt_Rampage,string.FormatByIdsId(Const_IDS[self.rampageIds],self.remainRampageTime)) else --设置狂暴层级 for k,v in ipairs (self.rageIdList) do if buffId==v then self.currentRampageLevel=k break end end if self.currentRampageLevel == RAGE_LEVEL_LOW or self.currentRampageLevel == RAGE_LEVEL_MIDDLE then --进入初级狂暴 \ 进入中级狂暴 local oldBuffData = DataSheetManager.BuffData:GetDataByBuffID(buffId) local newBuffData =DataSheetManager.BuffData:GetDataByBuffID(self.rageIdList[self.currentRampageLevel+1]) self.remainRampageTime = FP.tonumberV1((newBuffData.BuffDuration- oldBuffData.BuffDuration))/1000 UIUtils.SetLabel(self.txt_Rampage, string.FormatByIdsId(Const_IDS[self.rampageIds],self.remainRampageTime)) else --进入高级狂暴 UIUtils.SetLabelText(self.txt_Rampage,Const_IDS[self.rampageIds]) end end else UIUtils.SetActive(self.group_Rampage,false) end end --爬塔的狂暴定时刷新 function UIBattleLevelPanel:RefereshRampageInClimbTowerTimer() if (BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.ClimbTower) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.NationClimbTower)) and self.currentRampageLevel and self.currentRampageLevel < RAGE_LEVEL_HIGH then local currentFrame=BattleDataGetter.GetCurFrameIndex() local passedSeconds= (currentFrame- self.rampageTipFrame)/LuaConst.LogicFrameRate self.rampageTipFrame = BattleDataGetter.GetCurFrameIndex() self.remainRampageTime = self.remainRampageTime - passedSeconds if self.remainRampageTime < 0 then self.remainRampageTime = 0 end UIUtils.SetLabel(self.txt_Rampage, string.FormatByIdsId(Const_IDS[self.rampageIds],self.remainRampageTime)) end end --爬塔关信息 function UIBattleLevelPanel:ShowClimbTowerInfo() if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.ClimbTower) then --关卡显示 UIUtils.SetActive(self.group_Level,true) local nextConfig= CTL.ClimbTower.GetNextLevelConfig() if nextConfig then UIUtils.SetLabel(self.txt_ClimbTowerLevel, UIUtils.GetLocalizedTxt(Const_IDS[nextConfig.LevelName])) else UIUtils.SetLabel(self.txt_ClimbTowerLevel,"") end --获取战力显示 local currentGS = LevelManager.GetLevelGs() currentGS= CTL.LevelSelect.GetSubjugateGsText(nextConfig.SubjugateDataPVE, currentGS) local gsContent=string.FormatByIdsKey("IDS_NewClimbTower_EnemyPower", currentGS) UIUtils.SetLabel(self.txt_Power, gsContent) elseif BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.NationClimbTower) then --关卡显示 UIUtils.SetActive(self.group_Level,true) local nextConfig = MDL.NationClimbTower.GetNextLevelConfig() if nextConfig then UIUtils.SetLabel(self.txt_ClimbTowerLevel, string.FormatByIdsId(Const_IDS[nextConfig.LevelName], nextConfig.Number)) else UIUtils.SetLabel(self.txt_ClimbTowerLevel,"") end --获取战力显示 local currentGS = LevelManager.GetLevelGs() local levelTowerType = DataSheetManager.NationClimbTowerData:GetDataByID(nextConfig.BelongToChapter).TowerLevelCountry local targetGs = MDL.NationClimbTower.GetLineUpGSTotal(levelTowerType) currentGS= CTL.LevelSelect.GetSubjugateFreeLineGsText(nextConfig.SubjugateDataPVE, targetGs, currentGS) local gsContent=string.FormatByIdsKey("IDS_NewClimbTower_EnemyPower", currentGS) UIUtils.SetLabel(self.txt_Power, gsContent) else UIUtils.SetActive(self.group_Level,false) end end --endregion 关卡波次 function UIBattleLevelPanel:CreateBossLifeBar(entityID) local view = self.canvas_BossInfo:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIBattleBossBattleInfoView), {entityID = entityID}) view.gameObject.transform:SetLocalPosition(0, (BattleDataGetter.GetBossPriority(entityID) - 1) * BOSS_LIFE_BAR_STRIDE,0) self.bossLifeBarDic[entityID] = view table.insert(self.bossLifeBarList,view) self:RefreshLayoutUI() return view end function UIBattleLevelPanel:DealCreateBossLifeBarDelayReq() if self.isBossLifeBarActive then if self.bossLifeBarDelayCreateRequestDic then for entityID,v in pairs(self.bossLifeBarDelayCreateRequestDic) do self.bossLifeBarDelayCreateRequestDic[entityID] = nil self:CreateBossLifeBar(entityID) end end end end --region --*************** 关卡boss信息 ***************-- function UIBattleLevelPanel:OnBossBorn(entity) local entityID = entity.EntityID if self.isBossLifeBarActive then self:CreateBossLifeBar(entityID) else self.bossLifeBarDelayCreateRequestDic[entityID] = true end end function UIBattleLevelPanel:SetUpBoss(active) self.isBossLifeBarActive = active if active then self:DealCreateBossLifeBarDelayReq() for k,v in pairs(self.bossLifeBarDic) do v:ActiveUI({entityID = k}) end else --此处不代表Boss已死,所以只需要HideUI for k,v in pairs(self.bossLifeBarDic) do v:HideUI() end end end function UIBattleLevelPanel:OnBossListChanged(entity) if entity and not self.isBossLifeBarActive then self.bossLifeBarDelayCreateRequestDic[entity.EntityID] = nil end local priority = nil self:DealCreateBossLifeBarDelayReq() local needCloseAllView = true for entityID,view in pairs(self.bossLifeBarDic) do priority = BattleDataGetter.GetBossPriority(entityID) if priority > 0 then -- 只要有一个boss存活,就不关闭所有uiview needCloseAllView = false break end end if needCloseAllView then for i,view in ipairs(self.bossLifeBarList) do view:CloseView() end table.clearArray(self.bossLifeBarList) table.clear(self.bossLifeBarDic) else self:RefreshLayoutUI() end end function UIBattleLevelPanel:OnButtonClicked(comp) if comp == self.btn_Exit then CTL.Setting.BackToTown() elseif comp == self.event_Setting then UIManager.OpenView(Const_UI_Lua.UIEnum.UISettingMainPanel) end end function UIBattleLevelPanel:OnUpdateFun(deltaTime, timeSinceUpdate) --组队副本得减去前置关卡的耗时 local curTimer = BattleDataGetter.GetRemainTime() -- if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncTeamPVE) then -- curTimer = BattleDataGetter.GetRemainTime() - BattleDataGetter.GetPassTimeOfPrevious() -- else -- curTimer = BattleDataGetter.GetRemainTime() -- end UIUtils.SetLabel(self.txt_time, UTL.Time.FormatTimeBySeconds(curTimer)) local floorTimer = math.floor(curTimer) if floorTimer > 0 and floorTimer < 6 then UIUtils.SetActive(self.CountDown, true) self.number.text = floorTimer self.CountDownShowed = true elseif self.CountDownShowed or curTimer <= 0 then UIUtils.SetActive(self.CountDown, false) self.CountDownShowed = false end self:RefereshRampageInClimbTowerTimer() end --endregion 关卡boss信息 function UIBattleLevelPanel:OnAMChanged(am, maxAm, lastAm, entity) if am <= 0 and #self.bossLifeBarList == 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 UIBattleLevelPanel: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.bossLifeBarList 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.bossLifeBarList[i] view:SetBossHPBarWidth(width) --local viewTrans = self.bossLifeBarList[i].gameObject.transform self:SetBossHpUIPosAndScale(view, startPos, scale, tooOften) startPos = startPos + scale * width end elseif count > 0 then local view = self.bossLifeBarList[1] view:SetBossHPBarWidth(620) self.bossLifeBarList[1].gameObject.transform:SetLocalPosition(0, 0, 0) self.bossLifeBarList[1].gameObject.transform:SetLocalScale(1, 1, 1) end end function UIBattleLevelPanel:SetCameraTarget(entityID) self.curSelectEntityID = entityID self:RefreshLayoutUI() self.lastSelectEntityTime = UTL.Time.GetServerTimestamp() end function UIBattleLevelPanel: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 UIBattleLevelPanel