local UIHeroMatch1v1Stage1_Filtration = UIViewClass() function UIHeroMatch1v1Stage1_Filtration:OnOpened(context) self.hasGetMyPower = false self:RegistSystemEvent(EventID.UI_RefreshRankInfo, self.RefreshHeroMatch1v1Rank) self:RegistSystemEvent(EventID.UI_FreeLineUp_RefreshUI, self.UpdateMyPower) self:RefreshHeroMatch1v1Rank(MDL.Rank.RankType.HeroMatch1v1) self:UpdateRankListRepeatFunc() end ---@public 筛选赛匹配阶段刷新排行榜 function UIHeroMatch1v1Stage1_Filtration:UpdateRankListRepeatFunc(deltaTime, timeSinceUpdate) self.curMatchTimeID = MDL.HeroMatch1v1.GetCurMatchTimeID() self.winnerStageInfo = MDL.HeroMatch1v1.GetMatchStageInfo(MDL.HeroMatch1v1.GetCurStageID()) local MatchTime = DataSheetManager.MatchTime:GetDataByID(self.curMatchTimeID) if self.curMatchTimeID >= MDL.HeroMatch1v1.Enum_BigStage.Display or self.winnerStageInfo.state == MDL.HeroMatch1v1.Enum_State.Finish or not UTL.Time.IsServerInOpeningTime(MatchTime.StartTime, MatchTime.EndTime) then -- 不在筛选赛时间范围内,停止更新 self:StopRepeatFunc(self.UpdateRankListRepeatFunc) self.updateRankHandle = nil else if not self.updateRankHandle then self:StartRepeatFunc(self.UpdateRankListRepeatFunc, 5) self.updateRankHandle = true end end MDL.Rank.GetRankInfoReq(MDL.Rank.RankType.HeroMatch1v1, {isPreRank = false}, CTL.Rank.SortType.MyServer) end function UIHeroMatch1v1Stage1_Filtration:OnCellInit(scrollRect, index, cellTable, data) cellTable.state_Bg:SetState(data.index % 2) self:SetRankCell(cellTable, data) end function UIHeroMatch1v1Stage1_Filtration:RefreshHeroMatch1v1Rank(rankType, subData) self.state_Open:SetState(0) self.cdTimer:EndTimer() self.curStageID = MDL.HeroMatch1v1.GetCurStageID() if self.curStageID == MDL.HeroMatch1v1.Stage.Filtration_1 then local MatchTime = DataSheetManager.MatchTime:GetDataByID(MDL.HeroMatch1v1.GetCurMatchTimeID()) if UTL.Time.IsServerInOpeningTime(4, 1) then self:UpdateRankList(rankType) else local timer = UTL.Time.GetServerTimestampByTimeId(MatchTime.StartTime) - UTL.Time.GetServerTimestamp() if timer > 0 then self.state_Open:SetState(1) self.cdTimer:ResetAndBeginTimer(false, timer) else self:UpdateRankList(rankType) end end else self:UpdateRankList(rankType) end end function UIHeroMatch1v1Stage1_Filtration:UpdateRankList(rankType) if rankType == MDL.Rank.RankType.HeroMatch1v1 then self.HeroMatch1v1RankList = MDL.Rank.GetRankInfoDataByType(MDL.Rank.RankType.HeroMatch1v1) self.MyRankInfo = MDL.Rank.GetMyRankInfo() UIUtils.SetActive(self.group_Empty, not self.HeroMatch1v1RankList or #self.HeroMatch1v1RankList == 0) if self.HeroMatch1v1RankList then self.LoopScroll_PlayerInfo:ReloadAll(self.HeroMatch1v1RankList) end -- 设置自己排名信息 self:SetRankCell(self.group_Mine, self.MyRankInfo, true) end end -- 通用设置军团标记 function UIHeroMatch1v1Stage1_Filtration:SetHeroMatch1v1GuildFameNum(obj, guildSingleInfo) UIUtils.SetActive(obj.img_Guild, false) if string.isNilOrEmpty(guildSingleInfo) then obj.state_Guild:SetState(1) else obj.state_Guild:SetState(string.isNilOrEmpty(guildSingleInfo.emblemContent) and 1 or 0) if not string.isNilOrEmpty(guildSingleInfo.emblemContent) then UIUtils.SetLabel(obj.txt_Guild, guildSingleInfo.emblemContent) UIUtils.SetActive(obj.img_Guild, true) local guildEmblemCfg = DataSheetManager.GuildEmblem:GetDataByID(guildSingleInfo.emblemFrame) if guildEmblemCfg then UTL.Item.SetAtlasSprite(obj.img_Guild, "UI_Guild", guildEmblemCfg.Image) end UIUtils.SetLabel(obj.txt_GuildName, guildSingleInfo.guildName) -- 势力名 end end end function UIHeroMatch1v1Stage1_Filtration:UpdateMyPower() local power = MDL.FreeLineUp.GetLineUpTotalGsByFunctionType(MDL.FreeLineUp.FuncType.HeroMatch1v1) UIUtils.SetLabel(self.group_Mine.txt_BR, power) self.hasGetMyPower = true end function UIHeroMatch1v1Stage1_Filtration:SetRankCell(cellTable, data, isMyInfo) local rank = data.index -- 设置排名 if rank == nil or rank <= 0 then UIUtils.SetLabelText(cellTable.group_Rank.txt_Rank, Const_IDS.IDS_Rank_Unranked) cellTable.group_Rank.state_Rank:SetState(3) else UIUtils.SetLabel(cellTable.group_Rank.txt_Rank, rank) cellTable.group_Rank.state_Rank:SetState(rank <= 3 and rank - 1 or 3) end if isMyInfo then UIUtils.SetLabel(cellTable.txt_PlayerName, data.name == "" and BattleDataGetter.GetPlayerName() or data.name) -- 设置名字 --当没有榜单时,需要去拉取上阵战力,而不是当前战力 if data.param2 == nil or data.param2 <= 0 then if self.hasGetMyPower == false then MDL.FreeLineUp.FreeLineUpGetInfoRequest(MDL.FreeLineUp.FuncType.HeroMatch1v1) end else UIUtils.SetLabel(cellTable.txt_BR, data.param2) end UIUtils.SetLabel(cellTable.txt_ServerNum, string.FormatByIdsId(Const_IDS.IDS_Rank_ServerIDS, (data.serverId ~= nil and data.serverId > 0) and data.serverId or MDL.Login.GetServerShowId())) self:SetHeroMatch1v1GuildFameNum(cellTable, MDL.Guild.GetMyGuildInfo()) -- 势力徽记、势力名 else UIUtils.SetLabel(cellTable.txt_PlayerName, data.name) -- 设置名字 UIUtils.SetLabel(cellTable.txt_BR, tostring(data.param2)) -- 战力 UIUtils.SetLabel(cellTable.txt_ServerNum, string.FormatByIdsId(Const_IDS.IDS_Rank_ServerIDS, data.serverId)) self:SetHeroMatch1v1GuildFameNum(cellTable, data.guildSingleInfo) -- 势力徽记、势力名 end UIUtils.SetLabel(cellTable.txt_Win, tostring(data.param1)) -- 筛选赛胜场数 UIUtils.SetLabel(cellTable.txt_Beat, data.thumbsUpNum) -- 筛选赛击败数量 end return UIHeroMatch1v1Stage1_Filtration