65 lines
1.6 KiB
Lua
65 lines
1.6 KiB
Lua
|
---@class WB_GameEnd_C:UUserWidget
|
||
|
---@field Button_Return UButton
|
||
|
---@field Button_Share UButton
|
||
|
---@field TextBlock_Return UTextBlock
|
||
|
---@field WB_KDALine UWB_KDALine_C
|
||
|
---@field WB_PID UWB_PID_C
|
||
|
---@field WidgetSwitcher_GameEnd UWidgetSwitcher
|
||
|
--Edit Below--
|
||
|
---@type WB_GameEnd_C
|
||
|
local WB_GameEnd = { bInitDoOnce = false; };
|
||
|
|
||
|
function WB_GameEnd:Construct()
|
||
|
self:LuaInit();
|
||
|
end
|
||
|
|
||
|
function WB_GameEnd:OnShowPanel(...)
|
||
|
-- 加载即可
|
||
|
self:AutoReturnToLobby();
|
||
|
end
|
||
|
|
||
|
function WB_GameEnd:AutoReturnToLobby()
|
||
|
GlobalTickTool:AddInternalCount(self, function(o, dt, ServerTime, t)
|
||
|
self.TextBlock_Return:SetText("返回大厅(" .. tostring(t) .. ')');
|
||
|
end, 1, DefaultSettings.ReturnToLobbyTime, function(o)
|
||
|
o:OnReturnToLobby();
|
||
|
end);
|
||
|
end
|
||
|
|
||
|
function WB_GameEnd:LuaInit()
|
||
|
if self.bInitDoOnce then return ; end
|
||
|
self.bInitDoOnce = true;
|
||
|
self.Button_Return.OnClicked:Add(self.OnReturnToLobby, self)
|
||
|
UITool.BindButtonToShare(self.Button_Share);
|
||
|
UGCEventSystem.AddListener(EventTypes.AllPlayerKDAChange, self.OnAllPlayerKDAChange, self)
|
||
|
self.TextBlock_Return:SetText("返回大厅");
|
||
|
self.WB_KDALine:LuaInit();
|
||
|
self.WB_PID:LuaInit();
|
||
|
end
|
||
|
|
||
|
function WB_GameEnd:OnAllPlayerKDAChange(InList)
|
||
|
self.WidgetSwitcher_GameEnd:SetActiveWidgetIndex(0);
|
||
|
for i = 1, #InList do
|
||
|
local Item = InList[i];
|
||
|
if i > 3 then break; end
|
||
|
if Item.PlayerKey == LocalPlayerKey then
|
||
|
self.WidgetSwitcher_GameEnd:SetActiveWidgetIndex(1);
|
||
|
return ;
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WB_GameEnd:OnReturnToLobby()
|
||
|
-- 发送关闭协议到服务器
|
||
|
UE.ReturnToLobby();
|
||
|
end
|
||
|
|
||
|
-- function WB_GameEnd:Tick(MyGeometry, InDeltaTime)
|
||
|
|
||
|
-- end
|
||
|
|
||
|
-- function WB_GameEnd:Destruct()
|
||
|
|
||
|
-- end
|
||
|
|
||
|
return WB_GameEnd;
|