local UIFightThroneBattleInfo = UIViewClass() local EventSystem = require('Event/EventSystem') local TITLE_FORMAT = "%s(%s)" local CHECK_TIMER = 1 local BOSS_APPEAR_EVENT = 11 local BOSS_MONSTER_ID = 37002109 local IDS_DESC_FLOOR = { [LuaConst.LevelType.FightThroneTown] = Const_IDS.IDS_FightThrone_Explain1, [LuaConst.LevelType.CrossFightThroneTown] = Const_IDS.IDS_FightThrone_Explain1, [LuaConst.LevelType.FightThroneFirstFloor] = Const_IDS.IDS_FightThrone_Explain2, [LuaConst.LevelType.FightThroneSecondFloor] = Const_IDS.IDS_FightThrone_Explain3, [LuaConst.LevelType.FightThroneThirdFloor] = Const_IDS.IDS_FightThrone_Explain4, } local IDS_TITLE_FLOOR = { [LuaConst.LevelType.FightThroneTown] = Const_IDS.IDS_FightThrone_BattlegroundName4, [LuaConst.LevelType.CrossFightThroneTown] = Const_IDS.IDS_FightThrone_BattlegroundName4, [LuaConst.LevelType.FightThroneFirstFloor] = Const_IDS.IDS_FightThrone_BattlegroundName1, [LuaConst.LevelType.FightThroneSecondFloor] = Const_IDS.IDS_FightThrone_BattlegroundName2, [LuaConst.LevelType.FightThroneThirdFloor] = Const_IDS.IDS_FightThrone_BattlegroundName6, } local FRAME_LEVEL_START = LuaConst.LogicFrameRate * 1 local FRAME_LEVEL_30S = LuaConst.LogicFrameRate * 30 local FRAME_LEVEL_60S = LuaConst.LogicFrameRate * 60 local FRAME_LEVEL_85S = LuaConst.LogicFrameRate * 85 local FRAME_LEVEL_90S = LuaConst.LogicFrameRate * 90 local FRAME_LEVEL_120S = LuaConst.LogicFrameRate * 120 local FRAME_LEVEL_LEFT_60S function UIFightThroneBattleInfo:OnOpened(context) UIUtils.SetActive(self.img_ModeInfoBG, false) self:RegistSystemEvent(EventID.UIBattle_Level_SetUpBoss, self.SetUpBoss) self:RegistSystemEvent(EventID.UIBattle_MainPlayerFightModeChanged, self.OnFightModeChanged) self:RegistSystemEvent(EventID.FightThrone_CollectAmountChange, self.UpdateItemNum) self:RegistSystemEvent(EventID.FightThrone_SendResult, self.OnFightThroneResult) self:RegistSystemEvent(EventID.UIBattle_Level_OnBossBorn, self.OnBossBron) self.comboViewRoot:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIBattleCombo), { isShowComboType = LuaConst.ComboType.IsKillHero }) self.progressRoot:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIBattleBossProgress)) self.killInfoNoticeViewRoot:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIBattleKillInfoNotice)) local levelType = BattleDataGetter.GetCurLevelType() if BattleDataGetter.IsFightThroneTown() or levelType == LuaConst.LevelType.FightThroneThirdFloor then UIUtils.SetActive(self.group_BattleInfo.gameObject, false) UIUtils.SetActive(self.group_BattleInfoNoBox.gameObject, true) else UIUtils.SetActive(self.group_BattleInfo.gameObject, true) UIUtils.SetActive(self.group_BattleInfoNoBox.gameObject, false) if levelType == LuaConst.LevelType.FightThroneFirstFloor then self.group_BattleInfo.state_img:SetState(0) elseif levelType == LuaConst.LevelType.FightThroneSecondFloor then self.group_BattleInfo.state_img:SetState(1) end end if BattleDataGetter.IsFightThroneTown() then self.totalTimeFrame = nil self.totalTime = CTL.FightThrone.GetTownCloseTime() UIUtils.SetActive(self.btn_Setting_NoMap,true) UIUtils.SetActive(self.btn_Setting,false) else UIUtils.SetActive(self.btn_Setting_NoMap,false) UIUtils.SetActive(self.btn_Setting,true) self.totalTimeFrame = FP.tonumberV1(LevelManager.LevelTotalTime()) * LuaConst.LogicFrameRate FRAME_LEVEL_LEFT_60S = FP.tonumberV1(LevelManager.LevelTotalTime() - 60) * LuaConst.LogicFrameRate self.totalTime = nil end --描述 local curComps = self:GetCurInfoComps() curComps.UIState_Click:SetState(1) local desc = IDS_DESC_FLOOR[levelType] UIUtils.SetLabelText(curComps.labLocal_FightDescribe, desc) --道具数量 self.silverLimit = DataSheetManager.RewardPreview:GetDataByID(LuaConst.EFightThroneCollectType.SILVER).RewardLimit self.goldLimit = DataSheetManager.RewardPreview:GetDataByID(LuaConst.EFightThroneCollectType.GOLD).RewardLimit self.jadeLimit = DataSheetManager.RewardPreview:GetDataByID(LuaConst.EFightThroneCollectType.JADE).RewardLimit self:UpdateItemNum() --时间 self.titleContent = UIUtils.GetLocalizedTxt(IDS_TITLE_FLOOR[levelType]) if levelType == LuaConst.LevelType.FightThroneThirdFloor then self.bossAppearTimeFrame = FP.tonumberV1(LevelItemManager.GetEventConditionParam(BOSS_APPEAR_EVENT, LuaConst.LevelConditionType.Global_TimeRun)) * LuaConst.LogicFrameRate UIManager.OpenView(Const_UI_Lua.UIEnum.UIBattleCountDownCasualPanel, { nil, "IDS_WorldBoss_CountdownTips", true }) EventSystem.Dispatch(EventID.UI_UIBattleCountDownPanel_SetNumber, math.floor(self.bossAppearTimeFrame - BattleDataGetter.GetCurFrameIndex() / LuaConst.LogicFrameRate)) end self:UpdateTimer() self:StartRepeatFunc(self.UpdateTimer, CHECK_TIMER, 0) --Pk Mode local curPKModel = BattleDataGetter.GetFightMode() if curPKModel then self:OnFightModeChanged(curPKModel, true) end self:InitSecondFloorToggle() end function UIFightThroneBattleInfo:OnFightThroneResult() self.totalTimeFrame = nil self:UpdateTitle(self.titleContent) end function UIFightThroneBattleInfo:SetUpBoss(active, monsterId, entityID) if active then if not self.bossHpView then self.bossHpView = self.bossHPRoot:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIDemonGodBossHp), { entityID = entityID }, "GuildBoss/UIGuildBossBattleView") else self.bossHpView:ActiveUI({ entityID = entityID }) --这里临时先这么改吧 如果有两个boss切换血条 会不正确 end else if self.bossHpView then self.bossHpView:HideUI() end end end function UIFightThroneBattleInfo:UpdateTimer() if self.bossAppearTimeFrame then local leftBossAppearFrame = self.bossAppearTimeFrame - BattleDataGetter.GetCurFrameIndex() if leftBossAppearFrame > 0 then local seconds = math.floor(leftBossAppearFrame / LuaConst.LogicFrameRate) self:UpdateTitle(string.FormatByIdsId(Const_IDS.IDS_FightThrone_BattlegroundName5, seconds)) EventSystem.Dispatch(EventID.UI_UIBattleCountDownPanel_SetNumber, seconds) else UIManager.CloseView(Const_UI_Lua.UIEnum.UIBattleCountDownCasualPanel) self.bossAppearTimeFrame = nil end else if self.totalTimeFrame then local leftTimeFrame = self.totalTimeFrame - BattleDataGetter.GetCurFrameIndex() self:UpdateTitle(string.format(TITLE_FORMAT, self.titleContent, UTL.Time.FormatTimeByFrameCount(leftTimeFrame))) self:HandleShowDialogue() if leftTimeFrame <= 0 then self.totalTimeFrame = nil end end end if self.totalTime then local leftTime = self.totalTime - CHECK_TIMER if leftTime > 0 then self:UpdateTitle(string.format(TITLE_FORMAT, self.titleContent, UTL.Time.FormatTimeSeconds(leftTime))) self.totalTime = leftTime else self:UpdateTitle(self.titleContent) self.totalTime = nil end end end --处理报文提示 function UIFightThroneBattleInfo:HandleShowDialogue() local curFrameIndex = BattleDataGetter.GetCurFrameIndex() if self.lastFrameIndex then local levelType = BattleDataGetter.GetCurLevelType() if levelType == LuaConst.LevelType.FightThroneFirstFloor then if self.lastFrameIndex < FRAME_LEVEL_START and curFrameIndex >= FRAME_LEVEL_START then EventSystem.Dispatch(EventID.UI_MainShowDialogue, "Tip_Hard_370011_08") end if self.lastFrameIndex < FRAME_LEVEL_60S and curFrameIndex >= FRAME_LEVEL_60S then EventSystem.Dispatch(EventID.UI_MainShowDialogue, "Tip_Hard_370011_06") end if self.lastFrameIndex < FRAME_LEVEL_120S and curFrameIndex >= FRAME_LEVEL_120S then EventSystem.Dispatch(EventID.UI_MainShowDialogue, "Tip_Hard_370011_01") end if self.lastFrameIndex < FRAME_LEVEL_LEFT_60S and curFrameIndex >= FRAME_LEVEL_LEFT_60S then EventSystem.Dispatch(EventID.UI_MainShowDialogue, "Tip_Hard_370011_04") end elseif levelType == LuaConst.LevelType.FightThroneSecondFloor then if self.lastFrameIndex < FRAME_LEVEL_START and curFrameIndex >= FRAME_LEVEL_START then EventSystem.Dispatch(EventID.UI_MainShowDialogue, "Tip_Hard_370011_05") end if self.lastFrameIndex < FRAME_LEVEL_30S and curFrameIndex >= FRAME_LEVEL_30S then EventSystem.Dispatch(EventID.UI_MainShowDialogue, "Tip_Hard_370011_06") end if self.lastFrameIndex < FRAME_LEVEL_90S and curFrameIndex >= FRAME_LEVEL_90S then EventSystem.Dispatch(EventID.UI_MainShowDialogue, "Tip_Hard_370011_01") end if self.lastFrameIndex < FRAME_LEVEL_LEFT_60S and curFrameIndex >= FRAME_LEVEL_LEFT_60S then EventSystem.Dispatch(EventID.UI_MainShowDialogue, "Tip_Hard_370011_04") end elseif levelType == LuaConst.LevelType.FightThroneThirdFloor then if self.lastFrameIndex < FRAME_LEVEL_START and curFrameIndex >= FRAME_LEVEL_START then EventSystem.Dispatch(EventID.UI_MainShowDialogue, "Tip_Hard_370011_02") end if self.lastFrameIndex < FRAME_LEVEL_85S and curFrameIndex >= FRAME_LEVEL_85S then EventSystem.Dispatch(EventID.UI_MainShowDialogue, "Tip_Hard_370011_07") end end end self.lastFrameIndex = BattleDataGetter.GetCurFrameIndex() end function UIFightThroneBattleInfo:GetCurInfoComps() local levelType = BattleDataGetter.GetCurLevelType() if BattleDataGetter.IsFightThroneTown() or levelType == LuaConst.LevelType.FightThroneThirdFloor then return self.group_BattleInfoNoBox else return self.group_BattleInfo end end function UIFightThroneBattleInfo:UpdateTitle(content) local comp = self:GetCurInfoComps() comp.txt_Title.text = content end function UIFightThroneBattleInfo:UpdateItemNum(entity, collectType, delta) local isUpdate = true if entity and BattleDataGetter.GetCurEntity() ~= entity then isUpdate = false end if isUpdate then if collectType and delta > 0 then local itemId = DataSheetManager.RewardPreview:GetDataByID(collectType).RewardID CTL.Tips.AddImageTip(itemId, delta) end local num1 = BattleDataGetter.GetCollectAmountOfPlayerByCollectKey(LuaConst.EFightThroneCollectType.SILVER) or 0 self.group_BattleInfo.txt_Num1.text = num1 .. "/" .. self.silverLimit local num2 = BattleDataGetter.GetCollectAmountOfPlayerByCollectKey(LuaConst.EFightThroneCollectType.GOLD) or 0 self.group_BattleInfo.txt_Num2.text = num2 .. "/" .. self.goldLimit local num3 = BattleDataGetter.GetCollectAmountOfPlayerByCollectKey(LuaConst.EFightThroneCollectType.JADE) or 0 self.group_BattleInfo.txt_Num3.text = num3 .. "/" .. self.jadeLimit end end function UIFightThroneBattleInfo:OnFightModeChanged(pkModel, notTips) if self.curPKModel == pkModel then return end self.curPKModel = pkModel if pkModel == LuaConst.EFightMode.PEACE then self.state_Mode:SetState(0) if notTips ~= true then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS["IDS_PKMode_Change"], UIUtils.GetLocalizedTxt(Const_IDS.IDS_PKMode_Peace))) end elseif pkModel == LuaConst.EFightMode.TEAM_GUILD then local countryState = MDL.Country.GetCurStage() if countryState and countryState >= MDL.Country.Stage.CountryBuild and countryState <= MDL.Country.Stage.CountryReset then self.state_Mode:SetState(2) else self.state_Mode:SetState(1) end if notTips ~= true then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS["IDS_PKMode_Change"], UIUtils.GetLocalizedTxt(Const_IDS.IDS_PKMode_Force))) end end end function UIFightThroneBattleInfo:OnButtonClicked(comp) if comp == self.btn_Change then CTL.Tips.AddTipsMsg(Const_IDS["IDS_FightThrone_CannotSwitch"]) elseif comp == self.btn_Setting or comp == self.btn_Setting_NoMap then UIManager.OpenView(Const_UI_Lua.UIEnum.UISettingMainPanel) elseif comp == self.group_BattleInfo.btn_Info or comp == self.group_BattleInfoNoBox.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, { id = LuaConst.NoteID.FightThrone }) elseif comp == self.group_BattleInfo.group_Bottom then UIManager.OpenView(Const_UI_Lua.UIEnum.UIFightThroneRewardPreview) elseif comp == self.group_BattleInfo.btn_Up or comp == self.group_BattleInfoNoBox.btn_Up or comp == self.group_BattleInfo.btn_Down or comp == self.group_BattleInfoNoBox.btn_Down then self:OnUpdateFoldState() end end function UIFightThroneBattleInfo:OnUpdateFoldState() local comps = self:GetCurInfoComps() local curState = comps.UIState_Click.CurState if curState == 0 then if self.curShowRank then comps.UIState_Click:SetState(2) else comps.UIState_Click:SetState(1) end else comps.UIState_Click:SetState(0) end end function UIFightThroneBattleInfo:InitSecondFloorToggle() if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.FightThroneSecondFloor) then UIUtils.SetActive(self.group_toggles, true) else UIUtils.SetActive(self.group_toggles, false) end UIUtils.SetActive(self.group_BattleInfo.group_DamageRank, false) end local bossDmgInfoSorter = function(a, b) return a.dmg > b.dmg end function UIFightThroneBattleInfo:UpdateBossRank() local list = BattleDataGetter.GetDamageList() local boss = BattleDataGetter.GetMainBoss() local myRankIndex = 0 local myDmg = nil if next(list) then UIUtils.SetActive(self.group_BattleInfo.group_Empty, false) UIUtils.SetActive(self.group_BattleInfo.group_Rank, true) local sortList = {} for playerId, dmg in pairs(list) do table.insert(sortList, { playerId = playerId, dmg = dmg }) end table.sort(sortList, bossDmgInfoSorter) self.group_BattleInfo.loop_Rank:ReloadAll(sortList) for i, v in ipairs(sortList) do if v.playerId == BattleDataGetter.GetCurPlayerID() then myDmg = v.dmg myRankIndex = i end end self:InitMyRankInfo(myRankIndex, myDmg) else UIUtils.SetActive(self.group_BattleInfo.group_Empty, true) UIUtils.SetActive(self.group_BattleInfo.group_Rank, false) local curTimer = BattleDataGetter.GetRemainTime() - 50 local timeStr = UTL.Time.FormatTimeBySeconds(curTimer) local monsterData = DataSheetManager.MonsterData:GetDataByID(BOSS_MONSTER_ID) if boss then self.group_BattleInfo.lab_Empty.text = string.FormatByIdsId(Const_IDS.IDS_FightThrone_BossBornTips, UIUtils.GetLocalizedTxt(Const_IDS[monsterData.MonsterNameIDS])) else self.group_BattleInfo.lab_Empty.text = string.FormatByIdsId(Const_IDS.IDS_FightThrone_BossBornTime, UIUtils.GetLocalizedTxt(Const_IDS[monsterData.MonsterNameIDS]), timeStr) end end end function UIFightThroneBattleInfo:InitMyRankInfo(myRankIndex, myDmg) local My_Rank = self.group_BattleInfo.My_Rank UIUtils.SetActive(My_Rank.img_FirstRank, myRankIndex == 1) My_Rank.txt_Name.text = BattleDataGetter.GetPlayerName() My_Rank.txt_Score.text = UTL.String.GetCountStr(myDmg and FP.tonumberV1(myDmg) or 0) if myRankIndex == 0 then UIUtils.SetLabelText(My_Rank.txt_Empty, Const_IDS.IDS_HeroMatch1v1_NowResult5) UIUtils.SetActive(My_Rank.img_Rank, false) else My_Rank.txt_Rank.text = myRankIndex UIUtils.SetActive(My_Rank.img_Rank, true) My_Rank.txt_Empty.text = nil if myRankIndex == 1 then My_Rank.effect_Owner:PlayUIEffect() else My_Rank.effect_Owner:StopUIEffect() end end end function UIFightThroneBattleInfo:OnCellInit(scrollRect, index, cellTable, data) UIUtils.SetActive(cellTable.img_FirstRank, index == 0) cellTable.txt_Rank.text = index + 1 cellTable.txt_Name.text = BattleDataGetter.GetPlayerNameByPlayerID(data.playerId) if index == 0 then cellTable.effect_Owner:PlayUIEffect() else cellTable.effect_Owner:StopUIEffect() end cellTable.txt_Score.text = UTL.String.GetCountStr(FP.tonumberV1(data.dmg)) end function UIFightThroneBattleInfo:OnValueChanged(comp, value) if comp == self.group_toggles then if value == 0 then self:StopRepeatFunc(self.UpdateBossRank) self.group_BattleInfo.UIState_Click:SetState(1) self.curShowRank = nil else self.group_BattleInfo.UIState_Click:SetState(2) self:StartRepeatFunc(self.UpdateBossRank, 1, 0) self:UpdateBossRank() self.curShowRank = true end end end function UIFightThroneBattleInfo:OnBossBron() if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.FightThroneSecondFloor) then local monsterData = DataSheetManager.MonsterData:GetDataByID(BOSS_MONSTER_ID) local str = string.FormatByIdsId(Const_IDS.IDS_FightThrone_BossBornTips, UIUtils.GetLocalizedTxt(Const_IDS[monsterData.MonsterNameIDS])) UIManager.OpenView(Const_UI_Lua.UIEnum.UIDialogueTopReportView,{str = str}) self.group_toggles:SelectIndex(1) end end return UIFightThroneBattleInfo