---@class WB_Main_C:UAEUserWidget ---@field ShowTeamScore UWidgetAnimation ---@field Button_Score UButton ---@field Button_ShowGuide UButton ---@field Image_LeftBG UImage ---@field Image_RightBG UImage ---@field Text_BlueTeamScore UTextBlock ---@field Text_RedTeamScore UTextBlock ---@field TextBlock_Enemy UTextBlock ---@field TextBlock_Round UTextBlock ---@field TextBlock_Self UTextBlock ---@field WB_PlayerSoldiers UWB_PlayerSoldiers_C ---@field WB_PoisonCircle UWB_PoisonCircle_C ---@field WB_SelectParts UWB_SelectParts_C ---@field WB_TeamScore UWB_TeamScore_C ---@field WB_UseBuffs UWB_UseBuffs_C --Edit Below-- ---@type WB_Main_C local WB_Main = { bInitDoOnce = false; ChildWidgets = {}; }; function WB_Main:Construct() WB_Main.SuperClass.Construct(self); self:LuaInit(); end function WB_Main:LuaInit() if self.bInitDoOnce then return; end UITool.BindButtonClicked(self.Button_ShowGuide, function() WidgetManager:ShowPanel(WidgetConfig.EUIType.FaceNotice, false); end, self); UGCLogSystem.Log("[WB_Main:LuaInit] 执行") UITool.BindButtonClicked(self.Button_Score, self.OnClickScore, self); -- 设置大比分 self.TextBlock_Round:SetText("回合1"); -- 设置两边的名字 self.TextBlock_Self:SetText("己方"); self.TextBlock_Enemy:SetText("敌方"); UGCEventSystem.AddListener(EventTypes.UpdateRound, self.OnUpdateRound, self); UGCEventSystem.AddListener(EventTypes.UpdateGameRound, self.OnUpdateGameRound, self); -- 默认隐藏 self.WB_UseBuffs:SetVisibility(ESlateVisibility.Collapsed); self.WB_PlayerSoldiers:LuaInit(); self.WB_PoisonCircle:LuaInit(); if not table.isEmpty(UGCGameSystem.GameState.GameRounds) then self:OnUpdateGameRound(UGCGameSystem.GameState.GameRounds); end self.WB_SelectParts:LuaInit(); self.WB_SelectParts:SetType({ EWeaponPartType.Telescope, EWeaponPartType.Grip, EWeaponPartType.Muzzle, }); self.bInitDoOnce = true; end function WB_Main:OnShowPanel(...) self.WB_TeamScore:SetVisibility(ESlateVisibility.Collapsed); end function WB_Main:Tick(MyGeometry, InDeltaTime) WB_Main.SuperClass.Tick(self, MyGeometry, InDeltaTime) self.WB_PoisonCircle:CustomTick(InDeltaTime); end ---@param InRoundData RoundInfo 回合数据 function WB_Main:OnUpdateRound(InRoundData) self.TextBlock_Round:SetText(string.format("回合%d", InRoundData.CurrRoundTime)); end ---@param InData table { [RoundTime] = TeamId, ... } 游戏赢取的 TeamId function WB_Main:OnUpdateGameRound(InData) local List = {}; for i, TeamId in pairs(InData) do if List[TeamId] == nil then List[TeamId] = 1; else List[TeamId] = 1 + List[TeamId]; end end local TotalCount = table.getCount(InData); -- 这是自己的 local BlueScore = List[DefaultSettings.LocalTeamId]; if BlueScore == nil then BlueScore = 0; end self.Text_BlueTeamScore:SetText(tostring(BlueScore)); self.Text_RedTeamScore:SetText(tostring(TotalCount - BlueScore)); end WB_Main.bIsShowTeamScore = false; function WB_Main:OnClickScore() if not self.WB_TeamScore:IsVisible() then self:PlayAnimation(self.ShowTeamScore, 0, 1, EUMGSequencePlayMode.Forward, 1); else self:PlayAnimation(self.ShowTeamScore, 0, 1, EUMGSequencePlayMode.Reverse, 1); end end -- 设置是否显示界面上的按钮 function WB_Main:SetShowButton(IsShow, ButtonType) if self[ButtonType] == nil then return; end if IsShow then self[ButtonType]:SetVisibility(ESlateVisibility.SelfHitTestInvisible); else self[ButtonType]:SetVisibility(ESlateVisibility.Collapsed); end end function WB_Main:ConfigButton(ButtonType, ConfigStr, InConfig) if self.ChildWidgets[ButtonType] == nil then self.ChildWidgets[ButtonType] = {} end self.ChildWidgets[ButtonType][ConfigStr] = InConfig; end function WB_Main:EnableButton(InStr) self[InStr]:EnableButton(true) end function WB_Main:OnClickTest() end return WB_Main;