local UISuperGoldBossRank = UIViewClass() function UISuperGoldBossRank:OnOpened(context) self.context = context self.activityId = context.activityId self.activityType = MDL.OperationActivity.ActivityType.SuperGold self.heroType = context.heroType self.activityStartTime = MDL.OperationActivity.GetOperationActivityInfo(self.activityType, self.activityId).startTime self.closeByHand = false self:RegistSystemEvent(EventID.UI_OACommon_RankRefresh, self.RefreshRankRecords) self:RegistSystemEvent(EventID.UI_OACommon_HistoryRankRefresh, self.RefreshRankRecords) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) local modeData = DataSheetManager.SuperGoldActivityModeData:GetDataByHeroType(self.heroType) self.txt_TotalScoreInfo.text = string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_SuperGoldHeroActivity_NewHint_2), UTL.Time.GetDiffLocalStrById(modeData.DailyRankEndTime)) UIUtils.SetLabelText(self.UICommonPopUpTab.txt_Title, Const_IDS.IDS_SuperGoldHeroActivity_HeroTrial_ChildTitle1) self.loop_Tab = self.UICommonPopUpTab.loop_Tab self.loop_Tab:AddData({rankName = MDL.SuperGoldBoss.BossRankName.TotalScoreRank, title = Const_IDS.IDS_SuperGoldHeroActivity_HeroTrial_RankHint1}, 0) self.loop_Tab:AddData({rankName = MDL.SuperGoldBoss.BossRankName.MaxDamageRank, title = Const_IDS.IDS_SuperGoldHeroActivity_HeroTrial_RankHint3}, 0) self.loop_Tab:SelectIndex(context.rankSelect == MDL.SuperGoldBoss.BossRankName.MaxDamageRank and 1 or 0) end function UISuperGoldBossRank:OnClosed() if self.closeByHand then self.context = nil end end function UISuperGoldBossRank:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:OnButtonClicked(self.UICommonPopUpTab.btn_Close) end end end function UISuperGoldBossRank:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUpTab.btn_Close) end function UISuperGoldBossRank:OnButtonClicked(comp) if comp == self.UICommonPopUpTab.btn_Close then self.closeByHand = true self:CloseView() else for i, v in ipairs(self.group_TotalScoreSelf.group_Reward) do if comp == v.event_Click then local rewardLevel, isScoreEnough = MDL.SuperGoldBoss.GetCurrentIndexOfRewardRank(self.activityId, MDL.SuperGoldBoss.BossRankName.TotalScoreRank) local bossData = DataSheetManager.SuperGoldBossData:GetDataByHeroType(self.heroType) local rewardData = DataSheetManager.SuperGoldBossTotalRank[bossData.RankRewardGroup]:GetDataByRankID(rewardLevel) UTL.ItemTips.ShowCommonTipsById(rewardData.Reward_Table[i].Item) end end end end function UISuperGoldBossRank:RefreshRankRecords(activityId, rankName, day) if activityId == self.activityId then local records local loopComp if rankName == MDL.SuperGoldBoss.BossRankName.MaxDamageRank then loopComp = self.loop_MaxScoreRank records = MDL.OACommon.GetRankRecordsByActivityId(activityId, rankName) self:ShowSelfRank(MDL.OACommon.GetMyRankByActivityId(activityId, rankName), rankName) else loopComp = self.loop_TotalScoreRank if day then local data = MDL.OACommon.GetHistoryRankRecords(activityId, rankName, day) records = data and data.records or {} self:TryShowSelfHistoryRank(records) else records = MDL.OACommon.GetRankRecordsByActivityId(activityId, rankName) self:ShowSelfRank(MDL.OACommon.GetMyRankByActivityId(activityId, rankName), rankName) end end if loopComp.Count > 0 then loopComp:ClearCells() end for i, v in ipairs(records) do loopComp:AddData(v, 0) end UIUtils.SetActive(self.group_Empty, loopComp.Count == 0) end end function UISuperGoldBossRank:TryShowSelfHistoryRank(historyRecords) local selfAcId = BattleDataGetter.GetAcID() for i, v in ipairs(historyRecords) do if v.acid == selfAcId then self:ShowSelfRank(v, MDL.SuperGoldBoss.BossRankName.TotalScoreRank) return end end self.group_TotalScoreSelf.state_RankSelf:SetState(0) end function UISuperGoldBossRank:ShowSelfRank(myRank, rankName) if rankName == MDL.SuperGoldBoss.BossRankName.MaxDamageRank then self:SetMaxDamageRankCell(self.group_MaxScoreSelf, myRank) elseif rankName == MDL.SuperGoldBoss.BossRankName.TotalScoreRank then self:SetTotalScoreRankCell(self.group_TotalScoreSelf, myRank, true) end end function UISuperGoldBossRank:SetTotalScoreRankCell(cell, data, isSelf) local rank = data.index cell.txt_Points.text = data.param1 cell.txt_Num.text = data.param2 cell.txt_Rank.text = rank if isSelf then local rewardLevel, isScoreEnough = MDL.SuperGoldBoss.CalculateTotalPointRewardRank(self.activityId, rank, data.param1, data.param2) local bossData = DataSheetManager.SuperGoldBossData:GetDataByHeroType(self.heroType) if rewardLevel > 0 then local rewardData = DataSheetManager.SuperGoldBossTotalRank[bossData.RankRewardGroup]:GetDataByRankID(rewardLevel) cell.state_RankSelf:SetState(rewardData and 1 or 0) if rewardData then UIUtils.SetLabelText(cell.txt_RankName, Const_IDS[rewardData.RankName]) UIUtils.SetActive(cell.group_Reward.gameObject, true) local rewardTable = rewardData.Reward_Table for i, v in ipairs(cell.group_Reward) do local reward = rewardTable[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 else UIUtils.SetActive(cell.group_Reward.gameObject, false) end else cell.state_RankSelf:SetState(0) UIUtils.SetActive(cell.group_Reward.gameObject, false) end else cell.txt_Name.text = data.name end end function UISuperGoldBossRank:SetMaxDamageRankCell(cell, data) local rank = data.index if rank > 0 then cell.bg_Rank:SetState(rank >= 4 and 3 or rank - 1) cell.txt_Rank.text = rank else cell.bg_Rank:SetState(3) UIUtils.SetLabelText(cell.txt_Rank, Const_IDS.IDS_Rank_Unranked) end cell.txt_Name.text = data.name cell.txt_Server.text = string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Rank_ServerIDS), data.serverId) cell.txt_Integral.text = data.param1 --难度和阵容用分号隔开,阵容之间用逗号隔开 local param = string.split(data.extraParam, ";") if not string.isNilOrEmpty(param[1]) and tonumber(param[1]) > 0 then cell.state_Param:SetState(1) cell.txt_Difficulty.text = param[1] local formation = string.split(param[2], ",") for i, v in ipairs(cell.group_Formation) do local mainHeroId = formation[i * 2 - 1] and tonumber(formation[i * 2 - 1]) or 0 if mainHeroId > 0 then UTL.Item.SetHeroIconByHeroId(v.img_MainHeroHead, mainHeroId) UIUtils.SetActive(v.img_MainEmpty, false) else UIUtils.SetActive(v.img_MainEmpty, true) end local subHeroId = formation[i * 2] and tonumber(formation[i * 2]) or 0 if subHeroId > 0 then UTL.Item.SetHeroIconByHeroId(v.img_SubHeroHead, tonumber(formation[i * 2])) UIUtils.SetActive(v.img_SubEmpty, false) else UIUtils.SetActive(v.img_SubEmpty, true) end end else cell.txt_Difficulty.text = "--" cell.state_Param:SetState(0) end end function UISuperGoldBossRank:OnCellSelect(scrollRect, index, cellTable, data) if scrollRect == self.loop_Tab then if data.rankName then if data.rankName == MDL.SuperGoldBoss.BossRankName.MaxDamageRank then MDL.OACommon.ActivityCrossRankGetRecordReq(self.activityId, data.rankName) self.rankSelect = data.rankName self.context.rankSelect = data.rankName self.selectIndex = index self.loop_Tab:UpdateIndex(0) self.state_Rank:SetState(0) end else if self.rankSelect == MDL.SuperGoldBoss.BossRankName.TotalScoreRank and self.selectIndex == index then return end if data.isLock then self.loop_Tab:SelectIndex(self.selectIndex) return end local activityInfo = MDL.OperationActivity.GetOperationActivityInfo(self.activityType, self.activityId) local diffDay = UTL.Time.GetGameDiffDayCount(UTL.Time.GetServerTimestamp(), activityInfo.startTime) if data.day == diffDay then MDL.OACommon.ActivityCrossRankGetRecordReq(self.activityId, MDL.SuperGoldBoss.BossRankName.TotalScoreRank) else local records = MDL.OACommon.GetHistoryRankRecords(self.activityId, MDL.SuperGoldBoss.BossRankName.TotalScoreRank, data.day) if records then self:RefreshRankRecords(self.activityId, MDL.SuperGoldBoss.BossRankName.TotalScoreRank, data.day) end end self.selectIndex = index self.state_Rank:SetState(1) end end end function UISuperGoldBossRank:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Tab then if data.rankName then UIUtils.SetLabelText(cellTable.txt_Name_Nomal, data.title) UIUtils.SetLabelText(cellTable.txt_Name_Selected, data.title) cellTable.state_ArrowState:SetState(data.rankName == MDL.SuperGoldBoss.BossRankName.TotalScoreRank and 1 or 0) UIUtils.SetActive(cellTable.img_Selected, self.rankSelect == data.rankName) else local dayText = string.FormatByIdsKey("IDS_SuperGoldHeroActivity_HeroTrial_RankHint2", data.day) UIUtils.SetLabel(cellTable.txt_Name_Nomal, dayText) UIUtils.SetLabel(cellTable.txt_Name_Selected, dayText) UIUtils.SetActive(cellTable.img_Lock, data.isLock or false) UIUtils.SetActive(cellTable.group_Tag, UTL.Time.GetTimestampDay(self.activityStartTime) == data.day) end UIUtils.SetActive(cellTable.img_RedDot, false) elseif scrollRect == self.loop_TotalScoreRank then cellTable.state_Bg:SetState(index % 2) self:SetTotalScoreRankCell(cellTable, data, false) elseif scrollRect == self.loop_MaxScoreRank then cellTable.state_Bg:SetState(index % 2) self:SetMaxDamageRankCell(cellTable, data) end end function UISuperGoldBossRank:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Tab then if data.rankName then if data.rankName == MDL.SuperGoldBoss.BossRankName.TotalScoreRank then local activityInfo = MDL.OperationActivity.GetOperationActivityInfo(self.activityType, self.activityId) local diffDay = UTL.Time.GetGameDiffDayCount(UTL.Time.GetServerTimestamp(), activityInfo.startTime) if self.rankSelect ~= data.rankName then for i = 1, diffDay do self.loop_Tab:InsertData(index + i, {day = i}, 1) end local totalDay = UTL.Time.GetGameDiffDayCount(activityInfo.endTime, activityInfo.startTime) if diffDay < totalDay then self.loop_Tab:InsertData(index + diffDay + 1, {day = diffDay + 1, isLock = true}, 1) end end self.loop_Tab:SelectIndex(diffDay) UIUtils.SetActive(cellTable.img_Selected, true) else for i = self.loop_Tab.Count - 2, 1, -1 do self.loop_Tab:RemoveIndex(i) end end self.rankSelect = data.rankName self.context.rankSelect = data.rankName else if data.isLock then CTL.Tips.AddTipsMsg(Const_IDS.IDS_SuperGoldHeroActivity_HeroTrial_RankHint11) end end elseif scrollRect == self.loop_TotalScoreRank then CTL.PlayerInteract.OpenFriendInteractView(data.acid) elseif scrollRect == self.loop_MaxScoreRank then CTL.PlayerInteract.OpenFriendInteractView(data.acid) end end return UISuperGoldBossRank