32 lines
1.2 KiB
Lua
Raw Normal View History

2025-01-04 23:00:19 +08:00
---@class W_InvincibleTime_C:UUserWidget
---@field TextBlock_Time UTextBlock
--Edit Below--
---@type W_InvincibleTime_C
local W_InvincibleTime = {
bInitDoOnce = false;
SpawnTime = 0.;
};
function W_InvincibleTime:Construct()
WidgetLibrary.TextBlockBindingPropertyText(self.TextBlock_Time, self.TextBlock_Time_Txt, self)
self.SpawnTime = UGCSystemLibrary.GetGameTime()
end
function W_InvincibleTime:OnShowPanel()
self.SpawnTime = UGCSystemLibrary.GetGameTime()
UGCLogSystem.Log("[W_InvincibleTime_OnShowPanel] PlayerKey:%d, SpawnTime: %f", UGCSystemLibrary.GetLocalPlayerKey(), self.SpawnTime)
self:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
UGCEventSystem.SetTimer(self, function () self:SetVisibility(ESlateVisibility.Collapsed) end, GlobalConfigs.GameSetting.InvincibleTime)
end
function W_InvincibleTime:TextBlock_Time_Txt(ReturnValue)
local NowTime = UGCSystemLibrary.GetGameTime()
if (NowTime - self.SpawnTime) < GlobalConfigs.GameSetting.InvincibleTime then
return string.format("%0.2f",
math.clamp((GlobalConfigs.GameSetting.InvincibleTime - (NowTime - self.SpawnTime)), 0., GlobalConfigs.GameSetting.InvincibleTime)
)
end
return ""
end
return W_InvincibleTime;