69 lines
2.3 KiB
Lua
Raw Normal View History

2025-01-04 23:00:19 +08:00
---@class WB_AttackPoint_C:UUserWidget
---@field CanvasPanel_AttackPointPanel UCanvasPanel
---@field ProgressBar_AttackPoint UProgressBar
---@field WidgetSwitcher_IsEnemy UWidgetSwitcher
--Edit Below--
local WB_AttackPoint = {
bInitDoOnce = false;
FPS = 20;
}
--[==[ Construct
function WB_AttackPoint:Construct()
end
-- Construct ]==]
-- function WB_AttackPoint:Tick(MyGeometry, InDeltaTime)
-- end
function WB_AttackPoint:Destruct()
if self.LoopHandle then
UGCEventSystem.StopTimer(self.LoopHandle)
end
end
function WB_AttackPoint:Active()
if self.LoopHandle == nil then
self.LoopHandle = UGCEventSystem.SetTimerLoop(self, self.UpdateProgressBar, 1./self.FPS)
end
end
function WB_AttackPoint:GetAttackPointActor()
if not UE.IsValid(self.AttackPointClass) then self.AttackPointClass = UE.LoadClass(UGCGameSystem.GetUGCResourcesFullPath('Asset/Blueprint/SceneActor/AttackPoint/BP_AttackPoint.BP_AttackPoint_C')) end
if not UE.IsValid(self.AttackPointActor) and UE.IsValid(self.AttackPointClass) then
self.AttackPointActor = UGCSystemLibrary.GetUniqueInstanceFromClass(self.AttackPointClass)
end
return self.AttackPointActor
end
function WB_AttackPoint:UpdateProgressBar()
local AttackPointActor = self:GetAttackPointActor()
if UE.IsValid(AttackPointActor) then
local ProgressTime = AttackPointActor:GetProgress()
local IsActive = AttackPointActor:GetActive()
if IsActive and ProgressTime >= 1e-2 then
self:SetProgressBarVis(true)
self.ProgressBar_AttackPoint:SetPercent(ProgressTime / ProjectConfig.AttackPointTime)
self.WidgetSwitcher_IsEnemy:SetActiveWidgetIndex(UGCGameSystem.GameState:PlayerIsAttacker(UGCSystemLibrary.GetLocalPlayerKey()) and 0 or 1)
else
self:SetProgressBarVis(false)
end
else
self:SetProgressBarVis(false)
end
end
function WB_AttackPoint:SetProgressBarVis(InVis)
if self.ProgressBarIsVis ~= InVis then
self.ProgressBarIsVis = InVis
if self.ProgressBarIsVis then
self.CanvasPanel_AttackPointPanel:SetVisibility(ESlateVisibility.HitTestInvisible)
else
self.CanvasPanel_AttackPointPanel:SetVisibility(ESlateVisibility.Collapsed)
end
end
end
return WB_AttackPoint