---@class WB_CompetitionResponse_C:UUserWidget ---@field Image_Target UImage ---@field SelectButton1 UWB_CompetitionResponse_Item_C ---@field SelectButton2 UWB_CompetitionResponse_Item_C ---@field SelectButton3 UWB_CompetitionResponse_Item_C ---@field SelectButton4 UWB_CompetitionResponse_Item_C ---@field TextBlock_PleaseSelect UTextBlock ---@field TextBlock_ReadyTime UTextBlock ---@field TextBlock_TextTarget UTextBlock ---@field WB_AllPlayerMiniScore UWB_AllPlayerMiniScore_C ---@field WidgetSwitcher_State UWidgetSwitcher ---@field WidgetSwitcher_Target UWidgetSwitcher ---@field WidgetSwitcher_TipText UWidgetSwitcher --Edit Below-- local WB_CompetitionResponse = { bInitDoOnce = false; ItemList = {}; Textures = {}; TexturesColor = {}; TextList = {}; TextColorList = {}; IsReady = false; PlayerSelected = true; LastTime = -1; }; function WB_CompetitionResponse:OnShowPanel() --local MainControlPanel = GameBusinessManager.GetWidgetFromName(ingame, "MainControlPanelTochButton_C") --MainControlPanel:SetVisibility(ESlateVisibility.Collapsed) MiniGameConfig.ClientSetIsUIGame(true) end function WB_CompetitionResponse:OnClosePanel() --local MainControlPanel = GameBusinessManager.GetWidgetFromName(ingame, "MainControlPanelTochButton_C") --MainControlPanel:SetVisibility(ESlateVisibility.SelfHitTestInvisible) MiniGameConfig.ClientSetIsUIGame(false) WidgetManager:ShowPanel(WidgetConfig.EUIType.UIGameBG, false) end function WB_CompetitionResponse:Construct() self.WB_AllPlayerMiniScore:Init() UGCEventSystem.AddListener(EventEnum.ResponseGameReadyState, self.ReadyState, self) UGCEventSystem.AddListener(EventEnum.ResponseGameDifficultyUpgrade, self.DifficultyUpgrade, self) UGCEventSystem.AddListener(EventEnum.ResponseGameSelectCallBack, self.ResponseGameSelectCallBack, self) self.WidgetSwitcher_State:SetActiveWidgetIndex(0) self.ItemList = {self.SelectButton1, self.SelectButton2, self.SelectButton3, self.SelectButton4} for i, v in pairs(self.ItemList) do v:InitItem(i) v:SetSelectCallBack(self.PlayerSelect, self) end local TexturesPath = MiniGameConfig.MiniGameInfo[MiniGameConfig.MiniGameType.CompetitionResponse].GameParam.TexturesPath for i, v in pairs(TexturesPath) do self.Textures[#self.Textures + 1] = UE.LoadObject(v) end self.TexturesColor = MiniGameConfig.MiniGameInfo[MiniGameConfig.MiniGameType.CompetitionResponse].GameParam.TexturesColor --local TextParam = MiniGameConfig.MiniGameInfo[MiniGameConfig.MiniGameType.CompetitionResponse].GameParam.TextParam --for i, v in pairs(TextParam) do -- self.TextList[#self.TextList + 1] = i -- self.TextColorList[#self.TextColorList + 1] = v --end self.TextList = MiniGameConfig.MiniGameInfo[MiniGameConfig.MiniGameType.CompetitionResponse].GameParam.TextParam self.TextColorList = MiniGameConfig.MiniGameInfo[MiniGameConfig.MiniGameType.CompetitionResponse].GameParam.TextColor end -- 难度升级 function WB_CompetitionResponse:DifficultyUpgrade() self.WidgetSwitcher_TipText:SetActiveWidgetIndex(1) end ---@param InSelectParams table {[ID] = {Index, ColorIndex}} function WB_CompetitionResponse:ReadyState(InShowServerTime, InIsPic, TargetIndex, TargetColorIndex, InSelectParams) self.WidgetSwitcher_State:SetActiveWidgetIndex(0) self.ShowServerTime = InShowServerTime self.IsReady = true self.PlayerSelected = true self.TextBlock_PleaseSelect:SetVisibility(ESlateVisibility.Collapsed) -- 设置目标图案或者文字 以及对应颜色 self.IsPic = InIsPic if self.IsPic then self.Image_Target:SetBrushFromTexture(self.Textures[TargetIndex]) self.Image_Target:SetColorAndOpacity(self.TexturesColor[TargetColorIndex]) self.WidgetSwitcher_Target:SetActiveWidgetIndex(0) else self.TextBlock_TextTarget:SetText(self.TextList[TargetIndex]) self.TextBlock_TextTarget:SetColorAndOpacity({SpecifiedColor = self.TextColorList[TargetColorIndex], ColorUseRule=0}) self.WidgetSwitcher_Target:SetActiveWidgetIndex(1) end self.SelectParams = InSelectParams -- 设置按键UI图案或者文字 以及对应颜色 self:SetSelectButtonParam(self.IsPic, self.SelectParams) end function WB_CompetitionResponse:Tick(MyGeometry, InDeltaTime) if self.IsReady then local NowServerTime = UGCGameSystem.GameState:GetServerGameTime() if self.ShowServerTime <= NowServerTime then self:ShowTarget() else -- 修改秒数 local ShowTime = math.floor(self.ShowServerTime - NowServerTime) self.TextBlock_ReadyTime:SetText(tostring(ShowTime)) -- 播放读秒音效 if ShowTime ~= self.LastTime then self.LastTime = ShowTime SoundSystem.PlaySound(SoundSystem.ESound.Clock) end end end end function WB_CompetitionResponse:ShowTarget() self.IsReady = false self.PlayerSelected = false self.TextBlock_PleaseSelect:SetVisibility(ESlateVisibility.SelfHitTestInvisible) -- 显示目标图案或文字 self.WidgetSwitcher_State:SetActiveWidgetIndex(1) -- 播放音效 --SoundSystem.PlaySound(SoundSystem.ESound.) end ---@param InSelectParams table {[ID] = {Index, ColorIndex}} function WB_CompetitionResponse:SetSelectButtonParam(InIsPic, InSelectParams) for i, v in pairs(InSelectParams) do if self.ItemList[i] then if InIsPic then self.ItemList[i]:SetShowImage(self.Textures[v.Index], self.TexturesColor[v.ColorIndex]) else self.ItemList[i]:SetShowText(self.TextList[v.Index], self.TextColorList[v.ColorIndex]) end end end end function WB_CompetitionResponse:PlayerSelect(Index) if self.PlayerSelected == false then -- 发送RPC -- 设置按键已选择 self.PlayerSelected = true for i, v in pairs(self.ItemList) do v:SetShowSelect(true, Index) end UGCSendRPCSystem.RPCEvent(nil, EventEnum.ResponseGamePlayerSelect, UGCSystemLibrary.GetLocalPlayerKey(), Index) end end function WB_CompetitionResponse:ResponseGameSelectCallBack(IsRight, PlayerKey) if PlayerKey == UGCSystemLibrary.GetLocalPlayerKey() then if IsRight then SoundSystem.PlaySound(SoundSystem.ESound.Right) else SoundSystem.PlaySound(SoundSystem.ESound.Error) end else SoundSystem.PlaySound(SoundSystem.ESound.IsReady) end end -- function WB_CompetitionResponse:Destruct() -- end return WB_CompetitionResponse;