51 lines
1.7 KiB
Lua
51 lines
1.7 KiB
Lua
|
---@class WB_GameUnableToStart_C:UUserWidget
|
||
|
---@field Button_ReturnToLobby UButton
|
||
|
---@field TextBlock_ReturnToLobby UTextBlock
|
||
|
--Edit Below--
|
||
|
---@type WB_GameUnableToStart_C
|
||
|
local WB_GameUnableToStart = {
|
||
|
bInitDoOnce = false;
|
||
|
OnceReturnToLobby = false;
|
||
|
DelayReturnToLobbyTime = 15.0;
|
||
|
};
|
||
|
|
||
|
|
||
|
function WB_GameUnableToStart:Construct()
|
||
|
WidgetLibrary.BindButtonClicked(self.Button_ReturnToLobby, self.Button_ReturnToLobby_OnClicked, self)
|
||
|
end
|
||
|
|
||
|
function WB_GameUnableToStart:OnShowPanel()
|
||
|
self:DelayReturnToLobby()
|
||
|
end
|
||
|
|
||
|
|
||
|
function WB_GameUnableToStart:DelayReturnToLobby()
|
||
|
self.EndGameTime = KismetSystemLibrary.GetGameTimeInSeconds(self)
|
||
|
self.DelayReturnToLobbyHandle = UGCEventSystem.SetTimerLoop(
|
||
|
self,
|
||
|
function ()
|
||
|
local NowTime = KismetSystemLibrary.GetGameTimeInSeconds(self)
|
||
|
local ShowTime = math.floor(self.DelayReturnToLobbyTime - (NowTime - self.EndGameTime))
|
||
|
ShowTime = ShowTime >= 0 and ShowTime or 0
|
||
|
self.TextBlock_ReturnToLobby:SetText(string.format("返回大厅(%ds)", ShowTime))
|
||
|
if ShowTime <= 0 then
|
||
|
self:Button_ReturnToLobby_OnClicked()
|
||
|
end
|
||
|
end,
|
||
|
0.5
|
||
|
)
|
||
|
end
|
||
|
|
||
|
function WB_GameUnableToStart:Button_ReturnToLobby_OnClicked()
|
||
|
if self.OnceReturnToLobby then return end
|
||
|
if self.DelayReturnToLobbyHandle then
|
||
|
UGCEventSystem.StopTimer(self.DelayReturnToLobbyHandle)
|
||
|
self.DelayReturnToLobbyHandle = nil
|
||
|
end
|
||
|
self.OnceReturnToLobby = true
|
||
|
UGCGameSystem.ReturnToLobby()
|
||
|
UGCLogSystem.Log("[WB_GameUnableToStart_Button_ReturnToLobby_OnClicked]")
|
||
|
SoundSystem.PlaySound(SoundSystem.ESound.Btn)
|
||
|
end
|
||
|
|
||
|
return WB_GameUnableToStart;
|