--- 国战晚间boss战斗统计界面 --- local UICountryNightBossRecord = UIViewClass() local ConsistShowType = { Score = 0, JoinReward = 1, } local PageEnum = { CountryRank_1 = 0, PlayerRank_2 = 1, } local HIGHLIGHT_COLOR = "e8d588" function UICountryNightBossRecord:OnOpened(context) self:RegistSystemEvent(EventID.UI_CountryNightBoss_UpdateConsistInfo, self.SetRewardConsistInfo) self:RegistSystemEvent(EventID.UI_CountryNightBoss_UpdateFightDetailAndBalance, self.RefreshRankInfo) self.sortConfig = { [CTL.CountryNightBoss.SortFieldEnum.Damage] = 0, [CTL.CountryNightBoss.SortFieldEnum.Kill] = 0, [CTL.CountryNightBoss.SortFieldEnum.Help] = 0, [CTL.CountryNightBoss.SortFieldEnum.Death] = 0, } self.rankCacheArr = {} self.rankCacheDic = {} self.maxDamage = {val = 0} self.maxKill = {val = 0} self.maxHelp = {val = 0} self.playerRankList = {} -- 默认请求战斗统计界面1 self.state_Page:SetState(0) MDL.CountryNightBoss.CountryBossBalanceFinalReq() end function UICountryNightBossRecord:ResetSortOptionUI() self.state_ArrowDamage:SetState(2) self.state_ArrowKill:SetState(2) self.state_ArrowSupport:SetState(2) self.state_ArrowDead:SetState(2) end function UICountryNightBossRecord:RefreshRankInfo(rankList, myRank, targetDamage) self.myRank = myRank -- 本期达标积分 self.target = targetDamage or 0 -- 缓存伤害排行供排序使用 table.clearArray(self.playerRankList) for i, v in ipairs(rankList) do table.insert(self.playerRankList, v) end if self.state_Page.CurState == PageEnum.CountryRank_1 then -- myRank为num self:LoadCountryRankList(rankList) -- 本期达标积分 local targetScoreStr = self.target == 0 and "-" or self.target UIUtils.SetLabel(self.txt_SeasonDamage, string.FormatByIdsId(Const_IDS["IDS_CountryNightBoss_DamageStandard"], targetScoreStr)) self.state_Notice:SetState((self.target > 0 and self.myRank >= self.target) and 0 or 1) -- 我的积分 local myScoreStr = self.myRank > 0 and UTL.String.GetCountStr(self.myRank) or "-" UIUtils.SetLabel(self.txt_MyDamage, string.FormatByIdsId(Const_IDS["IDS_CountryNightBoss_MyDamage"], myScoreStr)) else -- 更新伤害、击杀、助攻最大值 -- myRank为table if #rankList == 0 then if self.loop_DamageRank.Count > 0 then self.loop_DamageRank:ClearCells() end UIUtils.SetActive(self.group_Empty.gameObject, true) else self.SortedPlayerRankList = {} UIUtils.SetActive(self.group_Empty.gameObject, false) CTL.CountryNightBoss.SetMaxValByDamage_Kill_Help(rankList, self.maxDamage, self.maxKill, self.maxHelp) self.loop_DamageRank:ReloadAll(rankList) end if IsServerDataNotNil(myRank) then UIUtils.SetActive(self.mine_DamageRank.gameObject, true) -- 排名 if myRank.index > 3 then self.mine_DamageRank.UIState:SetState(3) UIUtils.SetLabel(self.mine_DamageRank.txt_Rank, myRank.index) else self.mine_DamageRank.UIState:SetState(myRank.index - 1) end -- 国家 CTL.Country.SetCountryInRank(self.mine_DamageRank.img_Country, self.mine_DamageRank.txt_Guild, myRank.countryId) -- 姓名 UIUtils.SetLabel(self.mine_DamageRank.lab_HeroName, myRank.playerName) -- 服务器 UIUtils.SetLabel(self.mine_DamageRank.txt_Server, CTL.CrossServer.GetServerShowStr(myRank.serverId)) -- 带醒目字色 local damageStr = (myRank.damage ~= 0 and myRank.damage >= self.maxDamage.val and self.maxDamage.acid == myRank.acid) and UTL.Color.FormatTextByColor(HIGHLIGHT_COLOR, UTL.String.GetCountStr(myRank.damage)) or UTL.String.GetCountStr(myRank.damage) local killStr = (myRank.kill ~= 0 and myRank.kill >= self.maxKill.val and self.maxKill.acid == myRank.acid) and UTL.Color.FormatTextByColor(HIGHLIGHT_COLOR, UTL.String.GetCountStr(myRank.kill)) or UTL.String.GetCountStr(myRank.kill) local helpStr = (myRank.help ~= 0 and myRank.help >= self.maxHelp.val and self.maxHelp.acid == myRank.acid) and UTL.Color.FormatTextByColor(HIGHLIGHT_COLOR, UTL.String.GetCountStr(myRank.help)) or UTL.String.GetCountStr(myRank.help) -- 伤害 UIUtils.SetLabel(self.mine_DamageRank.txt_Damage, damageStr) -- 击杀 UIUtils.SetLabel(self.mine_DamageRank.txt_Kill, killStr) -- 助攻 UIUtils.SetLabel(self.mine_DamageRank.txt_Support, helpStr) -- 死亡 UIUtils.SetLabel(self.mine_DamageRank.txt_Dead, UTL.String.GetCountStr(myRank.death)) self:LoadMyPlayerRewardsCount(self.myRank.index) else UIUtils.SetActive(self.mine_DamageRank.gameObject, false) end end end function UICountryNightBossRecord:LoadMyPlayerRewardsCount(rankIndex) for i = #self.mine_DamageRank.ItemContent, 1, -1 do self:DestroyCollection(self.mine_DamageRank.ItemContent, i) end for _, v in DataSheetManager.CountryNightBossRankRewardP:GetEnumerator() do if (rankIndex >= v.RankBegin and rankIndex <= v.RankEnd) or (v.RankEnd == 0 and rankIndex >= v.RankBegin) then local itemTb = v.Item_Table for __, itemData in ipairs(itemTb) do local itemContent = self:InstantiateCollection(self.mine_DamageRank.ItemContent, self.item_SelfTemplate.gameObject) itemContent.ItemID = itemData.ItemID UIUtils.SetActive(itemContent.gameObject, true) UTL.Item.SetItemCell(itemContent, itemData.ItemID, itemData.ItemNum, false) end return end end end function UICountryNightBossRecord:LoadCellRewards(cellTable, rankIndex) for i = #cellTable.ItemContent, 1, -1 do self:DestroyCollection(cellTable.ItemContent, i) end for _, v in DataSheetManager.CountryNightBossRankRewardP:GetEnumerator() do if (rankIndex >= v.RankBegin and rankIndex <= v.RankEnd) or (v.RankEnd == 0 and rankIndex >= v.RankBegin) then local itemTb = v.Item_Table for __, itemData in ipairs(itemTb) do local itemContent = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.ItemContent, self.item_Template.gameObject) itemContent.ItemID = itemData.ItemID UIUtils.SetActive(itemContent.gameObject, true) UIUtils.SetActive(itemContent.img_All.gameObject, itemData.IfAllMember ~= nil) UTL.Item.SetItemCell(itemContent.item, itemData.ItemID, itemData.ItemNum, false) end return end end end function UICountryNightBossRecord:LoadCountryRankList(rankList) table.clearArray(self.rankCacheArr) table.clear(self.rankCacheDic) for _, v in ipairs(rankList) do self.rankCacheDic[v.countryId] = v table.insert(self.rankCacheArr, v) end for i = 1, 4 do if not self.rankCacheDic[i] then table.insert(self.rankCacheArr, { index = i, countryId = i, score = 0 }) end end self.loop_CountryRank:ReloadAll(self.rankCacheArr) end function UICountryNightBossRecord:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.group_Tip.loop_BossList then -- 国家奖励组成 UIUtils.SetActive(cellTable.img_Icon.gameObject, false) -- 方位描述 local pointData = DataSheetManager.CountryNightBossPoint:GetDataByBossPoint(index + 1) local directionStr = string.FormatByIdsId(Const_IDS[pointData.PointName]) UIUtils.SetLabel(cellTable.txt_Direction, directionStr) CTL.CountryNightBoss.SetBossHeadUI(cellTable.BossIcon, data.bossID) if self.curSelectConsistType == ConsistShowType.Score then if data.bossID > 0 then UIUtils.SetLabel(cellTable.txt_Num, data.score) else UIUtils.SetLabel(cellTable.txt_Num, "-") end elseif self.curSelectConsistType == ConsistShowType.JoinReward then if data.bossID > 0 then UIUtils.SetActive(cellTable.img_Icon.gameObject, true) if data.rewardId > 0 then UTL.Item.SetItemIcon(cellTable.img_Icon, data.rewardId) UIUtils.SetLabel(cellTable.txt_Num, data.num) else UIUtils.SetActive(cellTable.img_Icon.gameObject, false) UIUtils.SetLabel(cellTable.txt_Num, "-") end else UIUtils.SetActive(cellTable.img_Icon.gameObject, false) UIUtils.SetLabel(cellTable.txt_Num, "-") end end elseif scrollRect == self.loop_CountryRank then -- 国家伤害榜 UIUtils.SetActive(cellTable.group_Me.gameObject, MDL.Country.GetMyCountryId() == data.countryId) -- 国家标识 CTL.Country.SetCountryInRank(cellTable.img_Country, cellTable.txt_Country, data.countryId) -- 总积分 UIUtils.SetLabel(cellTable.txt_Integral, UTL.String.GetCountStr(data.score)) UIUtils.SetActive(cellTable.btn_Info1, data.score >= 0) if data.score <= 0 then cellTable.state_Info:SetState(1) else cellTable.state_Info:SetState(0) self:LoadCNBRewards(cellTable.item1, data.countryReward) self:LoadCNBRewards(cellTable.item2, data.JoinPlayerReward) end -- 奖励 elseif scrollRect == self.loop_DamageRank then UIUtils.SetActive(cellTable.sprite_Bg1, index % 2 ~= 1) -- 个人伤害榜排行 -- 排名 if data.index > 3 then cellTable.UIState:SetState(3) UIUtils.SetLabel(cellTable.txt_Rank, data.index) else cellTable.UIState:SetState(data.index - 1) end -- 国家标识 CTL.Country.SetCountryInRank(cellTable.img_Country, cellTable.txt_Guild, data.countryId) -- 姓名 UIUtils.SetLabel(cellTable.lab_HeroName, data.playerName) -- 服务器 UIUtils.SetLabel(cellTable.txt_Server, CTL.CrossServer.GetServerShowStr(data.serverId)) local damageStr = (data.damage ~= 0 and data.damage >= self.maxDamage.val and self.maxDamage.acid == data.acid) and UTL.Color.FormatTextByColor(HIGHLIGHT_COLOR, UTL.String.GetCountStr(data.damage)) or UTL.String.GetCountStr(data.damage) local killStr = (data.kill ~= 0 and data.kill >= self.maxKill.val and self.maxKill.acid == data.acid) and UTL.Color.FormatTextByColor(HIGHLIGHT_COLOR, UTL.String.GetCountStr(data.kill)) or UTL.String.GetCountStr(data.kill) local helpStr = (data.help ~= 0 and data.help >= self.maxHelp.val and self.maxHelp.acid == data.acid) and UTL.Color.FormatTextByColor(HIGHLIGHT_COLOR, UTL.String.GetCountStr(data.help)) or UTL.String.GetCountStr(data.help) -- 伤害 UIUtils.SetLabel(cellTable.txt_Damage, damageStr) -- 击杀 UIUtils.SetLabel(cellTable.txt_Kill, killStr) -- 助攻 UIUtils.SetLabel(cellTable.txt_Support, helpStr) -- 死亡 UIUtils.SetLabel(cellTable.txt_Dead, data.death) self:LoadCellRewards(cellTable, data.index) end end function UICountryNightBossRecord:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_CountryRank then if target == cellTable.btn_Info2 then self.curSelectConsistType = ConsistShowType.JoinReward self.curSelectCountryID = data.countryId MDL.CountryNightBoss.CountryBossInfoConsistReq(data.countryId) UIUtils.SetActive(self.group_Tip.gameObject, true) elseif target == cellTable.btn_Info1 then self.curSelectConsistType = ConsistShowType.Score self.curSelectCountryID = data.countryId MDL.CountryNightBoss.CountryBossInfoConsistReq(data.countryId) UIUtils.SetActive(self.group_Tip.gameObject, true) elseif target == cellTable.item1.event_Click then -- 国家奖励 UTL.ItemTips.ShowCommonTipsById(data.countryReward[1].itemId) elseif target == cellTable.item2.event_Click then UTL.ItemTips.ShowCommonTipsById(data.JoinPlayerReward[1].itemId) end elseif scrollRect == self.loop_DamageRank then for i, v in ipairs(cellTable.ItemContent) do if target == v.item.event_Click then UTL.ItemTips.ShowCommonTipsById(v.ItemID) end end end end function UICountryNightBossRecord:SetRewardConsistInfo(countryId, scoreConsist, joinConsist) -- 设置标题 local countryNameStr if self.curSelectConsistType == ConsistShowType.Score then countryNameStr = string.FormatByIdsId(Const_IDS["IDS_CountryNightBoss_CountryTotalScoreParts"], CTL.Country.GetCountryFullName(countryId)) self.group_Tip.loop_BossList:ReloadAll(scoreConsist) else countryNameStr = string.FormatByIdsId(Const_IDS["IDS_CountryNightBoss_CountryRewardParts"], CTL.Country.GetCountryFullName(countryId)) self.group_Tip.loop_BossList:ReloadAll(joinConsist) end UIUtils.SetLabel(self.group_Tip.txt_Title, countryNameStr) end function UICountryNightBossRecord:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UICountryNightBossRecord:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() elseif comp == self.group_Tip.btn_Close then UIUtils.SetActive(self.group_Tip.gameObject, false) elseif comp == self.btn_PageDown then self.state_Page:SetState(1) UIUtils.SetActive(self.mine_DamageRank.gameObject, false) MDL.CountryNightBoss.CountryBossFightDetailReq() elseif comp == self.btn_PageUp then self.state_Page:SetState(0) MDL.CountryNightBoss.CountryBossBalanceFinalReq() elseif comp == self.btn_Kill then -- 击杀排序 self:SortByField(CTL.CountryNightBoss.SortFieldEnum.Kill) self.state_ArrowKill:SetState(self.sortConfig[CTL.CountryNightBoss.SortFieldEnum.Kill]) elseif comp == self.btn_Damage then -- 伤害排序 self:SortByField(CTL.CountryNightBoss.SortFieldEnum.Damage) self.state_ArrowDamage:SetState(self.sortConfig[CTL.CountryNightBoss.SortFieldEnum.Damage]) elseif comp == self.btn_Support then -- 助攻排序 self:SortByField(CTL.CountryNightBoss.SortFieldEnum.Help) self.state_ArrowSupport:SetState(self.sortConfig[CTL.CountryNightBoss.SortFieldEnum.Help]) elseif comp == self.btn_Dead then -- 死亡排序 self:SortByField(CTL.CountryNightBoss.SortFieldEnum.Death) self.state_ArrowDead:SetState(self.sortConfig[CTL.CountryNightBoss.SortFieldEnum.Death]) else for i, v in ipairs(self.mine_DamageRank.ItemContent) do if comp == v.event_Click then UTL.ItemTips.ShowCommonTipsById(v.ItemID) break end end end end function UICountryNightBossRecord:LoadCNBRewards(comp, rewards) local count = 0 for i, v in ipairs(rewards) do count = count + v.itemNum end if #rewards > 0 then UTL.Item.SetItemCell(comp, rewards[1].itemId, count, false) end end function UICountryNightBossRecord:SortByField(targetField) local configVal = self.sortConfig[targetField] if configVal == 0 then self.sortConfig[targetField] = 1 else self.sortConfig[targetField] = 0 end local sortedList = CTL.CountryNightBoss.SortDataBySortConfigAndField(self.playerRankList, self.sortConfig[targetField], targetField) self.loop_DamageRank:ReloadAll(sortedList) end return UICountryNightBossRecord