--- 国战晚间BOSS战斗内UI local UICountryNightBossBattleBase = UIViewClass() local EventSystem = require('Event/EventSystem') local UPDATE_CHECK_TIME = 0.3 local FRAME_TIMES_UNIT = LuaConst.TimeSpanMs local MILLION_SECONDS = 1000 local START_WAITING_TIME = 10 local DELAY_QUIT_TIME = DataSheetManager.ConstData:GetDataByID("CountryBossSettlementTime").IntValue local RECRUIT_CD = DataSheetManager.ConstData:GetDataByID("WorldBossSeekHelpCD").IntValue local ICON_BOSS = ConstAssetPathConfig.ICON_BOSS local ICON_WEAK = ConstAssetPathConfig.ICON_WEAK local HIDE_KILL_TIME = 7 local QUEUE_UNIT_COUNT = 3 -- 一组击杀信息的长度 local CountryWorldBossPKModel = { [LuaConst.EFightMode.PEACE] = { constIDS = Const_IDS.IDS_PKMode_Peace, iconName = "sjslzd_icon_heping" }, [LuaConst.EFightMode.TEAM_GUILD] = { constIDS = Const_IDS.IDS_CountryWorldBoss_BattleType, iconName = "zd_icon_gjms" }, } function UICountryNightBossBattleBase:OnOpened(context) self:RegistSystemEvent(EventID.UI_CountryNightBoss_UpdateBossInfo, self.LoadPlayerRank) self:RegistSystemEvent(EventID.UI_CountryNightBoss_UpdateBossInfo, self.UpdateBossInfo) self:RegistSystemEvent(EventID.UI_UpdateBuff_Boss, self.UpdateBuffShow) self:RegistSystemEvent(EventID.UIBattle_BossAMChanged, self.OnAMChanged) self:RegistSystemEvent(EventID.UIBattle_Level_OnBossBorn, self.OnBossBorn) self:RegistSystemEvent(EventID.WorldBoss_PlayerAllHeroBeKilled, self.OnPlayerKill) self.comboViewRoot:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIBattleCombo), {isShowComboType = LuaConst.ComboType.IsKillHeroAndAssist}) self.allHide = true self.hideLoopKill = {} self.isFightEnd = false self.firstCellPosX, self.firstCellPosY= self.loop_Kill[3].gameObject.transform:GetAnchoredPosition() -- 尝试获取BossEntity local mainBossData = BattleDataGetter.GetMainBoss() if mainBossData then self.bindingEntityID = mainBossData.EntityID self.buffPanel = self.buffItem_Root:OpenView( GetViewClass(Const_UI_Lua.UIEnum.UIBattleBuffPanel), { buffType = LuaConst.UIBuffShowType.Boss, entityId = self.bindingEntityID } ) end self:Init() end function UICountryNightBossBattleBase:Init() UIUtils.SetActive(self.img_Country, false) UIUtils.SetActive(self.txt_Country, false) -- 国家模式标识 local curPKModel = BattleDataGetter.GetFightMode() if curPKModel then self:OnFightModeChanged(curPKModel) end -- 招募按钮 UIUtils.SetActive(self.group_SeekHelp.gameObject, CTL.CountryNightBoss.HasRecruitPermission()) --倒计时 self.totalTime = FP.tonumberV1(LevelManager.LevelTotalTime()) self.waitingStartSeconds = START_WAITING_TIME - math.floor(BattleDataGetter.GetCurFrameIndex() * FRAME_TIMES_UNIT / MILLION_SECONDS) if self.waitingStartSeconds > 0 then UIManager.OpenView(Const_UI_Lua.UIEnum.UIBattleCountDownCasualPanel, { nil, "IDS_WorldBoss_CountdownTips", true }) EventSystem.Dispatch(EventID.UI_UIBattleCountDownPanel_SetNumber, self.waitingStartSeconds) end -- 设置boss信息 self.bossEnterInfo = MDL.CountryNightBoss.GetEnterBossBattleInitInfo() local monsterData = DataSheetManager.MonsterData:GetDataByID(DataSheetManager.CountryNightBoss:GetDataByID(self.bossEnterInfo.bossId).MonsterID) self.bossIconName = DataSheetManager.MonsterModelData:GetDataByID(monsterData.ModelID).BossHeadIcon self:RefreshBossIcon() self:UpdateBossInfo(true) self:StartRepeatFunc(self.OnUpdateFunc, UPDATE_CHECK_TIME) self:OnValueChanged(self.toggles_Battle, 0) end function UICountryNightBossBattleBase:RefreshBossIcon() if string.isNilOrEmpty(self.bossIconName) then self.state_Icon:SetState(0) UIUtils.SetImageByAssetBundle(self.BossIcon, ICON_BOSS) else self.state_Icon:SetState(1) UTL.Item.ItemIconByName(self.img_HeroIcon, self.bossIconName) end end --- OnUpdateFunction 0.3秒 function UICountryNightBossBattleBase:OnUpdateFunc(deltaTime, timeSinceUpdate) self:UpdateTimeShow() if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIBattleCountDownCasualPanel) then local tmp = START_WAITING_TIME - math.floor(BattleDataGetter.GetCurFrameIndex() * FRAME_TIMES_UNIT / MILLION_SECONDS) if tmp <= 0 then UIManager.CloseView(Const_UI_Lua.UIEnum.UIBattleCountDownCasualPanel) -- 战斗开始倒计时 else if tmp ~= self.waitingStartSeconds then self.waitingStartSeconds = tmp EventSystem.Dispatch(EventID.UI_UIBattleCountDownPanel_SetNumber, self.waitingStartSeconds) end end end end function UICountryNightBossBattleBase:OnBossBorn(entity) if not self.buffPanel then self.bindingEntityID = entity.EntityID self.buffPanel = self.buffItem_Root:OpenView( GetViewClass(Const_UI_Lua.UIEnum.UIBattleBuffPanel), { buffType = LuaConst.UIBuffShowType.Boss, entityId = self.bindingEntityID } ) end end function UICountryNightBossBattleBase:OnAMChanged(am, maxAm, lastAm, entity) if self.bindingEntityID == entity.EntityID then local percent = maxAm == 0 and 0 or am / maxAm if lastAm > 0 then if percent <= 0 then self.sprite_AmFg_BossMask.fillAmount = 1 if self.BossAm_ShineLoop == nil then self.BossAm_ShineLoop = self:PlayUIAnimation("BossAm_ShineLoop") else self:PlayUIAnimation(self.BossAm_ShineLoop) end if self.effect_weak then self.effect_weak:PlayUIEffect() else logging.error(LTAG.ERROR, "UIBattleBossBattleInfoView.effect_weak 为 nil ,self.BossIcon 是否为空: ", self.BossIcon == nil) end UIUtils.SetImageByAssetBundle(self.BossIcon, ICON_WEAK) else if self.BossAm_ShineLoop then self:StopUIAnimation(self.BossAm_ShineLoop) end self.sprite_AmFg_BossMask.fillAmount = percent self:RefreshBossIcon() end elseif lastAm <= 0 and percent == 1 then self.sprite_AmFg_BossMask.fillAmount = 1 self:RefreshBossIcon() if self.BossAm_ShineLoop then self:StopUIAnimation(self.BossAm_ShineLoop) end if self.BossAm_Return == nil then self.BossAm_Return = self:PlayUIAnimation("BossAm_Return") else self:PlayUIAnimation(self.BossAm_Return) end end end end --Buff变化 function UICountryNightBossBattleBase:UpdateBuffShow(buffData, time, layer, sourceEntityId, entityID) if entityID == self.bindingEntityID then self.buffPanel:UpdateBuffShow(buffData, time, layer, sourceEntityId) end end function UICountryNightBossBattleBase:UpdateBossInfo(isInit) -- 更新关卡剩余时间 self:UpdateTimeShow() -- 更新boss血量 if isInit == true then UIUtils.SetLabel(self.hpValue, CTL.CountryNightBoss.GetHpPercentValStr(self.bossEnterInfo.bossHp, self.bossEnterInfo.bossTotalHp)) local monsterData = DataSheetManager.MonsterData:GetDataByID(DataSheetManager.CountryNightBoss:GetDataByID(self.bossEnterInfo.bossId).MonsterID) UIUtils.SetLabelText(self.BossName, Const_IDS[monsterData.MonsterNameIDS]) self.hp_Boss.value = CTL.CountryNightBoss.GetHpPercentVal(self.bossEnterInfo.bossHp, self.bossEnterInfo.bossTotalHp) else local bossInfo = MDL.CountryNightBoss.GetBossInfoByID(self.bossEnterInfo.bossId) UIUtils.SetLabel(self.hpValue, CTL.CountryNightBoss.GetHpPercentValStr(bossInfo.bossHp, bossInfo.totalBossHp)) self.hp_Boss.value = CTL.CountryNightBoss.GetHpPercentVal(bossInfo.bossHp, bossInfo.totalBossHp) if (bossInfo.bossHp <= 0 or MDL.CountryNightBoss.IsBossOver(bossInfo.bossId)) and self.isFightEnd == false then self.isFightEnd = true self:StartRepeatFunc(self.OnLateCloseBattleView, DELAY_QUIT_TIME + 1, 1) end end end function UICountryNightBossBattleBase:OnLateCloseBattleView() MDL.Level.SendRoleLeaveFuben() end function UICountryNightBossBattleBase:OnUpdateRecruitTimer() self.event_SeekHelp:SetGray(false, true) self.helpTimer = nil self.lab_HelpTimeCD:EndTimer() self.CDTimerLock = false end --请求协助 --请求召集后,按钮变灰色,倒计时开始,按钮不可用 function UICountryNightBossBattleBase:OnClickRecruit() self.effect_Help:StopUIEffect() self.event_SeekHelp:SetGray(true) self:StartRepeatFunc(self.OnUpdateRecruitTimer, RECRUIT_CD, 1) self.lab_HelpTimeCD:ResetAndBeginCustomTimer(false, RECRUIT_CD, 0, UIUtils.GetLocalizedTxt(Const_IDS["IDS_TeamUI_Myteam_RecruitingTime"]), 1) MDL.CountryNightBoss.CountryNightBossCallMemberReq() end function UICountryNightBossBattleBase:LoadPlayerRank() local playerRankList, myRank = MDL.CountryNightBoss.GetPlayerBossRankInfo() self.LoopScroll_Battle:ReloadAll(playerRankList) UIUtils.SetActive(self.img_Country, true) UIUtils.SetActive(self.txt_Country, true) UIUtils.SetLabel(self.txt_NameMine, BattleDataGetter.GetPlayerName()) CTL.Country.SetCountryInRank(self.img_Country, self.txt_Country, BattleDataGetter.GetMyCountryID()) if myRank then UIUtils.SetLabel(self.txt_RankMine, myRank.index) UIUtils.SetLabel(self.txt_ScoreMine, myRank.score) else UIUtils.SetLabel(self.txt_RankMine, "-") UIUtils.SetLabel(self.txt_ScoreMine, "-") end end function UICountryNightBossBattleBase:UpdateTimeShow() local curTimer = BattleDataGetter.GetCurFrameIndex() * FRAME_TIMES_UNIT / MILLION_SECONDS self.txt_Condition.text = UTL.Time.FormatTimeSeconds(self.totalTime - curTimer) end --- 切换战斗模式 function UICountryNightBossBattleBase:OnFightModeChanged(pkModel) if self.CurPKModel == pkModel then return end self.CurPKModel = pkModel UIUtils.SetLabelText(self.lab_Mode, CountryWorldBossPKModel[pkModel].constIDS) UTL.Item.SetAtlasSprite(self.img_Point, "UI_Battle", CountryWorldBossPKModel[pkModel].iconName) end function UICountryNightBossBattleBase:OnValueChanged(comp, index) if comp == self.toggles_Battle then self.sub_View:CloseAll() if index == 0 then self.sub_View:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UICountryNightBossBattleRank)) elseif index == 1 then self.sub_View:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UICountryNightBossBattleList)) end end end function UICountryNightBossBattleBase:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.LoopScroll_Battle then UIUtils.SetLabel(cellTable.txt_Rank, data.index) UIUtils.SetLabel(cellTable.txt_Name, data.playerName) UIUtils.SetLabel(cellTable.txt_Score, data.score) CTL.Country.SetCountryInRank(cellTable.img_Country, cellTable.txt_Country, data.countryId) end end function UICountryNightBossBattleBase:OnButtonClicked(comp) if comp == self.btn_Goto then elseif comp == self.btn_Setting then UIManager.OpenView(Const_UI_Lua.UIEnum.UISettingMainPanel) elseif comp == self.btn_Exit then CTL.Setting.BackToTown() elseif comp == self.event_SeekHelp then self:OnClickRecruit() elseif comp == self.btn_ArrowOpen then -- 打开右侧面板 self.obi_state:SetState(1) elseif comp == self.btn_ArrowClose then -- 关闭右侧面板 self.obi_state:SetState(0) end end function UICountryNightBossBattleBase:OnPlayerKill(entity) if not entity or not entity:IsHero() then return end local killerEntity = entity.components.record.KillerEntity killerEntity = killerEntity:GetMasterEntity() or killerEntity if not killerEntity or not killerEntity:IsHero() then return end local killerInfo = BattleDataGetter.GetPlayerInfo(killerEntity:GetPlayerID()) local deadPersonInfo = BattleDataGetter.GetPlayerInfo(entity:GetPlayerID()) if killerInfo and deadPersonInfo then local killerName = killerInfo.name local killerCountryID = killerInfo.countryId local deadPersonName = deadPersonInfo.name self:ShowKillMsg(killerName, deadPersonName, killerCountryID) end end --- 击杀提示相关内容 function UICountryNightBossBattleBase:HideLoopKill(deltaTime, timeSinceUpdate) for k, v in pairs(self.hideLoopKill) do if v then local time = UTL.Time.GetLocalTimestamp() - v if time >= HIDE_KILL_TIME then self:PlayUIAnimation(ConstAssetPathConfig.AssetPath112, k.gameObject.transform) self.hideLoopKill[k] = nil end end end if not next(self.hideLoopKill) then self.allHide = true end end function UICountryNightBossBattleBase:ShowKillMsg(killerName, deadName, killerCountryID) if self.allHide then local cell = self.loop_Kill[3] self:SetKillCell(cell, killerName, deadName, killerCountryID) cell.gameObject:SetActive(true) --第一次显示 播放最下层信息动画 self.firstId = self:PlayUIAnimation(ConstAssetPathConfig.AssetPath111, self.loop_Kill[3].gameObject.transform, true) self.hideLoopKill[self.loop_Kill[3]] = UTL.Time.GetLocalTimestamp() self.playing = true self.allHide = false self:StartRepeatFunc(self.HideLoopKill, 1, -1) else self.curShowMsgs = self.curShowMsgs or {} self:EnqueueKillParam(killerName, deadName, killerCountryID) if not self.playing then self:PlayNext() end end end function UICountryNightBossBattleBase:DequeueKillParam() local killerCountryID = table.remove(self.curShowMsgs, 3) local deadName = table.remove(self.curShowMsgs, 2) local killerName = table.remove(self.curShowMsgs, 1) return killerName, deadName, killerCountryID end function UICountryNightBossBattleBase:EnqueueKillParam(killerName, deadName, killerCountryID) table.insert(self.curShowMsgs, killerName) table.insert(self.curShowMsgs, deadName) table.insert(self.curShowMsgs, killerCountryID) end function UICountryNightBossBattleBase:PlayNext() if self.curShowMsgs and #self.curShowMsgs > QUEUE_UNIT_COUNT then self.playing = true --击杀动画 已经显示的上移 腾出位置给新的显示动画 if self.hideLoopKill[self.loop_Kill[2]] then self:PlayUIAnimation(ConstAssetPathConfig.Path16, self.loop_Kill[2].gameObject.transform) self.hideLoopKill[self.loop_Kill[2]] = UTL.Time.GetLocalTimestamp() end self.killPlayId = self:PlayUIAnimation(ConstAssetPathConfig.Path16, self.loop_Kill[3].gameObject.transform, true) self.loop_Kill[1].gameObject:SetActive(false) self.hideLoopKill[self.loop_Kill[3]] = UTL.Time.GetLocalTimestamp() else self.playing = false end end function UICountryNightBossBattleBase:SetKillCell(cellTable, killerName, deadName, killerCountryID) if killerCountryID == BattleDataGetter.GetMyCountryID() then cellTable.txt_Name01.text = self:GetPlayerNameColor(killerName) cellTable.txt_Name02.text = UTL.Color.FormatTextByColor("e46b71", deadName) else cellTable.txt_Name01.text = UTL.Color.FormatTextByColor("e46b71", killerName) cellTable.txt_Name02.text = self:GetPlayerNameColor(deadName) end end function UICountryNightBossBattleBase:GetPlayerNameColor(playerName) if playerName == BattleDataGetter.GetPlayerName() then return UTL.Color.FormatGreenColor(playerName) else return UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Blue, playerName) end end function UICountryNightBossBattleBase:OnUIAnimationStoped(id) if self.killPlayId == id then if self.curShowMsgs and #self.curShowMsgs > QUEUE_UNIT_COUNT then local cell1 = self.loop_Kill[1] local cell2 = self.loop_Kill[2] local cell3 = self.loop_Kill[3] self.loop_Kill[1] = cell2 self.loop_Kill[2] = cell3 self.loop_Kill[3] = cell1 self:SetKillCell(self.loop_Kill[3], self:DequeueKillParam()) self.loop_Kill[3].gameObject.transform:SetAnchoredPosition(self.firstCellPosX, self.firstCellPosY) self.loop_Kill[3].gameObject:SetActive(true) self.firstId = self:PlayUIAnimation(ConstAssetPathConfig.AssetPath111, self.loop_Kill[3].gameObject.transform, true) self.hideLoopKill[self.loop_Kill[3]] = UTL.Time.GetLocalTimestamp() end elseif self.firstId == id then self:PlayNext() end end return UICountryNightBossBattleBase