--天下会武小组赛 local UIFairSoloTournamentStage1_GroupCompetition = UIViewClass() local TYPE_RANK = 1 function UIFairSoloTournamentStage1_GroupCompetition:OnOpened(context) self.infoList = {} self.indexGroup = {} self:RegistSystemEvent(EventID.UI_FairSoloTournament_ChangeGroupTab, self.OnChangeGroupTab) self:RegistSystemEvent(EventID.UI_FairSoloTournament_RefreshStageInfo, self.OnStageInfoRefresh) self:RegistSystemEvent(EventID.UI_FairSoloTournament_RefreshPlayerInfo, self.ShowPlayersDetail) self:RegistSystemEvent(EventID.UI_FairSoloTournament_UpdateClassPlayerInfo, self.ShowPlayersDetail) self:RegistSystemEvent(EventID.UI_FairSoloTournament_RefreshMyInfo, self.OnStageInfoRefresh) self:RegistSystemEvent(EventID.UI_FairSoloTournament_JumpToPlayer, self.OnJumpToPlayer) UTL.Toggle.InitToggleGroupByIDS(self.group_Toggles01, "txt", { Const_IDS.IDS_FairTournament_RaceBattle, Const_IDS.IDS_FairTournament_BattleRank }) self.group_Toggles01:SetToggleCompActive(1, "img_Line", false) self.group_Toggles01:SetToggleCompActive(2, "img_Line", false) local index = CTL.FairSoloTournament.GetLastGroupSelectIndex() or 0 self.isForceUpdate = true self.group_Toggles01:SelectIndex(index) end function UIFairSoloTournamentStage1_GroupCompetition:OnJumpToPlayer(acid) local group = MDL.FairSoloTournament.GetPlayerGroup(acid) if group then self.selectGroup = group self:OnSelectGroupTab() end end function UIFairSoloTournamentStage1_GroupCompetition:OnClosed() CTL.FairSoloTournament.SetLastGroupSelectIndex(self.selectToggleIndex) end function UIFairSoloTournamentStage1_GroupCompetition:OnChangeGroupTab(tabIndex) self.group_Toggles01:SelectIndex(tabIndex) end function UIFairSoloTournamentStage1_GroupCompetition:OnStageInfoRefresh() self.isForceUpdate = true self:RefreshGroupData() self.loop_FTLeftTab:SelectIndex(self:GetSelectIndex()) --如果是同个cell,selectIndex不会执行,如果isForceUpdate还是true,需要执行下刷新逻辑 if self.isForceUpdate then self:OnSelectGroupTab() self.isForceUpdate = false end end function UIFairSoloTournamentStage1_GroupCompetition:OnValueChanged(comp, index) if comp == self.group_Toggles01 then if self.selectGroupCell and self.selectToggleIndex ~= index then UIUtils.SetActive(self.selectGroupCell.img_UnSelected, true) UIUtils.SetActive(self.selectGroupCell.img_Selected, false) self.selectGroupCell = nil self.isForceUpdate = true end self.selectToggleIndex = index if index == TYPE_RANK then --处于小组赛阶段时请求下最新的胜场数 if MDL.FairSoloTournament.GetCurStageID() == MDL.FairSoloTournament.ConfigStage.Group_1 or MDL.FairSoloTournament.GetCurStageID() == MDL.FairSoloTournament.ConfigStage.Group_2 then MDL.FairSoloTournament.FairTournamentGetClassPlayerInfoReq() end UIUtils.SetActive(self.group_Rank, true) UIUtils.SetActive(self.group_Competition, false) else UIUtils.SetActive(self.group_Rank, false) UIUtils.SetActive(self.group_Competition, true) end self:RefreshGroupData() if self.loop_FTLeftTab.Count > 0 then local targetIndex = self:GetSelectIndex() self.loop_FTLeftTab:SelectIndex(targetIndex) end end end function UIFairSoloTournamentStage1_GroupCompetition:GetSelectIndex() local targetIndex if self.selectGroup then --赛事页签多了个推荐,因此不用-1 if self.selectToggleIndex == TYPE_RANK then targetIndex = math.max(self.selectGroup - 1, 0) else targetIndex = math.max(self.selectGroup, 0) end else targetIndex = 0 end return targetIndex end function UIFairSoloTournamentStage1_GroupCompetition:RefreshGroupData() local moduleInfo = MDL.FairSoloTournament.GetModuleInfo() if moduleInfo then local curStageID = MDL.FairSoloTournament.GetCurStageID() if curStageID > MDL.FairSoloTournament.ConfigStage.Group_2 then self.stageID = MDL.FairSoloTournament.ConfigStage.Group_2 else self.stageID = curStageID end table.clearArray(self.indexGroup) for i = 1, moduleInfo.groupNum do self.indexGroup[i] = i end --赛事多了个推荐页签 if self.selectToggleIndex ~= TYPE_RANK then table.insert(self.indexGroup, 1, 0) end self.loop_FTLeftTab:ReloadAll(self.indexGroup) end end function UIFairSoloTournamentStage1_GroupCompetition:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_FTLeftTab then if data == 0 then UIUtils.SetLabelText(cellTable.txt_Name_Nomal, Const_IDS.IDS_FairTournament_Suggest) UIUtils.SetLabelText(cellTable.txt_Name_Selected, Const_IDS.IDS_FairTournament_Suggest) else local title = string.FormatByIdsId(Const_IDS.IDS_FairTournament_Group, data) cellTable.txt_Name_Nomal.text = title cellTable.txt_Name_Selected.text = title end if self:GetSelectIndex() == index then UIUtils.SetActive(cellTable.img_UnSelected, false) UIUtils.SetActive(cellTable.img_Selected, true) else UIUtils.SetActive(cellTable.img_UnSelected, true) UIUtils.SetActive(cellTable.img_Selected, false) end if MDL.FairSoloTournament.GetGuessingInfoByGroupID(data) then UIUtils.SetActive(cellTable.group_Tag, true) UIUtils.SetLabelText(cellTable.txt_Tag, Const_IDS.IDS_FairTournament_Picked1) else UIUtils.SetActive(cellTable.group_Tag, false) end elseif scrollRect == self.loopScroll_Competition_PlayerInfo then cellTable.txt_GroupNum.text = string.FormatByIdsId(Const_IDS.IDS_FairTournament_Group, CTL.FairSoloTournament.ParseGroupID(data.groupId)) local isBye = string.isNilOrEmpty(data.playerInfos[1].acid) or string.isNilOrEmpty(data.playerInfos[2].acid) if isBye then CTL.FairSoloTournament.SetBattleCellInfo(cellTable.group_PlayerLeft, string.isNilOrEmpty(data.playerInfos[1].acid) and nil or MDL.FairSoloTournament.GetPlayerShowInfo(data.playerInfos[1].acid)) CTL.FairSoloTournament.SetBattleCellInfo(cellTable.group_PlayerRight, string.isNilOrEmpty(data.playerInfos[2].acid) and nil or MDL.FairSoloTournament.GetPlayerShowInfo(data.playerInfos[2].acid)) else CTL.FairSoloTournament.SetBattleCellInfo(cellTable.group_PlayerLeft, MDL.FairSoloTournament.GetPlayerShowInfo(data.playerInfos[1].acid)) CTL.FairSoloTournament.SetBattleCellInfo(cellTable.group_PlayerRight, MDL.FairSoloTournament.GetPlayerShowInfo(data.playerInfos[2].acid)) end local stageInfo = MDL.FairSoloTournament.GetStageInfo(self.stageID) if stageInfo.state == MDL.FairSoloTournament.Enum_State.Ready or stageInfo.state == MDL.FairSoloTournament.Enum_State.Matching then cellTable.state_Match:SetState(0) cellTable.txt_NotStartedInfo.text = string.FormatByIdsId(Const_IDS.IDS_FairTournament_RoundStart, data.turn) cellTable.cdTimer:ResetAndBeginCustomTimer(false, stageInfo.stateEndTime - UTL.Time.GetServerTimestamp(), 0, "{0}:{1}:{2}") elseif stageInfo.state == MDL.FairSoloTournament.Enum_State.Battle then cellTable.cdTimer:EndTimer() if data.isBattleEnd then if isBye then cellTable.state_Match:SetState(3) cellTable.cdTimer:EndTimer() if string.isNilOrEmpty(data.playerInfos[1].acid) then UIUtils.SetLabel(cellTable.txt_WinRightNum, UTL.Color.FormatTextByColor(MDL.HeroMatch1v1.WinColor, data.playerInfos[2].winNum)) UIUtils.SetLabel(cellTable.txt_WinLeftNum, UTL.Color.FormatWhiteColor(data.playerInfos[1].winNum)) else UIUtils.SetLabel(cellTable.txt_WinLeftNum, UTL.Color.FormatTextByColor(MDL.HeroMatch1v1.WinColor, data.playerInfos[1].winNum)) UIUtils.SetLabel(cellTable.txt_WinRightNum, UTL.Color.FormatWhiteColor(data.playerInfos[2].winNum)) end else cellTable.state_Match:SetState(3) local isLeftWin = data.playerInfos[1].winNum > data.playerInfos[2].winNum UIUtils.SetLabel(cellTable.txt_WinLeftNum, isLeftWin and UTL.Color.FormatTextByColor(MDL.HeroMatch1v1.WinColor, data.playerInfos[1].winNum) or UTL.Color.FormatWhiteColor(data.playerInfos[1].winNum)) UIUtils.SetLabel(cellTable.txt_WinRightNum, isLeftWin and UTL.Color.FormatWhiteColor(data.playerInfos[2].winNum) or UTL.Color.FormatTextByColor(MDL.HeroMatch1v1.WinColor, data.playerInfos[2].winNum)) end else cellTable.state_Match:SetState(2) end elseif stageInfo.state == MDL.FairSoloTournament.Enum_State.Roll then cellTable.state_Match:SetState(1) cellTable.cdTimer:EndTimer() elseif stageInfo.state == MDL.FairSoloTournament.Enum_State.BanPick then cellTable.state_Match:SetState(2) cellTable.cdTimer:EndTimer() elseif stageInfo.state == MDL.FairSoloTournament.Enum_State.Finish then cellTable.state_Match:SetState(3) cellTable.cdTimer:EndTimer() local isLeftWin = data.playerInfos[1].winNum > data.playerInfos[2].winNum UIUtils.SetLabel(cellTable.txt_WinLeftNum, isLeftWin and UTL.Color.FormatTextByColor(MDL.HeroMatch1v1.WinColor, data.playerInfos[1].winNum) or UTL.Color.FormatWhiteColor(data.playerInfos[1].winNum)) UIUtils.SetLabel(cellTable.txt_WinRightNum, isLeftWin and UTL.Color.FormatWhiteColor(data.playerInfos[2].winNum) or UTL.Color.FormatTextByColor(MDL.HeroMatch1v1.WinColor, data.playerInfos[2].winNum)) end --有轮空无法观战 if isBye == false then UIUtils.SetActive(cellTable.group_PlayerLeft.btn_LeftWatch, true) UIUtils.SetActive(cellTable.group_PlayerRight.btn_RightWatch, true) else UIUtils.SetActive(cellTable.group_PlayerLeft.btn_LeftWatch, false) UIUtils.SetActive(cellTable.group_PlayerRight.btn_RightWatch, false) end elseif scrollRect == self.loopScroll_Rank_PlayerInfo then UIUtils.SetActive(cellTable.img_Even, index % 2 ~= 0) self:SetRankCell(cellTable, data, false, index + 1) end end function UIFairSoloTournamentStage1_GroupCompetition:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_FTLeftTab then if self.selectGroup == nil or self.selectGroup ~= data or self.isForceUpdate then self.isForceUpdate = false if self.selectGroupCell then UIUtils.SetActive(self.selectGroupCell.img_UnSelected, true) UIUtils.SetActive(self.selectGroupCell.img_Selected, false) end UIUtils.SetActive(cellTable.img_UnSelected, false) UIUtils.SetActive(cellTable.img_Selected, true) self.selectGroupCell = cellTable self.selectGroup = data self:OnSelectGroupTab() end elseif scrollRect == self.loopScroll_Competition_PlayerInfo then if target == cellTable.group_PlayerLeft.btn_LeftWatch then CTL.FairSoloTournament.WatchBattle(data, data.playerInfos[1].gRoomId, data.playerInfos[1].playerId, data.playerInfos[1].acid, self.stageID) elseif target == cellTable.group_PlayerRight.btn_RightWatch then CTL.FairSoloTournament.WatchBattle(data, data.playerInfos[2].gRoomId, data.playerInfos[2].playerId, data.playerInfos[2].acid, self.stageID) elseif target == cellTable.group_PlayerLeft.UIHeroHead.img_PlayerAvatarBg then -- 左边玩家 if data.playerInfos[1].acid ~= BattleDataGetter.GetAcID() then MDL.PlayerInteract.GetPlayerInteractiveInfoReq(data.playerInfos[1].acid) end elseif target == cellTable.group_PlayerRight.UIHeroHead.img_PlayerAvatarBg then -- 右边玩家 if data.playerInfos[2].acid ~= BattleDataGetter.GetAcID() then MDL.PlayerInteract.GetPlayerInteractiveInfoReq(data.playerInfos[2].acid) end end elseif scrollRect == self.loopScroll_Rank_PlayerInfo then if target == cellTable.btn_Guess or target == cellTable.btn_More then CTL.FairSoloTournament.OpenBetKeyBoard(self.selectGroup, data.acid, CTL.FairSoloTournament.ParseBetRate(data.multiplier), self.stageID, 1) end end end --选中页签(排行、赛制) function UIFairSoloTournamentStage1_GroupCompetition:OnSelectGroupTab() local curStageID = self.stageID if self.selectToggleIndex == TYPE_RANK then --排行页签 if curStageID > MDL.FairSoloTournament.ConfigStage.Group_2 then local stageInfo = MDL.FairSoloTournament.GetStageInfo(MDL.FairSoloTournament.ConfigStage.Group_2) if stageInfo == nil then MDL.FairSoloTournament.FairTournamentGetStageInfoReq(MDL.FairSoloTournament.ConfigStage.Group_2) else self:TryShowStageInfo(MDL.FairSoloTournament.ConfigStage.Group_2) end else self:TryShowStageInfo(curStageID) end else --赛制页签 if MDL.FairSoloTournament.IsGroupCompetitionFinish() then UIUtils.SetActive(self.group_Empty, true) self.loopScroll_Competition_PlayerInfo:ClearCells() else UIUtils.SetActive(self.group_Empty, false) self:TryShowStageInfo(curStageID) end end end --尝试设置面板数据,可能数据为空,需要异步请求再刷新 function UIFairSoloTournamentStage1_GroupCompetition:TryShowStageInfo(stageID) if MDL.FairSoloTournament.TryGetAllPlayerInfo(stageID, self.selectGroup) == false then self:ShowPlayersDetail() end end function UIFairSoloTournamentStage1_GroupCompetition:ShowPlayersDetail() table.clearArray(self.infoList) local stageInfo = MDL.FairSoloTournament.GetStageInfo(self.stageID) if self.selectToggleIndex == TYPE_RANK then for _, groupInfo in ipairs(stageInfo.groupInfos) do if (CTL.FairSoloTournament.ParseGroupID(groupInfo.groupId) == self.selectGroup) then for _, playerInfo in ipairs(groupInfo.playerInfos) do if string.isNilOrEmpty(playerInfo.acid) == false then table.insert(self.infoList, playerInfo) end end end end if #self.infoList > 0 then table.sort(self.infoList, CTL.FairSoloTournament.SortByWinNum) UIUtils.SetActive(self.group_RankEmpty, false) self.loopScroll_Rank_PlayerInfo:ReloadAll(self.infoList) local myRank, myData for i, v in ipairs(self.infoList) do if v.acid == BattleDataGetter.GetAcID() then myRank = i myData = v break end end if myData then UIUtils.SetActive(self.group_Mine.gameObject, true) self:SetRankCell(self.group_Mine, myData, true, myRank) else UIUtils.SetActive(self.group_Mine.gameObject, false) end else UIUtils.SetActive(self.group_RankEmpty, true) UIUtils.SetActive(self.group_Mine.gameObject, false) self.loopScroll_Rank_PlayerInfo:ClearCells() end else MDL.FairSoloTournament.FillGroupCompetitionInfo(self.infoList, self.selectGroup) self.loopScroll_Competition_PlayerInfo:ReloadAll(self.infoList) end end --设置排行信息 function UIFairSoloTournamentStage1_GroupCompetition:SetRankCell(comp, data, isMyInfo, rank) --排名 if rank == nil or rank <= 0 then UIUtils.SetLabelText(comp.group_Rank.txt_Rank, Const_IDS.IDS_Rank_Unranked) comp.group_Rank.state_Rank:SetState(3) else UIUtils.SetLabel(comp.group_Rank.txt_Rank, rank) comp.group_Rank.state_Rank:SetState(rank <= 3 and rank - 1 or 3) end --小组赛结束后,显示【出线】标识 if MDL.FairSoloTournament.GetCurStageID() > MDL.FairSoloTournament.ConfigStage.Group_2 then local _, targetRank = CTL.FairSoloTournament.GetGroupPlayerCount() UIUtils.SetActive(comp.group_Sign, rank <= targetRank) else UIUtils.SetActive(comp.group_Sign, false) end --势力 local showInfo = MDL.FairSoloTournament.GetPlayerShowInfo(data.acid) if showInfo then CTL.Guild.SetGuildEmblem(comp.img_Guild, comp.txt_Guild, showInfo.EmblemFrame, showInfo.EmblemContent) comp.txt_GuildName.text = showInfo.name comp.txt_Server.text = CTL.CrossServer.GetServerShowStr(showInfo.ShowServerId) end --胜利场次 comp.txt_Win.text = MDL.FairSoloTournament.GetPlayerGroupWinNum(data.acid) comp.txt_BeatNum.text = MDL.FairSoloTournament.GetPlayerGroupDefeatNum(data.acid) if isMyInfo == false then local guessInfo = MDL.FairSoloTournament.GetGuessingInfoByGroupID_ACID(self.selectGroup, data.acid, true) if guessInfo then comp.state_GuessBg:SetState(1) comp.txt_MoreRate.text = string.FormatByIdsId(Const_IDS.IDS_FairTournament_PickRate, CTL.FairSoloTournament.ParseBetRate(data.multiplier)) else comp.state_GuessBg:SetState(0) comp.txt_NormalRate.text = string.FormatByIdsId(Const_IDS.IDS_FairTournament_PickRate, CTL.FairSoloTournament.ParseBetRate(data.multiplier)) end end end return UIFairSoloTournamentStage1_GroupCompetition