--- 左侧小列表国家伤害排行子View local UICountryNightBossBattleRank = UIViewClass() local emptyStateList = { { countryId = 1, totalDamage = 0, }, { countryId = 2, totalDamage = 0, }, { countryId = 3, totalDamage = 0, }, { countryId = 4, totalDamage = 0, }, } -- {bossID = 0} -- bossID == 0 代表不显示前往按钮,排行为国家所有伤害 -- bossID > 0 显示前往按钮,排行为国家对单一boss的伤害排行 function UICountryNightBossBattleRank:OnOpened(context) self:RegistSystemEvent(EventID.UI_CountryNightBoss_UpdateBossInfo, self.RefreshRankList) self.bossID = 0 if context and context.bossID then self.bossID = context.bossID end self:Init() end function UICountryNightBossBattleRank:Init() if self.bossID > 0 then self.state_Info:SetState(1) else self.state_Info:SetState(0) end for i, v in ipairs(emptyStateList) do if self.bossID > 0 then self.loop_CountryRank:AddData(v, 0) else self.loop_CountryRank:AddData(v, 1) end end end function UICountryNightBossBattleRank:RefreshRankList() -- 场景内国家对此boss的伤害 local bossInfo = MDL.CountryNightBoss.GetBossInfoByID(self.bossID) if self.bossID > 0 and bossInfo.CountryScoreRank then -- 长安内 self.loop_CountryRank:ReloadAll(bossInfo.CountryScoreRank) else -- 战斗内 local rankList = MDL.CountryNightBoss.GetCountryTotalDamageRank() self.loop_CountryRank:ReloadAll(rankList) end end function UICountryNightBossBattleRank:OnCellInit(scrollRect, index, cellTable, data) UIUtils.SetLabel(cellTable.txt_Rank, index + 1) CTL.Country.SetCountryInRank(cellTable.img_Country, cellTable.txt_Guild, data.countryId) UIUtils.SetLabel(cellTable.txt_Blood, data.totalDamage <= 0 and "--" or UTL.String.GetPercentFormatFloat(data.totalDamage*100, 1, 2)) end function UICountryNightBossBattleRank:OnButtonClicked(comp) if comp == self.btn_Goto then local bossInfo = MDL.CountryNightBoss.GetBossInfoByID(self.bossID) CTL.CountryNightBoss.GoToBossPos(bossInfo.position) end end return UICountryNightBossBattleRank