local UIChangAnSiegeBattlefieldDataPanel = UIViewClass() function UIChangAnSiegeBattlefieldDataPanel:OnOpened() UIUtils.SetLabelText(self.UICommonPopUpTab.txt_Title, Const_IDS.IDS_SiegeCity_InMBF_Data_4) self:InitPlayerData() self.isDefendCountry = MDL.ChangAnSiege.IsDefendCountry() self.isCityWarMainLevel = BattleDataGetter.IsCityWarMainLevel() self.UICommonPopUpTab.loop_Tab:AddData(Const_IDS.IDS_SiegeCity_InMBF_DataDetail_1, 0) self.UICommonPopUpTab.loop_Tab:AddData(Const_IDS.IDS_SiegeCity_InMBF_DataDetail_2, 0) self.UICommonPopUpTab.loop_Tab:SelectIndex(0) end local function TotalContributionSort(a,b) local aTotalContribution = a.killScore + a.assistScore + a.otherScore local bTotalContribution = b.killScore + b.assistScore + b.otherScore if aTotalContribution == bTotalContribution then return a.playerInfo.playerID < b.playerInfo.playerID end return aTotalContribution > bTotalContribution end function UIChangAnSiegeBattlefieldDataPanel:InitPlayerData() local allPlayerInfoList = BattleDataGetter.GetCityWarPlayerScoreInfoList() self.teamData = {} self.enemyData = {} for i, v in ipairs(allPlayerInfoList) do if v.playerInfo.campID == BattleDataGetter.GetMyCampID() then --我方玩家 table.insert(self.teamData, v) else table.insert(self.enemyData, v) end end table.sort(self.teamData, TotalContributionSort) table.sort(self.enemyData, TotalContributionSort) end function UIChangAnSiegeBattlefieldDataPanel:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUpTab.btn_Close) end function UIChangAnSiegeBattlefieldDataPanel:OnButtonClicked(comp) if comp == self.UICommonPopUpTab.btn_Close then self:CloseView() end end function UIChangAnSiegeBattlefieldDataPanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.UICommonPopUpTab.loop_Tab then UIUtils.SetLabelText(cellTable.txt_Name_Nomal, data) UIUtils.SetLabelText(cellTable.txt_Name_Selected, data) UIUtils.SetActive(cellTable.img_Arrow, false) UIUtils.SetActive(cellTable.img_ArrowS, false) elseif scrollRect == self.loop_CASBattlefieldData1 or scrollRect == self.loop_CASBattlefieldData2 then if index <= 2 then UIUtils.SetActive(cellTable.img_MedalIcon, true) cellTable.img_MedalIcon:SetState(index) UIUtils.SetLabel(cellTable.txt_Rank, "") else UIUtils.SetActive(cellTable.img_MedalIcon, false) UIUtils.SetLabel(cellTable.txt_Rank, index+1) end if data.playerInfo.acid == BattleDataGetter.GetAcID() then UIUtils.SetLabel(cellTable.txt_PlayerName, UTL.Color.FormatGreenColor(data.playerInfo.name)) else UIUtils.SetLabel(cellTable.txt_PlayerName, UTL.Color.FormatWhiteColor(data.playerInfo.name)) end UIUtils.SetLabel(cellTable.txt_Kill, BattleDataGetter.GetCityWarTotalKillNum(data.playerInfo.playerID)) UIUtils.SetLabel(cellTable.txt_Assisting, BattleDataGetter.GetCityWarAssistKillNum(data.playerInfo.playerID)) if cellTable.txt_Contribution then UIUtils.SetLabel(cellTable.txt_Contribution, math.floor(data.otherScore)) end UIUtils.SetLabel(cellTable.txt_TotalContribution, math.floor(data.killScore + data.assistScore + data.otherScore)) end end function UIChangAnSiegeBattlefieldDataPanel:OnCellSelect(scrollRect, index, cellTable, data) if scrollRect == self.UICommonPopUpTab.loop_Tab then self:OnTabClicked(index) end end function UIChangAnSiegeBattlefieldDataPanel:OnTabClicked(index) if self.isCityWarMainLevel then --主战场 UIUtils.SetActive(self.group_InformationBar1.gameObject, true) UIUtils.SetActive(self.group_InformationBar2.gameObject, false) if index == 0 then self.loop_CASBattlefieldData1:ReloadAll(self.teamData) if self.teamData and #self.teamData > 0 then self.loop_CASBattlefieldData1:SelectIndex(0, true) end if self.isDefendCountry then UIUtils.SetLabelText(self.lab_Contribution, Const_IDS.IDS_SiegeCity_InMBF_DataDetail_8) else UIUtils.SetLabelText(self.lab_Contribution, Const_IDS.IDS_SiegeCity_InMBF_DataDetail_7) end else self.loop_CASBattlefieldData1:ReloadAll(self.enemyData) if self.enemyData and #self.enemyData > 0 then self.loop_CASBattlefieldData1:SelectIndex(0, true) end if self.isDefendCountry then UIUtils.SetLabelText(self.lab_Contribution, Const_IDS.IDS_SiegeCity_InMBF_DataDetail_7) else UIUtils.SetLabelText(self.lab_Contribution, Const_IDS.IDS_SiegeCity_InMBF_DataDetail_8) end end else --副战场 if index == 0 then UIUtils.SetActive(self.group_InformationBar1.gameObject, not self.isDefendCountry) UIUtils.SetActive(self.group_InformationBar2.gameObject, self.isDefendCountry) if self.isDefendCountry then self.loop_CASBattlefieldData2:ReloadAll(self.teamData) --我方防守数据 else self.loop_CASBattlefieldData1:ReloadAll(self.teamData) --我方进攻数据 UIUtils.SetLabelText(self.lab_Contribution, Const_IDS.IDS_SiegeCity_InABF_Data_4) end else UIUtils.SetActive(self.group_InformationBar1.gameObject, self.isDefendCountry) UIUtils.SetActive(self.group_InformationBar2.gameObject, not self.isDefendCountry) if self.isDefendCountry then self.loop_CASBattlefieldData1:ReloadAll(self.enemyData) --敌方进攻数据 UIUtils.SetLabelText(self.lab_Contribution, Const_IDS.IDS_SiegeCity_InABF_Data_4) else self.loop_CASBattlefieldData2:ReloadAll(self.enemyData) --敌方防守数据 end end end end return UIChangAnSiegeBattlefieldDataPanel