39 lines
1.3 KiB
Lua
39 lines
1.3 KiB
Lua
|
---@class WB_ResetPlayer_C:UUserWidget
|
||
|
---@field Button_ResetPlayer UButton
|
||
|
---@field Image_CD UImage
|
||
|
--Edit Below--
|
||
|
local WB_ResetPlayer = {
|
||
|
bInitDoOnce = false;
|
||
|
StartCoolingTime = -10;
|
||
|
ShowTime = 2;
|
||
|
bIsCooling = false;
|
||
|
};
|
||
|
|
||
|
|
||
|
function WB_ResetPlayer:Construct()
|
||
|
WidgetLibrary.BindButtonClicked(self.Button_ResetPlayer, self.ClickBtn, self)
|
||
|
self.bIsCooling = true
|
||
|
self.UpdateCoolingHandle = UGCEventSystem.SetTimerLoop(self, self.UpdateCooling, 0.1)
|
||
|
end
|
||
|
|
||
|
function WB_ResetPlayer:UpdateCooling()
|
||
|
local NowTime = UGCSystemLibrary.GetGameTime()
|
||
|
local Material = self.Image_CD:GetDynamicMaterial();
|
||
|
local Percent = (NowTime - self.StartCoolingTime) / self.ShowTime
|
||
|
Material:SetScalarParameterValue("Mask_Percent", Percent);
|
||
|
if Percent >= 1 then
|
||
|
self.bIsCooling = false
|
||
|
UGCEventSystem.StopTimer(self.UpdateCoolingHandle)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WB_ResetPlayer:ClickBtn()
|
||
|
if self.bIsCooling == false then
|
||
|
self.bIsCooling = true
|
||
|
self.StartCoolingTime = UGCSystemLibrary.GetGameTime()
|
||
|
UGCSendRPCSystem.ActorRPCNotify(nil, UGCGameSystem.GameState, "ResetPlayer", UGCSystemLibrary.GetLocalPlayerKey())
|
||
|
self.UpdateCoolingHandle = UGCEventSystem.SetTimerLoop(self, self.UpdateCooling, 0.1)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return WB_ResetPlayer;
|