local UIGoldenHeroBossRankReward = UIViewClass() function UIGoldenHeroBossRankReward:OnOpened(context) self.heroType = context.heroType self.activityId = context.activityId UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_GoldHeroActivity_SynergyBoss_RankReward_Hint1) self:RegistSystemEvent(EventID.UI_GoldenHeroBoss_RefreshRankData, self.RefreshRankReward) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) MDL.GoldenHeroBoss.GoldHeroGetRankRecordReq(self.activityId, MDL.GoldenHeroBoss.BossRankType.SynergyBossTotalRank) end function UIGoldenHeroBossRankReward:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView() end end end function UIGoldenHeroBossRankReward:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIGoldenHeroBossRankReward:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.btn_TotalPoints then self:RefreshRankReward(MDL.GoldenHeroBoss.BossRankType.SynergyBossTotalRank) elseif comp == self.btn_SingleDamage then self:RefreshRankReward(MDL.GoldenHeroBoss.BossRankType.SynergyBossMaxDamageRank) end end function UIGoldenHeroBossRankReward:RefreshRankReward(rankType) self.rankType = rankType UIUtils.SetActive(self.img_TotalPointsSelected, rankType == MDL.GoldenHeroBoss.BossRankType.SynergyBossTotalRank) UIUtils.SetActive(self.img_SingleDamageSelected, rankType == MDL.GoldenHeroBoss.BossRankType.SynergyBossMaxDamageRank) if self.loop_RankReward.Count > 0 then self.loop_RankReward:ClearCells() end if rankType == MDL.GoldenHeroBoss.BossRankType.SynergyBossTotalRank then for i, v in DataSheetManager.GoldHeroSynergyBossTotalRank[self.heroType]:GetEnumerator() do self.loop_RankReward:AddData({isTotal = true, data = v}, 0) end self.state_RankTitle:SetState(0) elseif rankType == MDL.GoldenHeroBoss.BossRankType.SynergyBossMaxDamageRank then for i, v in DataSheetManager.GoldHeroSynergyBossDamageRank[self.heroType]:GetEnumerator() do self.loop_RankReward:AddData({isTotal = false, data = v}, 1) end self.state_RankTitle:SetState(1) end end function UIGoldenHeroBossRankReward:RefreshMaxDamageCell(index, cellTable, data) local itemData = data.Reward_Table for i, v in ipairs(cellTable.Content) do if #itemData >= i then UTL.Item.SetItemCell(v, itemData[i].Item, itemData[i].ItemNum) v.gameObject.transform.parent.gameObject:SetActive(true) else v.gameObject.transform.parent.gameObject:SetActive(false) end end cellTable.txt_Name.text = self:FormatRankStr(data.Rank1, data.Rank2) --能获得的奖励是否处于当前排名中 local currentIndex = MDL.GoldenHeroBoss.GetCurrentIndexOfRewardRank(self.activityId, self.rankType) - 1 if currentIndex < 0 then UIUtils.SetActive(cellTable.img_Current, false) else UIUtils.SetActive(cellTable.img_Current, index == currentIndex) end end function UIGoldenHeroBossRankReward:RefreshTotalPointCell(index, cellTable, data) local rewardData = data.Reward_Table UIUtils.SetLabelText(cellTable.txt_RankName, Const_IDS[data.RankName]) UIUtils.SetActive(cellTable.group_Reward.gameObject, true) for i, v in ipairs(cellTable.group_Reward) do local reward = rewardData[i] if reward then UIUtils.SetActive(v.gameObject.transform.parent, true) UTL.Item.SetItemCell(v, reward.Item, reward.ItemNum) else UIUtils.SetActive(v.gameObject.transform.parent, false) end end --能获得的奖励是否处于当前排名中 local currentIndex = MDL.GoldenHeroBoss.GetCurrentIndexOfRewardRank(self.activityId, self.rankType) - 1 if currentIndex < 0 then UIUtils.SetActive(cellTable.img_Current, false) else UIUtils.SetActive(cellTable.img_Current, index == currentIndex) end local limitScore = data.LimitIntegration or 0 UIUtils.SetActive(cellTable.group_Points, limitScore > 0) if limitScore > 0 then cellTable.txt_Point.text = data.LimitIntegration end local limitTimes = data.LimitNum or 0 UIUtils.SetActive(cellTable.group_Times, limitTimes > 0) if limitTimes > 0 then cellTable.txt_Times.text = limitTimes end cellTable.txt_Conditions.text = data.Rank2 end local StringFormat = string.FormatByIdsId function UIGoldenHeroBossRankReward:FormatRankStr(rank1, rank2) if (not rank2) or (rank1 == rank2) then return StringFormat(Const_IDS.IDS_BossChallenge_Reward_RankRange_OneNum, rank1) else return StringFormat(Const_IDS.IDS_BossChallenge_Reward_RankRange_TwoNum, rank1, rank2) end end function UIGoldenHeroBossRankReward:OnCellInit(scrollRect, index, cellTable, data) if data.isTotal then self:RefreshTotalPointCell(index, cellTable, data.data) else self:RefreshMaxDamageCell(index, cellTable, data.data) end end function UIGoldenHeroBossRankReward:OnCellClicked(scrollRect, index, cellTable, target, data) if data.isTotal then for i, v in ipairs(cellTable.group_Reward) do if v.event_Click == target then UTL.ItemTips.ShowCommonTipsById(data.data.Reward_Table[i].Item) break end end else for i, v in ipairs(cellTable.Content) do if v.event_Click == target then UTL.ItemTips.ShowCommonTipsById(data.data.Reward_Table[i].Item) break end end end end return UIGoldenHeroBossRankReward