local UIGuildWarSummaryReward = UIViewClass() local TimeRefreshId = 1656 --第二场开战时间id local CountDown = DataSheetManager.ConstData:GetDataByID("GuildBossRewardClientShow").IntValue local AuctionTime = DataSheetManager.ConstData:GetDataByID("GuildAuctionShowTime").IntValue local MinScore = DataSheetManager.ConstData:GetDataByID("GuildWarPlayerRewardScoreLimit").IntValue function UIGuildWarSummaryReward:OnOpened(context) local data = MDL.GuildWar.GetBattleInfo() self.isGuildWarCrossServer = CTL.GuildWar.IsShowCrossServerUI() -- 是否开启跨服 self.isWin = false if data.selfIsRed then self.isWin = context.winCameId == 1 else self.isWin = context.winCameId == 2 end local isEmpty = true if context.isFirst then local mergeReward = self:GetMergeReward(context.rewards) for k, v in pairs(mergeReward) do self.scroll_RewardTop:AddData(v, 0) isEmpty = false end UIUtils.SetActive(self.group_Double, true) UIUtils.SetActive(self.group_Single, false) UTL.Time.GetDiffLocalStrById(1656) self.lab_Desc1.text = string.FormatByIdsId(Const_IDS.IDS_GuildWar_NextBattleDesc, UTL.Time.GetDiffLocalStrById(1656)) local reward = self:GetMergeReward(self:GetNextReward()) for k, v in pairs(reward) do self.scroll_RewardBottom:AddData(v, 0) end self.lab = self.lab1 else UIUtils.SetActive(self.group_Double, false) UIUtils.SetActive(self.group_Single, true) local mergeReward = self:GetMergeReward(context.rewards) for k, v in pairs(mergeReward) do self.scroll_RewardSingle:AddData(v, 0) isEmpty = false end if context.tagId == 5 then UIUtils.SetActive(self.lab_Desc2, false) else UIUtils.SetActive(self.lab_Desc2, true) self.lab_Desc2.text = string.FormatByIdsId(Const_IDS.IDS_Auction_GuildAuctionOpenDesc, AuctionTime / UTL.Time.TotalSecondsOneMinute) end self.lab = self.lab2 end local str = UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildBoss_AutoCloseTime) self.labLocal_Timer:ResetAndBeginCustomTimer(false, CountDown, 0, str) self.TitleSwitch:SetState(self.isWin and 0 or 1) self:StartRepeatFunc(self.OnUpdateFun, CountDown) if isEmpty then local str = string.FormatByIdsId(Const_IDS.IDS_GuildWar_NoRewardDesc, MinScore) self.lab_Empty.text = str self.lab_Mail.text = nil UIUtils.SetActive(self.lab, false) else UIUtils.SetActive(self.lab, true) UIUtils.SetLabelText(self.lab, Const_IDS.IDS_DrawCard_Title_Congratulations) UIUtils.SetLabelText(self.lab_Mail, Const_IDS.IDS_GuildWar_RewardIntro2) end if self.isWin then CTL.Sound.PlayGameSound("UI_victory_v1") else CTL.Sound.PlayGameSound("UI_failed_v1") end end function UIGuildWarSummaryReward:OnUpdateFun() self:CloseView() end function UIGuildWarSummaryReward:OnClosed() UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildWarSummaryPanel, self.context) end function UIGuildWarSummaryReward:GetNextReward() local id = 0 if self.context.tagId == 5 then id = self.isWin and 1 or 2 else id = self.isWin and 1 or 3 end local rankRewardId = self.isGuildWarCrossServer and DataSheetManager.GuildWarRankRewardCrossServer:GetDataByID_Rank(self.context.tagId, id).MilitaryExploitsReward or DataSheetManager.GuildWarRankReward:GetDataByID_Rank(self.context.tagId, id).MilitaryExploitsReward local rankReward = DataSheetManager.GuildWarMilitaryExploitsReward:GetDataByID(rankRewardId) local cfg = self.isGuildWarCrossServer and DataSheetManager.GuildWarGroupCrossServer:GetDataByID(self.context.tagId) or DataSheetManager.GuildWarGroup:GetDataByID(self.context.tagId) local partReward = DataSheetManager.GuildWarSigleVictoryReward:GetDataByID(cfg.AttendVictoryReward) local list = {} for i, v in ipairs(rankReward.Item_Table) do table.insert(list, v) end for i, v in ipairs(partReward.Item_Table) do table.insert(list, v) end return list end function UIGuildWarSummaryReward:GetMergeReward(rewardLists) local list = {} for i, v in ipairs(rewardLists) do local itemId = v.ItemId or v.ItemID local count = v.ItemCount or v.ItemNum if list[itemId] then list[itemId].ItemCount = list[itemId].ItemCount + count else list[itemId] = { ItemCount = count, ItemId = itemId } end end return list end function UIGuildWarSummaryReward:OnBackButtonPressed() self:OnButtonClicked(self.event_Bottom) end function UIGuildWarSummaryReward:OnButtonClicked(comp) if comp == self.event_Bottom then self:CloseView() end end function UIGuildWarSummaryReward:OnCellInit(scrollRect, index, cellTable, data) UTL.Item.SetItemCell(cellTable.item, data.ItemId, data.ItemCount) end function UIGuildWarSummaryReward:OnCellClicked(scrollRect, index, cellTable, target, data) UTL.ItemTips.ShowCommonTipsById(data.ItemId) end return UIGuildWarSummaryReward