---@class WB_MiniGameFinish_C:UUserWidget ---@field ShowFinish UWidgetAnimation ---@field Button_0 UButton ---@field CanvasPanel_Settlement UCanvasPanel ---@field CanvasPanel_ShowMVP UCanvasPanel ---@field HorizontalBox_MVP UHorizontalBox ---@field Image_3 UImage ---@field TextBlock_Finish UTextBlock ---@field VerticalBox_PlayerRank UVerticalBox --Edit Below-- local WB_MiniGameFinish = { bInitDoOnce = false; LastPlayerScore = {}; }; function WB_MiniGameFinish:Construct() for i = 1, self.VerticalBox_PlayerRank:GetChildrenCount() do local Item = self.VerticalBox_PlayerRank:GetChildAt(i - 1) UGCLogSystem.Log("[WB_MiniGameFinish_Construct] Item:%s", KismetSystemLibrary.GetObjectName(Item)) Item:Init() end end --- AllPlayerScore {{RankNum = uint, PlayerKey = uint, Score = uint}, ...} function WB_MiniGameFinish:OnShowPanel(AllPlayerScore, MiniGameScore, MVPPlayers) self.CanvasPanel_ShowMVP:SetVisibility(ESlateVisibility.Collapsed) self.CanvasPanel_Settlement:SetVisibility(ESlateVisibility.Collapsed) self.TextBlock_Finish:SetVisibility(ESlateVisibility.SelfHitTestInvisible) self.MiniGameScore = MiniGameScore self.MVPPlayers = MVPPlayers self:PlayAnimation(self.ShowFinish, 0, 1, EUMGSequencePlayMode.Forward, 1) SoundSystem.PlaySound(SoundSystem.ESound.GameStart) UGCEventSystem.SetTimer(self, function() self:ShowMVPPanel(AllPlayerScore) end, 2.) end function WB_MiniGameFinish:OnClosePanel() WidgetManager:ClosePanel(WidgetConfig.EUIType.UIGameBG) UGCLogSystem.Log("[WB_MiniGameFinish_OnClosePanel]") end function WB_MiniGameFinish:ShowMVPPanel(AllPlayerScore) self.CanvasPanel_ShowMVP:SetVisibility(ESlateVisibility.SelfHitTestInvisible) self.TextBlock_Finish:SetVisibility(ESlateVisibility.Collapsed) --local RoundMVP = self:GetRoundMVPPlayer(AllPlayerScore) --UGCLogSystem.LogTree("[WB_MiniGameFinish_OnShowPanel]", RoundMVP) local PlayerScoreInfo = {} for i, v in pairs(self.MiniGameScore) do PlayerScoreInfo[#PlayerScoreInfo + 1] = {PlayerKey = i, Score = v} end table.sort(PlayerScoreInfo, function(a, b) return a.Score > b.Score end) for i = 1, self.HorizontalBox_MVP:GetChildrenCount() do local Item = self.HorizontalBox_MVP:GetChildAt(i - 1) --if i <= #RoundMVP then -- Item:UpdatePlayer(RoundMVP[i]) -- Item:SetVisibility(ESlateVisibility.SelfHitTestInvisible) -- UGCLogSystem.Log("[WB_MiniGameFinish_OnShowPanel] i:%s", tostring(i)) --else -- Item:SetVisibility(ESlateVisibility.Collapsed) --end if PlayerScoreInfo[i] then Item:SetVisibility(ESlateVisibility.SelfHitTestInvisible) local PlayerKey = PlayerScoreInfo[i].PlayerKey Item:UpdatePlayer(PlayerKey, self.MiniGameScore[PlayerKey], table.hasValue(self.MVPPlayers, PlayerKey)) else Item:SetVisibility(ESlateVisibility.Collapsed) end end UGCEventSystem.SetTimer(self, function() self:ShowSettlement(AllPlayerScore) end, 4) for i, v in pairs(AllPlayerScore) do self.LastPlayerScore[v.PlayerKey] = v.Score end end function WB_MiniGameFinish:ShowSettlement(AllPlayerScore) self.CanvasPanel_ShowMVP:SetVisibility(ESlateVisibility.Collapsed) self.CanvasPanel_Settlement:SetVisibility(ESlateVisibility.SelfHitTestInvisible) if AllPlayerScore then for i = 1, self.VerticalBox_PlayerRank:GetChildrenCount() do local Item = self.VerticalBox_PlayerRank:GetChildAt(i - 1) local PlayerScoreInfo = AllPlayerScore[i] if PlayerScoreInfo then Item:UpdatePlayerRankInfo(PlayerScoreInfo.RankNum, PlayerScoreInfo, AllPlayerScore) else Item:UpdatePlayerRankInfo(i) end end else UGCLogSystem.LogError("[WB_MiniGameFinish_OnShowPanel] AllPlayerScore is nil") end end function WB_MiniGameFinish:GetRoundMVPPlayer(AllPlayerScore) local RoundScore = {} local MaxScore = -1; for i, v in pairs(AllPlayerScore) do if self.LastPlayerScore[v.PlayerKey] then RoundScore[v.PlayerKey] = v.Score - self.LastPlayerScore[v.PlayerKey] else RoundScore[v.PlayerKey] = v.Score end if RoundScore[v.PlayerKey] > MaxScore then MaxScore = RoundScore[v.PlayerKey] end end local Res = {} for i, v in pairs(RoundScore) do if v == MaxScore then Res[#Res + 1] = i end end return Res end -- function WB_MiniGameFinish:Tick(MyGeometry, InDeltaTime) -- end -- function WB_MiniGameFinish:Destruct() -- end return WB_MiniGameFinish;