67 lines
2.2 KiB
Lua
67 lines
2.2 KiB
Lua
|
---@class WB_ToGod_C:UUserWidget
|
||
|
---@field ToGod UWidgetAnimation
|
||
|
---@field AddToGod UWidgetAnimation
|
||
|
---@field ProgressBar_ToGod UProgressBar
|
||
|
---@field TextBlock_Count UTextBlock
|
||
|
---@field WidgetSwitcher_IsGod UWidgetSwitcher
|
||
|
--Edit Below--
|
||
|
local WB_ToGod = {
|
||
|
bInitDoOnce = false;
|
||
|
LastCount = 0;
|
||
|
LastIsGod = false;
|
||
|
};
|
||
|
|
||
|
|
||
|
function WB_ToGod:Construct()
|
||
|
UGCEventSystem.AddListener(EventEnum.UpdateToGodSchedule, self.UpdateToGod, self)
|
||
|
self:ResetInfo()
|
||
|
UGCEventSystem.SetTimerLoop(self, self.UpdateToGod, 2)
|
||
|
end
|
||
|
|
||
|
function WB_ToGod:ResetInfo()
|
||
|
self.WidgetSwitcher_IsGod:SetActiveWidgetIndex(0)
|
||
|
self.TextBlock_Count:SetText(string.format("击倒 0/%s", tostring(GodOfWarConfig.ToGodCondition)))
|
||
|
self.ProgressBar_ToGod:SetPercent(0)
|
||
|
self.LastCount = 0
|
||
|
end
|
||
|
|
||
|
function WB_ToGod:UpdateToGod()
|
||
|
-- UGCLogSystem.Log("[WB_ToGod_UpdateToGod] ToGodSchedule:%s", tostring(ToGodSchedule))
|
||
|
local LocalPC = UGCSystemLibrary.GetLocalPlayerController()
|
||
|
local ToGodSchedule = LocalPC:GetToGodSchedule()
|
||
|
local IsGod = LocalPC:PlayerIsGod()
|
||
|
if ToGodSchedule ~= self.LastCount or IsGod ~= self.LastIsGod then
|
||
|
|
||
|
if IsGod then
|
||
|
if IsGod ~= self.LastIsGod then
|
||
|
self.WidgetSwitcher_IsGod:SetActiveWidgetIndex(1)
|
||
|
if self.LastCount < GodOfWarConfig.ToGodCondition then
|
||
|
UGCLogSystem.Log("[WB_ToGod_UpdateToGod] Show Animation")
|
||
|
self:PlayAnimation(self.ToGod, 0, 1, EUMGSequencePlayMode.Forward, 1);
|
||
|
end
|
||
|
end
|
||
|
else
|
||
|
self.WidgetSwitcher_IsGod:SetActiveWidgetIndex(0)
|
||
|
if ToGodSchedule > 0 and ToGodSchedule ~= self.LastCount then
|
||
|
self:PlayAnimation(self.AddToGod, 0, 1, EUMGSequencePlayMode.Forward, 1);
|
||
|
end
|
||
|
self.TextBlock_Count:SetText(string.format("击倒 %s/%s", tostring(ToGodSchedule), tostring(GodOfWarConfig.ToGodCondition)))
|
||
|
self.ProgressBar_ToGod:SetPercent(ToGodSchedule / GodOfWarConfig.ToGodCondition)
|
||
|
end
|
||
|
self.LastCount = ToGodSchedule
|
||
|
self.LastIsGod = IsGod
|
||
|
end
|
||
|
|
||
|
end
|
||
|
|
||
|
|
||
|
|
||
|
-- function WB_ToGod:Tick(MyGeometry, InDeltaTime)
|
||
|
|
||
|
-- end
|
||
|
|
||
|
-- function WB_ToGod:Destruct()
|
||
|
|
||
|
-- end
|
||
|
|
||
|
return WB_ToGod;
|