70 lines
2.7 KiB
Lua
Raw Permalink Normal View History

2025-01-04 23:00:19 +08:00
---@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;
};
function WB_ToGod:Construct()
UGCEventSystem.AddListener(EventEnum.UpdateToGodSchedule, self.UpdateToGod, self)
self:ResetInfo()
UGCEventSystem.SetTimerLoop(self,
function()
local LocalPawn = UGCGameSystem.GameState:GetAlivePawn(UGCSystemLibrary.GetLocalPlayerKey())
if LocalPawn then
self:UpdateToGod(LocalPawn, LocalPawn:GetToGodSchedule())
end
end
, 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(InPawn, ToGodSchedule)
-- UGCLogSystem.Log("[WB_ToGod_UpdateToGod] ToGodSchedule:%s", tostring(ToGodSchedule))
local LocalPawn = UGCGameSystem.GameState:GetAlivePawn(UGCSystemLibrary.GetLocalPlayerKey())
if LocalPawn and LocalPawn == InPawn then
if ToGodSchedule ~= self.LastCount then
--UGCLogSystem.Log("[WB_ToGod_UpdateToGod]LocalPawn:%s, InPawn:%s ", tostring(LocalPawn), tostring(InPawn))
--UGCLogSystem.Log("[WB_ToGod_UpdateToGod] ToGodSchedule:%s, self.LastCount:%s", tostring(ToGodSchedule), tostring(self.LastCount))
if ToGodSchedule >= GodOfWarConfig.ToGodCondition 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
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
end
end
end
-- function WB_ToGod:Tick(MyGeometry, InDeltaTime)
-- end
-- function WB_ToGod:Destruct()
-- end
return WB_ToGod;