---@class WB_BreakThroughSettlement_C:UUserWidget ---@field Button_AutoReturnToLobby UButton ---@field Button_share UButton ---@field CanvasPanel_Result UCanvasPanel ---@field Image_3 UImage ---@field Image_Left UImage ---@field Image_Right UImage ---@field Image_titlebg UImage ---@field TextBlock_AutoReturnToLobby UTextBlock ---@field TextBlock_LeftName UTextBlock ---@field TextBlock_LeftTime UTextBlock ---@field TextBlock_Levels2_2 UTextBlock ---@field TextBlock_RightName UTextBlock ---@field TextBlock_RightTime UTextBlock ---@field UIParticleEmitter_95 UUIParticleEmitter ---@field VerticalBox_Left UVerticalBox ---@field VerticalBox_Right UVerticalBox ---@field WidgetSwitcher_Win UWidgetSwitcher --Edit Below-- local WB_TeamSettlement = { bInitDoOnce = false; LeftTeamType = 1; RightTeamType = 2; }; function WB_TeamSettlement:Construct() --UGCEventSystem.AddListener(EventEnum.UpdatePlayerScoreData, self.UpdateRank, self); --UGCEventSystem.AddListener(EventEnum.UpdatePlayerRank, self.UpdateRank, self); WidgetLibrary.BindButtonClicked(self.Button_AutoReturnToLobby, self.Button_AutoReturnToLobby_OnClicked, self) WidgetLibrary.BindButtonClicked(self.Button_share, self.ShareSettlement, self) self:SetItemTeam() for i = 0, self.VerticalBox_Left:GetChildrenCount() - 1 do local ItemLeftInst = self.VerticalBox_Left:GetChildAt(i) local ItemRightInst = self.VerticalBox_Right:GetChildAt(i) ItemLeftInst:SetIndex(i + 1) ItemRightInst:SetIndex(i + 1) end end function WB_TeamSettlement:OnShowPanel() self:AutoReturnToLobby() self:UpdateRank() UGCEventSystem.AddListener(EventEnum.UpdateTeamBreakThroughTime, self.UpdateRank, self) end function WB_TeamSettlement:SetItemTeam() local LocalPlayerTeamID = UGCPlayerControllerSystem.GetTeamID(UGCSystemLibrary.GetLocalPlayerController()) if LocalPlayerTeamID == TeamConfig.TeamType.CT then self.LeftTeamType, self.RightTeamType = TeamConfig.TeamType.CT, TeamConfig.TeamType.T else self.LeftTeamType, self.RightTeamType = TeamConfig.TeamType.T, TeamConfig.TeamType.CT end for i = 0, self.VerticalBox_Left:GetChildrenCount() - 1 do local ItemLeftInst = self.VerticalBox_Left:GetChildAt(i) local ItemRightInst = self.VerticalBox_Right:GetChildAt(i) ItemLeftInst:SetTeam(TeamConfig.TeamType.CT) ItemRightInst:SetTeam(TeamConfig.TeamType.T) end end function WB_TeamSettlement:UpdateRank() UGCLogSystem.Log("[WB_TeamSettlement_UpdateRank]") local LeftScore = UGCGameSystem.GameState:GetTeamBreakThroughTime(self.LeftTeamType) local RightScore = UGCGameSystem.GameState:GetTeamBreakThroughTime(self.RightTeamType) self.TextBlock_LeftTime:SetText((LeftScore > 0 and UGCSystemLibrary.formatTime(LeftScore, true, false, false) or "--")) self.TextBlock_RightTime:SetText((RightScore > 0 and UGCSystemLibrary.formatTime(RightScore, true, false, false) or "--")) -- 设置胜利图标 if LeftScore == RightScore then self.WidgetSwitcher_Win:SetActiveWidgetIndex(2) else self.WidgetSwitcher_Win:SetActiveWidgetIndex(0) if LeftScore < 0 or (RightScore > 0 and LeftScore > RightScore) then self.WidgetSwitcher_Win:SetActiveWidgetIndex(1) else self.WidgetSwitcher_Win:SetActiveWidgetIndex(0) end end local RankData = PlayerScoreSystem.GetTeamRank() UGCLogSystem.LogTree("[WB_TeamRank_UpdateRank]", RankData) for i = 0, self.VerticalBox_Left:GetChildrenCount() - 1 do local ItemLeftInst = self.VerticalBox_Left:GetChildAt(i) local ItemRightInst = self.VerticalBox_Right:GetChildAt(i) local PlayerKeyLeft = RankData[self.LeftTeamType] and RankData[self.LeftTeamType][i + 1] or nil local PlayerKeyRight = RankData[self.RightTeamType] and RankData[self.RightTeamType][i + 1] or nil if PlayerKeyLeft then ItemLeftInst:SetVisibility(ESlateVisibility.SelfHitTestInvisible) ItemLeftInst:InitRankInfo(PlayerKeyLeft) else ItemLeftInst:SetVisibility(ESlateVisibility.Collapsed) end if PlayerKeyRight then ItemRightInst:SetVisibility(ESlateVisibility.SelfHitTestInvisible) ItemRightInst:InitRankInfo(PlayerKeyRight) else ItemRightInst:SetVisibility(ESlateVisibility.Collapsed) end end end function WB_TeamSettlement:AutoReturnToLobby() self.DelayReturnToLobbyTime = GlobalConfigs.GameSetting.DelayReturnToLobbyTime self.SettlementTime = KismetSystemLibrary.GetGameTimeInSeconds(self) self.DelayReturnToLobbyTimerHandle = UGCEventSystem.SetTimerLoop( self, function () local NowTime = KismetSystemLibrary.GetGameTimeInSeconds(self) local ShowTime = math.floor(self.DelayReturnToLobbyTime - (NowTime - self.SettlementTime)) ShowTime = ShowTime >= 0 and ShowTime or 0 self.TextBlock_AutoReturnToLobby:SetText(string.format("返回大厅(%ds)", ShowTime)) if ShowTime <= 0 then self:Button_AutoReturnToLobby_OnClicked() end end, 0.5 ) end function WB_TeamSettlement:Button_AutoReturnToLobby_OnClicked() if UGCGameSystem.GameState.GameStateType ~= CustomEnum.EGameState.End then return end if self == nil or self.DoOnceReturnToLobby then return end if self.DelayReturnToLobbyTimerHandle then UGCEventSystem.StopTimer(self.DelayReturnToLobbyTimerHandle) self.DelayReturnToLobbyTimerHandle = nil end self.DoOnceReturnToLobby = true UGCGameSystem.ReturnToLobby() UGCLogSystem.Log("[WB_TeamSettlement_Button_AutoReturnToLobby_OnClicked]") end --- 分享战绩 function WB_TeamSettlement:ShareSettlement() UGCWidgetManagerSystem.Share(); end return WB_TeamSettlement;