local UIFightThroneRewardResult = UIViewClass() local TAB_TYPE_PERSON = 0 local TAB_TYPE_GUILD = 1 local TAB_TYPE_COLLECT = 2 function UIFightThroneRewardResult:OnOpened(context) local reward1 = DataSheetManager.RewardPreview:GetDataByID(1).RewardID UTL.Item.SetItemCell(self.collectRewardItem1, reward1, 0) local reward2 = DataSheetManager.RewardPreview:GetDataByID(2).RewardID UTL.Item.SetItemCell(self.collectRewardItem2, reward2, 0) local reward3 = DataSheetManager.RewardPreview:GetDataByID(3).RewardID UTL.Item.SetItemCell(self.collectRewardItem3, reward3, 0) self.itemSourceObj = self.Item_FightThroneRewardResult.gameObject self.playerRankArray = context.playerRank self.guildRankArray = context.guildRank self.myDmgData = context.myDmg self.myGuildDmgData = context.myGuildDmg UIUtils.SetActive(self.btn_Next, false) self.tabType = nil if self.guildRankArray and #self.guildRankArray > 0 then local time = DataSheetManager.ConstData:GetDataByID("GuildAuctionShowTime").IntValue self.txt_AuctionTips.text = string.FormatByIdsId(Const_IDS.IDS_FightThroneAuctionTips, time / 60) else self.txt_AuctionTips.text = nil end self:OnValueChanged(self.toggle_TopGroup, TAB_TYPE_PERSON) end function UIFightThroneRewardResult:OnValueChanged(comp, value) if comp == self.toggle_TopGroup then self:OnTabChange(value, true) end end function UIFightThroneRewardResult:OnTabChange(tabType, isToggle) if isToggle and self.tabType == tabType then return end self.tabType = tabType self.loop_RewardRank:ClearCells() if tabType == TAB_TYPE_PERSON then UIUtils.SetActive(self.Panel_Rank, true) UIUtils.SetActive(self.Panel_CollectReward, false) UIUtils.SetLabelText(self.txt_NameTitle, Const_IDS.IDS_RebelStrike_Player) UIUtils.SetLabelText(self.lab_Hurt, Const_IDS.IDS_FightThrone_Damage) UIUtils.SetLabelText(self.txt_Reward, Const_IDS.IDS_FightThronePreviewPersonal2) if self.playerRankArray and #self.playerRankArray > 0 then self:ShowRankData(tabType, self.playerRankArray, self.myDmgData) else self:ShowEmpty(tabType) end elseif tabType == TAB_TYPE_GUILD then UIUtils.SetActive(self.Panel_Rank, true) UIUtils.SetActive(self.Panel_CollectReward, false) UIUtils.SetLabelText(self.txt_NameTitle, Const_IDS.IDS_FightThrone_Legion) UIUtils.SetLabelText(self.lab_Hurt, Const_IDS.IDS_3v3Points) UIUtils.SetLabelText(self.txt_Reward, Const_IDS.IDS_FightThronePreviewGuild2) if self.guildRankArray and #self.guildRankArray > 0 then self:ShowRankData(tabType, self.guildRankArray, self.myGuildDmgData) else self:ShowEmpty(tabType) end else UIUtils.SetActive(self.Panel_Rank, false) UIUtils.SetActive(self.Panel_CollectReward, true) local result = self.context.result self:SetCollectNum(result.SilverChest, result.GoldChest, result.JadeFragment) end end function UIFightThroneRewardResult:GetRewardArray(tabType, index) if tabType == TAB_TYPE_PERSON then for _, v in DataSheetManager.FightThronePersonRank:GetEnumerator() do if index <= v.Rank then if CTL.WarZone.IsWarZoneOpen() then return DataSheetManager.FightThronePersonReward:GetDataByID(v.CrossSeverPersonalReward).Item_Table else return DataSheetManager.FightThronePersonReward:GetDataByID(v.PersonalReward).Item_Table end end end else local rankMaxID = 1 -- 数据里的最大排名ID local rewardShowData for _, v in DataSheetManager.FightThroneGuildRank:GetEnumerator() do if v.ID > rankMaxID then rankMaxID = v.ID rewardShowData = v end if index <= v.Rank then return MDL.FightThrone.GetAuctionPoolRewardArray(v) end end --其他排名走最后一行的排名奖励 if rewardShowData then return MDL.FightThrone.GetAuctionPoolRewardArray(rewardShowData) end end return nil end function UIFightThroneRewardResult:ShowRankData(tabType, array, myData) UIUtils.SetActive(self.group_Empty, false) self.loop_RewardRank:ReloadAll(array) if myData and myData.index > 0 then UIUtils.SetActive(self.group_SelfRewardInfo, true) self:SetRankIndex(self.UIState_RankIcon, self.txt_Rank, self.img_RankIcon, myData.index) self:SetNameAndDamage(myData, self.txt_Name, self.txt_HurtNum, self.img_GuildBG, self.txt_Guild, true) local reward = self:GetRewardArray(tabType, myData.index) self.myRewardArray = reward self:SetRewardInfo(reward, self.content, nil) else UIUtils.SetActive(self.group_SelfRewardInfo, false) end end function UIFightThroneRewardResult:SetNameAndDamage(data, txt_Name, txt_HurtNum, img_GuildBG, txt_Guild, isGreenColor) local name = isGreenColor and UTL.Color.FormatGreenColor(data.name) or data.name if CTL.WarZone.IsWarZoneOpen() then name = name..".S"..tostring(data.serId) end txt_Name.text = name if self.tabType == TAB_TYPE_PERSON then txt_HurtNum.text = isGreenColor and UTL.Color.FormatGreenColor(UTL.String.GetCountStr(data.damage)) or UTL.String.GetCountStr(data.damage) UIUtils.SetActive(img_GuildBG, false) else txt_HurtNum.text = isGreenColor and UTL.Color.FormatGreenColor(UTL.String.GetCountStr(data.score)) or UTL.String.GetCountStr(data.score) UIUtils.SetActive(img_GuildBG, true) CTL.Guild.SetGuildEmblem(img_GuildBG, txt_Guild, data.emblemFrame, data.emblemContent) end end function UIFightThroneRewardResult:SetRewardInfo(rewardArray, content, cellObj) if rewardArray == nil then for i = 1, #content do local item = content[i] UIUtils.SetActive(item.gameObject, false) end return end for i, v in ipairs(rewardArray) do local item = content[i] if item == nil then if cellObj then item = self:InstantiateCellCollection(cellObj, content, self.itemSourceObj) else item = self:InstantiateCollection(content, self.itemSourceObj) end end UIUtils.SetActive(item.gameObject, true) UTL.Item.SetItemCell(item.item, v.ItemID, v.ItemNum) if self.tabType == TAB_TYPE_PERSON then UIUtils.SetActive(item.img_Icon, false) else UIUtils.SetActive(item.img_Icon, true) end end for i = #rewardArray + 1, #content do local item = content[i] UIUtils.SetActive(item.gameObject, false) end end function UIFightThroneRewardResult:SetRankIndex(state, txt_Rank, rankIcon, rankValue) if rankValue <= 3 then txt_Rank.text = nil UIUtils.SetActive(rankIcon, true) state:SetState(rankValue - 1) else txt_Rank.text = rankValue UIUtils.SetActive(rankIcon, false) end end function UIFightThroneRewardResult:ShowEmpty(tabType) UIUtils.SetActive(self.group_SelfRewardInfo, false) self.loop_RewardRank:ClearCells() UIUtils.SetActive(self.group_Empty, true) if tabType == TAB_TYPE_PERSON then UIUtils.SetLabelText(self.txt_Empty, Const_IDS.IDS_GuildBoss_RankingNoPlayer) else UIUtils.SetLabelText(self.txt_Empty, Const_IDS.IDS_FightThrone_NoLegion) end end function UIFightThroneRewardResult:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_RewardRank then local isSelf = false if self.tabType == TAB_TYPE_PERSON then isSelf = data.acid == BattleDataGetter.GetAcID() else if self.myGuildDmgData then isSelf = data.id == self.myGuildDmgData.id end end UIUtils.SetActive(cellTable.img_Self, isSelf) self:SetRankIndex(cellTable.UIState_RankIcon, cellTable.txt_Rank, cellTable.img_RankIcon, data.index) self:SetNameAndDamage(data, cellTable.txt_Name, cellTable.txt_HurtNum, cellTable.img_GuildBG, cellTable.txt_Guild, isSelf) local reward = self:GetRewardArray(self.tabType, data.index) self:SetRewardInfo(reward, cellTable.content, cellTable.cell.gameObject) end end function UIFightThroneRewardResult:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_RewardRank then for i, v in ipairs(cellTable.content) do if v.item.event_Click == target then local reward = self:GetRewardArray(self.tabType, data.index) UTL.ItemTips.ShowCommonTipsById(reward[i].ItemID) break end end end end function UIFightThroneRewardResult:SetCollectNum(num1, num2, num3) if num1 == 0 and num2 == 0 and num3 == 0 then UIUtils.SetActive(self.group_CollectRewardEmpty, true) UIUtils.SetActive(self.group_CollectReward, false) else UIUtils.SetActive(self.group_CollectRewardEmpty, false) UIUtils.SetActive(self.group_CollectReward, true) self:SetItemNum(self.collectRewardItem1, num1) self:SetItemNum(self.collectRewardItem2, num2) self:SetItemNum(self.collectRewardItem3, num3) end end function UIFightThroneRewardResult:SetItemNum(item, num) if num > 0 then UIUtils.SetActive(item.gameObject.transform.parent, true) item.lab_Count.text = num else UIUtils.SetActive(item.gameObject.transform.parent, false) end end function UIFightThroneRewardResult:OnBackButtonPressed() self:OnButtonClicked(self.btn_Quit) end function UIFightThroneRewardResult:OnButtonClicked(comp) if comp == self.btn_Quit then self:CloseView() MDL.Level.SendRoleLeaveFuben() elseif comp == self.btn_Info or comp == self.btn_Info2 then UIManager.OpenView(Const_UI_Lua.UIEnum.UIFightThroneRewardPreview) elseif comp == self.collectRewardItem1.event_Click then local id = DataSheetManager.RewardPreview:GetDataByID(1).RewardID UTL.ItemTips.ShowCommonTipsById(id) elseif comp == self.collectRewardItem2.event_Click then local id = DataSheetManager.RewardPreview:GetDataByID(2).RewardID UTL.ItemTips.ShowCommonTipsById(id) elseif comp == self.collectRewardItem3.event_Click then local id = DataSheetManager.RewardPreview:GetDataByID(3).RewardID UTL.ItemTips.ShowCommonTipsById(id) else for i, v in ipairs(self.content) do if v.item.event_Click == comp then UTL.ItemTips.ShowCommonTipsById(self.myRewardArray[i].ItemID) break end end end end return UIFightThroneRewardResult