---@class WB_Title2_2_C:UUserWidget ---@field Border_LeftSideTeam UBorder ---@field Border_RightSideTeam UBorder ---@field CanvasPanel_2 UCanvasPanel ---@field CanvasPanel_LeftSidechampion UCanvasPanel ---@field CanvasPanel_RightSidechampion UCanvasPanel ---@field CanvasPanel_ScoreBoard UCanvasPanel ---@field HorizontalBox_8 UHorizontalBox ---@field HorizontalBox_9 UHorizontalBox ---@field HorizontalBox_EnemyKill UHorizontalBox ---@field HorizontalBox_Kill UHorizontalBox ---@field Image_LeftHead UImage ---@field Image_LeftSide_ScoreBG UImage ---@field Image_LeftSide_ScoreBG2 UImage ---@field Image_LeftSide_SlotBG UImage ---@field Image_LeftSideKillBar UImage ---@field Image_RightHead UImage ---@field Image_RightSide_ScoreBG UImage ---@field Image_RightSide_ScoreBG2 UImage ---@field Image_RightSide_SlotBG UImage ---@field Image_RightSideKillBar UImage ---@field TextBlock_EnemyKill UTextBlock ---@field TextBlock_EnemyScore UTextBlock ---@field TextBlock_GameTime UTextBlock ---@field TextBlock_Left UTextBlock ---@field TextBlock_LeftSide_Total_Num UTextBlock ---@field TextBlock_Right UTextBlock ---@field TextBlock_RightSide_Total_Num UTextBlock ---@field TextBlock_SelfKill UTextBlock ---@field TextBlock_SelfScore UTextBlock ---@field TextBlock_Time UTextBlock ---@field WidgetSwitcher_LeftSide_ScoreBG UWidgetSwitcher ---@field WidgetSwitcher_RightSide_ScoreBG UWidgetSwitcher --Edit Below-- ---@type WB_Title2_2_C local WB_Title2 = { bInitDoOnce = false } function WB_Title2:Construct() self:LuaInit(); end function WB_Title2:LuaInit() if self.bInitDoOnce then return ; end self.bInitDoOnce = true; UGCEventSystem.AddListener(EventTypes.GameCountDownTimeChange, self.OnCountDownChange, self); UGCEventSystem.AddListener(EventTypes.UpdateRoundTimes, self.OnUpdateRoundTimes, self); UGCEventSystem.AddListener(EventTypes.UpdateRoundWinners, self.OnUpdateRoundWinners, self); UGCEventSystem.AddListener(EventTypes.UpdateAccountInfo, self.OnUpdateAccountInfo, self) -- 初始化 self.TextBlock_SelfScore:SetText("0"); self.TextBlock_EnemyScore:SetText("0"); self.TextBlock_Time:SetText("0/7"); self.TextBlock_EnemyKill:SetText("0"); self.TextBlock_SelfKill:SetText("0"); self:SetKillCount(0) self:SetEnemyKillCount(0) self:OnUpdateAccountInfo(); local RoundWinners = UE.GetMiniRepData("RoundWinners") if RoundWinners ~= nil then UGCLogSystem.LogTree(string.format("[WB_Title1:LuaInit] RoundWinners ="), RoundWinners) self:OnUpdateRoundWinners(RoundWinners); else self.TextBlock_SelfScore:SetText(0); self.TextBlock_EnemyScore:SetText(0); end local RoundTimes = UE.GetMiniRepData("RoundTimes"); UGCLogSystem.Log("[WB_Title1:LuaInit] RoundTimes = %s", tostring(RoundTimes)) self:OnUpdateRoundTimes(RoundTimes or 0, 7); local RoundDeadTimes = UE.GetMiniRepData("RoundDeadTimes"); if RoundDeadTimes ~= nil then self:SetRoundKill(RoundDeadTimes); UGCLogSystem.LogTree(string.format("[WB_Title1:LuaInit] RoundDeadTimes ="), RoundDeadTimes) else self.TextBlock_SelfKill:SetText(0); self.TextBlock_EnemyKill:SetText(0); self:SetKillCount(0) self:SetEnemyKillCount(0) end end function WB_Title2:OnUpdateAccountInfo() --- 设置名字 for PlayerKey, Info in pairs(UE.GetAccountInfo()) do if Info.TeamID == 1 then self.TextBlock_Left:SetText(Info.PlayerName); UITool.DownloadImage(Info.IconURL, function(Texture) self.Image_LeftHead:SetBrushFromTextureDynamic(Texture); end) else self.TextBlock_Right:SetText(Info.PlayerName); UITool.DownloadImage(Info.IconURL, function(Texture) UGCLogSystem.Log("[WB_Title2:OnUpdateAccountInfo] 执行") self.Image_RightHead:SetBrushFromTextureDynamic(Texture); end) end end end function WB_Title2:OnCountDownChange(InTime) if InTime <= 0 then self.TextBlock_GameTime:SetText("00:00") else self.TextBlock_GameTime:SetText(string.format("%02d:%02d", InTime // 60, InTime % 60)); end end function WB_Title2:OnUpdateRoundTimes(InTimes, InTotal) UGCLogSystem.Log("[WB_Title2:OnUpdateRoundTimes] InTimes = %s, InTotal = %s", tostring(InTimes), tostring(InTotal)); if InTimes ~= nil and InTotal ~= nil then self.TextBlock_Time:SetText(string.format("%d/%d", InTotal - InTimes, InTotal)); end end function WB_Title2:OnUpdateRoundWinners(InWinners) local Rounds = {}; for i, v in pairs(InWinners) do if v.Winner then Rounds[v.Winner] = (Rounds[v.Winner] or 0) + 1; end end UGCLogSystem.LogTree(string.format("[WB_Title2:OnUpdateRoundWinners] Rounds ="), Rounds); for PlayerKey, Times in pairs(Rounds) do local TeamId = UE.GetTeamID(PlayerKey); if TeamId == 1 then self.TextBlock_SelfScore:SetText(Rounds[PlayerKey] or 0); else self.TextBlock_EnemyScore:SetText(Rounds[PlayerKey] or 0); end end end function WB_Title2:SetRoundKill(Kills) self.TextBlock_SelfKill:SetText(0); self.TextBlock_EnemyKill:SetText(0); self:SetKillCount(0) self:SetEnemyKillCount(0) if table.isEmpty(Kills) then return ; end for PlayerKey, Times in pairs(Kills) do local TeamId = UE.GetTeamID(PlayerKey); if TeamId == 1 then self.TextBlock_EnemyKill:SetText(Times); self:SetEnemyKillCount(Times) else self.TextBlock_SelfKill:SetText(Times); self:SetKillCount(Times) end end end function WB_Title2:SetKillCount(Count) for i = 1, self.HorizontalBox_Kill:GetChildrenCount() do local Item = self.HorizontalBox_Kill:GetChildAt(i - 1) if Count >= i then Item:SetActiveWidgetIndex(1) else Item:SetActiveWidgetIndex(0) end end end function WB_Title2:SetEnemyKillCount(Count) for i = 1, self.HorizontalBox_EnemyKill:GetChildrenCount() do local Item = self.HorizontalBox_EnemyKill:GetChildAt(i - 1) if Count >= i then Item:SetActiveWidgetIndex(1) else Item:SetActiveWidgetIndex(0) end end end -- function WB_Title2:Tick(MyGeometry, InDeltaTime) -- end -- function WB_Title2:Destruct() -- end return WB_Title2