local UIReplayMain = UIViewClass() --时间参数 local timeStateEnum = { Today = 1, --最新 MoreDay = 2,--近期 } local rightTabStateEnum = { MyServer = 1 , --本服 WarZone = 2, --战区 AllServer = 3, --全服 MyVideo = 4, --我的视频 } local leftTabStateEnum = { PVP = 1, --1v1 BC = 2, --无双挑战 MUlTIPVP = 3, --3V3 } local timeStateEnumIds = { [timeStateEnum.Today] = Const_IDS.IDS_FairPlayReplay_Today, [timeStateEnum.MoreDay] = Const_IDS.IDS_FairPlayReplay_MoreDay, } local sortStateEnumIds = { [CTL.Replay.SortStateEnum.SortByScore] = Const_IDS.IDS_FairPlayReplay_SortByScore, [CTL.Replay.SortStateEnum.SortByHot] = Const_IDS.IDS_FairPlayReplay_SortByHot, } local rankTypeArray = { [leftTabStateEnum.PVP] = { [rightTabStateEnum.MyServer] = { [timeStateEnum.Today] ={ MDL.Rank.RankType.FairPlayReplay1v1MyServer, -- 公平竞技1v1本服视频榜单 }, [timeStateEnum.MoreDay] ={ MDL.Rank.RankType.FairPlayReplay1v1MyServerNDay, --公平竞技1v1本服N日视频榜单 }, }, [rightTabStateEnum.WarZone] = { [timeStateEnum.Today] ={ MDL.Rank.RankType.FairPlayReplay1v1WarZone, --公平竞技1v1战区视频榜单 }, [timeStateEnum.MoreDay] ={ MDL.Rank.RankType.FairPlayReplay1v1WarZoneNDay, --公平竞技1v1战区N日视频榜单 }, }, [rightTabStateEnum.AllServer] = { [timeStateEnum.Today] ={ MDL.Rank.RankType.FairPlayReplay1v1AllServer, --公平竞技1v1全服视频榜单 }, [timeStateEnum.MoreDay] ={ MDL.Rank.RankType.FairPlayReplay1v1AllServerNDay, --公平竞技1v1全服N日视频榜单 }, }, }, [leftTabStateEnum.MUlTIPVP] = { [rightTabStateEnum.MyServer] = { [timeStateEnum.Today] ={ MDL.Rank.RankType.FairPlayReplay3v3MyServer, --公平竞技3v3本服视频榜单 }, [timeStateEnum.MoreDay] ={ MDL.Rank.RankType.FairPlayReplay3v3MyServerNDay, --公平竞技3v3本服N日视频榜单 }, }, [rightTabStateEnum.WarZone] = { [timeStateEnum.Today] ={ MDL.Rank.RankType.FairPlayReplay3v3WarZone, --公平竞技3v3战区视频榜单 }, [timeStateEnum.MoreDay] ={ MDL.Rank.RankType.FairPlayReplay3v3WarZoneNDay, --公平竞技3v3战区N日视频榜单 }, }, [rightTabStateEnum.AllServer] = { [timeStateEnum.Today] ={ MDL.Rank.RankType.FairPlayReplay3v3AllServer, --公平竞技3v3全服视频榜单 }, [timeStateEnum.MoreDay] ={ MDL.Rank.RankType.FairPlayReplay3v3AllServerNDay, --公平竞技3v3全服N日视频榜单 }, }, }, [leftTabStateEnum.BC] = { [rightTabStateEnum.MyServer] = { MDL.Rank.RankType.FairPlayReplayBCMyServer, --公平竞技无双挑战本服视频榜单 }, [rightTabStateEnum.WarZone] = { MDL.Rank.RankType.FairPlayReplayBCWarZone, --公平竞技无双挑战战区视频榜单 }, [rightTabStateEnum.AllServer] = { MDL.Rank.RankType.FairPlayReplayBCAllServer, --公平竞技无双挑战全服视频榜单 }, }, } --段位 local LevelImgPath = ConstAssetPathConfig.LevelImgPath --region 生命周期方法 function UIReplayMain:OnOpened(context) self:RegistSystemEvent(EventID.UI_Replay_RefreshRankInfo,self.RefreshRankInfo) self:RegistSystemEvent(EventID.UI_Replay_SelectHero,self.RefreshHeroShow) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title,Const_IDS.IDS_FairPlayReplay_Title) UTL.Toggle.InitToggleGroupByIDS(self.group_LeftBtn.toggles_Group, "txt",{Const_IDS.IDS_1v1Sync_Title}) self.group_LeftBtn.toggles_Group:SelectIndex(0) self:Init() MDL.Rank.GetRankInfoReq(self.rankType) end function UIReplayMain:Init() --按1v1\本服or战区\全部主将\最新\积分显示 if CTL.WarZone.IsWarZoneOpen() then self.rankType = MDL.Rank.RankType.FairPlayReplay1v1WarZone --默认用战区1V1榜单 else self.rankType = MDL.Rank.RankType.FairPlayReplay1v1MyServer --默认用本服1V1榜单 end self.leftTabState = leftTabStateEnum.PVP if CTL.WarZone.IsWarZoneOpen() then self.rightTabState = rightTabStateEnum.WarZone else self.rightTabState = rightTabStateEnum.MyServer end self.timeState = timeStateEnum.Today self.sortState = CTL.Replay.SortStateEnum.SortByScore --显示本服 or 战区 if CTL.WarZone.IsWarZoneOpen() then UTL.Toggle.InitToggleGroupByIDS(self.toggle_TopGroup, "txt",{Const_IDS.IDS_FairPlayReplay_Warzone,Const_IDS.IDS_FairPlayReplay_AllServer}) else UTL.Toggle.InitToggleGroupByIDS(self.toggle_TopGroup, "txt",{Const_IDS.IDS_FairPlayReplay_MyServer,Const_IDS.IDS_FairPlayReplay_AllServer}) end self.toggle_TopGroup:SelectIndex(0) self.group_Hero.toggle_Hero:SelectIndex(0) self.heroId = nil UIUtils.SetActive(self.group_Hero.heroHead.gameObject,false) UIUtils.SetActive(self.group_Hero.img_SwitchHero,false) self:ShowTimeStateInfo() self:ShowSortStateInfo() end function UIReplayMain:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_Close) end function UIReplayMain:OnButtonClicked(comp) if comp == self.btn_ChooseTime then --按时间查询 if self.state_Time1 == false or self.state_Time1 == nil then self.state_Time:SetState(1) self.loop_ChooseTime:ReloadAll(timeStateEnumIds) self.state_Time1 = true CTL.Sound.PlayGameSound("UI_expand") else self.state_Time:SetState(0) self.state_Time1 = false CTL.Sound.PlayGameSound("UI_fold") end self.state_Sort:SetState(0) self.state_Sort1 = false elseif comp == self.btn_ChooseSort then --排序 if self.state_Sort1 == false or self.state_Sort1 == nil then self.state_Sort:SetState(1) self.loop_ChooseSort:ReloadAll(sortStateEnumIds) self.state_Sort1 = true CTL.Sound.PlayGameSound("UI_expand") else self.state_Sort:SetState(0) self.state_Sort1 = false CTL.Sound.PlayGameSound("UI_fold") end self.state_Time:SetState(0) self.state_Time1 = false elseif comp == self.group_Hero.uiclick_Head then --切换主将 self:SwitchHero() elseif comp == self.Bottom then self.state_Time:SetState(0) self.state_Time1 = false self.state_Sort:SetState(0) self.state_Sort1 = false CTL.Sound.PlayGameSound("UI_fold") elseif comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.FairPlayReplay}) end end function UIReplayMain:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_ChooseTime then UIUtils.SetLabelText(cellTable.txt_Choose01,data) elseif scrollRect == self.loop_ChooseSort then UIUtils.SetLabelText(cellTable.txt_Choose01,data) elseif scrollRect == self.loop_11and33 then if self.leftTabState == leftTabStateEnum.PVP then local replayInfo = MDL.Replay.ParseRankPerRecordReplayInfoFromBytes(data.extraParamBytes) self:Init1V1GroupCell(cellTable.group_Blue,replayInfo.infos1,replayInfo.winCamp == 1,true,cellTable.group_BlueResult,cellTable.group_RedResult) self:Init1V1GroupCell(cellTable.group_Red,replayInfo.infos2,replayInfo.winCamp == 2,false,cellTable.group_BlueResult,cellTable.group_RedResult) --时长、热度 UIUtils.SetLabel(cellTable.txt_Time,os.date(UTL.Time.FormatDateEnum.MS, replayInfo.fightTime)) local hot = CTL.Replay.GetHot(data.thumbsUpNum,data.param1) UIUtils.SetLabel(cellTable.txt_Hot,tostring(hot)) elseif self.leftTabState == leftTabStateEnum.MUlTIPVP then end end end function UIReplayMain:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_ChooseTime then self.state_Time:SetState(0) self.state_Time1 = false self.timeState = index + 1 self:ShowTimeStateInfo() self:GetRankInfoByRanktype() CTL.Sound.PlayGameSound("UI_fold") elseif scrollRect == self.loop_ChooseSort then self.state_Sort:SetState(0) self.state_Sort1 = false self.sortState = index + 1 self:ShowSortStateInfo() self:ReloadRankData(self.allRankInfo) CTL.Sound.PlayGameSound("UI_fold") elseif scrollRect == self.loop_11and33 then if target == cellTable.btn_Play then if self.leftTabState == leftTabStateEnum.PVP then UTL.MessageBox.ShowOKCancelBox(nil, Const_IDS.IDS_FairPlayReplay_ConfirmWatchTips, function() local replayInfo = MDL.Replay.ParseRankPerRecordReplayInfoFromBytes(data.extraParamBytes) MDL.Replay.FairPlayReplayReq(self.rankType,data.replayId,replayInfo.url) end) elseif self.leftTabState == leftTabStateEnum.MUlTIPVP then end elseif target == cellTable.group_Blue.btn_ClickName then local replayInfo = MDL.Replay.ParseRankPerRecordReplayInfoFromBytes(data.extraParamBytes) local acid = replayInfo.infos1[1].acid if acid ~= BattleDataGetter.GetAcID() and not self:IsRobot(acid) then MDL.PlayerInteract.GetPlayerInteractiveInfoReq(replayInfo.infos1[1].acid) end elseif target == cellTable.group_Red.btn_ClickName then local replayInfo = MDL.Replay.ParseRankPerRecordReplayInfoFromBytes(data.extraParamBytes) local acid = replayInfo.infos2[1].acid if replayInfo.infos2[1].acid ~= BattleDataGetter.GetAcID() and not self:IsRobot(acid) then MDL.PlayerInteract.GetPlayerInteractiveInfoReq(replayInfo.infos2[1].acid) end end end end --是否为机器人 function UIReplayMain:IsRobot(acid) return string.find(acid, "Robot") end function UIReplayMain:OnValueChanged(comp, index) if comp == self.group_Hero.toggle_Hero then if index == 0 then --全部 self:RefreshHeroShow(true) elseif index == 1 then --单个主将 self:RefreshHeroShow(false,self.heroId) end elseif comp == self.toggle_TopGroup then --本服or战区/全服 if index == 0 then --本服or战区 --当前已经是全服才处理 if self.rightTabState == rightTabStateEnum.AllServer then if CTL.WarZone.IsWarZoneOpen() then self.rightTabState = rightTabStateEnum.WarZone else self.rightTabState = rightTabStateEnum.MyServer end self:GetRankInfoByRanktype() end elseif index == 1 then --全服 --当前已经是本服or战区才处理 if self.rightTabState == rightTabStateEnum.WarZone or self.rightTabState == rightTabStateEnum.MyServer then self.rightTabState = rightTabStateEnum.AllServer self:GetRankInfoByRanktype() end end end end --endregion --刷新榜单信息 function UIReplayMain:RefreshRankInfo(rankInfo) self.allRankInfo = rankInfo self:ReloadRankData(self.allRankInfo) end function UIReplayMain:ReloadRankData(rankInfo) if rankInfo then --先根据主将ID筛选 self.currentRankInfo = CTL.Replay.GetRankInfoByHeroId(rankInfo,self.heroId) --重新排序 self.currentRankInfo = CTL.Replay.ResortRankInfo(self.currentRankInfo,self.sortState) self.loop_11and33:ClearCells() UIUtils.SetActive(self.group_Empty, #self.currentRankInfo == 0) for i = 1, #self.currentRankInfo do local data = self.currentRankInfo[i] local replayInfo = MDL.Replay.ParseRankPerRecordReplayInfoFromBytes(data.extraParamBytes) --筛掉小于30秒的战斗,防止刷分的回放频繁出现 if replayInfo.fightTime > 30 then if self.leftTabState == leftTabStateEnum.PVP then self.loop_11and33:AddData(data, 0) elseif self.leftTabState == leftTabStateEnum.MUlTIPVP then self.loop_11and33:AddData(data, 1) end end end else UIUtils.SetActive(self.group_Empty,true) end end function UIReplayMain:Init1V1GroupCell(group, campInfo, isWin,isBlue,group_BlueResult,group_RedResult) --名字、积分 if campInfo[1].acid == BattleDataGetter.GetAcID() then UIUtils.SetLabel(group.txt_Name,UTL.Color.FormatTextByColor(UTL.Color.Green, campInfo[1].name)) elseif isBlue then UIUtils.SetLabel(group.txt_Name,UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Blue, campInfo[1].name)) else UIUtils.SetLabel(group.txt_Name,UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Red, campInfo[1].name)) end UIUtils.SetLabel(group.txt_Score,string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_FairPlayReplay_Score), tostring(campInfo[1].point))) local group_Members = {} table.insert(group_Members, group.group_Member01) table.insert(group_Members, group.group_Member02) table.insert(group_Members, group.group_Member03) --阵容 for i = 1, #group_Members do local heroId = campInfo[1].heroIds[2 * i - 1] local isHeroAwaken = campInfo[1].isHeroAwakens[2 * i - 1] if isHeroAwaken then CTL.Character.SetPortraitAndFrame(group_Members[i].group_Member01, CTL.HeroAwaken.GetAwakenPortraitId(heroId)) else local portraitData1 = MDL.Character.GetFullPortraitDataByHeroID(heroId) if portraitData1 then CTL.Character.SetPortraitAndFrame(group_Members[i].group_Member01, portraitData1.ID) end end if campInfo[1].isHeroAwakens[2 * i] then CTL.Character.SetPortraitAndFrame(group_Members[i].group_Member01, CTL.HeroAwaken.GetAwakenPortraitId(campInfo[1].heroIds[2 * i])) else local portraitData2 = MDL.Character.GetFullPortraitDataByHeroID(campInfo[1].heroIds[2 * i]) if portraitData2 then CTL.Character.SetPortraitAndFrame(group_Members[i].group_Member001, portraitData2.ID) end end UIUtils.SetActive(group_Members[i].effect_Seclected,heroId == self.heroId) end --段位 local levelData = DataSheetManager.SyncSoloData:GetDataByLevelID(campInfo[1].dan) if levelData then UIUtils.SetImageByAssetBundle(group.img_Level, string.format(LevelImgPath,levelData.LevelSmallIcon)) else logging.error(LTAG.ERROR,"SyncSoloData not find",campInfo.dan) end --胜利失败展示 if isBlue then self:SetWinOfFailResult(group_BlueResult,isWin) else self:SetWinOfFailResult(group_RedResult,isWin) end end function UIReplayMain:SetWinOfFailResult(group,isWin) UIUtils.SetActive(group.gameObject, true) if isWin then if group.loc_icon.CurState == 1 then UIUtils.SetLabelText(group.txt_result, Const_IDS.IDS_GuildWar_Win) group.state_Color:SetState(0) else UIUtils.SetLocalizationImage(group.img_Win, "1v1_msz_s.png") end else if group.loc_icon.CurState == 1 then UIUtils.SetLabelText(group.txt_result, Const_IDS.IDS_GuildWar_Lose) group.state_Color:SetState(0) else UIUtils.SetLocalizationImage(group.img_Win, "1v1_msz_b.png") end end end --按最新 还是按近期显示 function UIReplayMain:ShowTimeStateInfo() UIUtils.SetLabelText(self.txt_ChooseTime,timeStateEnumIds[self.timeState]) end function UIReplayMain:GetRankInfoByRanktype() local temp = rankTypeArray[self.leftTabState][self.rightTabState] if type(temp) == "table" then self.rankType = temp[self.timeState][1] else self.rankType = temp end MDL.Rank.GetRankInfoReq(self.rankType) end -- selectAll 为true,选全部主将 function UIReplayMain:RefreshHeroShow(selectAll,heroId) if selectAll then self.heroId = nil UIUtils.SetActive(self.group_Hero.heroHead.gameObject,false) UIUtils.SetActive(self.group_Hero.img_SwitchHero,false) UIUtils.SetActive(self.group_Hero.uiclick_Head,false) else UIUtils.SetActive(self.group_Hero.heroHead.gameObject,true) UIUtils.SetActive(self.group_Hero.img_SwitchHero,true) UIUtils.SetActive(self.group_Hero.uiclick_Head,true) if heroId ~= nil then self.heroId = heroId else self.heroId = 1 end local portraitData = MDL.Character.GetFullPortraitDataByHeroID(self.heroId) if portraitData then CTL.Character.SetPortraitAndFrame(self.group_Hero.heroHead, portraitData.ID) end end self:ReloadRankData(self.allRankInfo) end function UIReplayMain:SwitchHero() local tabType if self.leftTabState == leftTabStateEnum.PVP then tabType = LuaConst.LevelType.SyncPVP elseif self.leftTabData == leftTabStateEnum.MUlTIPVP then tabType = LuaConst.LevelType.SyncTeamPVP end UIManager.OpenView(Const_UI_Lua.UIEnum.UIReplayHeroPopUp,{heroId = self.heroId, levelType = tabType }) end --按积分排序 还是按热度排序 function UIReplayMain:ShowSortStateInfo() UIUtils.SetLabelText(self.txt_ChooseSort,sortStateEnumIds[self.sortState]) end return UIReplayMain