63 lines
1.7 KiB
Lua
63 lines
1.7 KiB
Lua
---@class WB_ShowEnemyPos_C:UUserWidget
|
|
---@field Image_1 UImage
|
|
---@field Overlay_Main UOverlay
|
|
---@field TextBlock_Dis UTextBlock
|
|
--Edit Below--
|
|
---@type WB_ShowEnemyPos_C
|
|
local WB_ShowEnemyPos = { bInitDoOnce = false; };
|
|
|
|
--[==[ Construct
|
|
function WB_ShowEnemyPos:Construct()
|
|
|
|
end
|
|
-- Construct ]==]
|
|
|
|
-- function WB_ShowEnemyPos:Tick(MyGeometry, InDeltaTime)
|
|
|
|
-- end
|
|
|
|
-- function WB_ShowEnemyPos:Destruct()
|
|
|
|
-- end
|
|
|
|
---@param InPlayerKey PlayerKey
|
|
function WB_ShowEnemyPos:ShowDistanceByPlayerKey(InPlayerKey)
|
|
UGCLogSystem.Log("[WB_ShowEnemyPos:ShowDistanceByPlayerKey] InPlayerKey = %s", tostring(InPlayerKey));
|
|
if InPlayerKey == nil or InPlayerKey == 0 then
|
|
self:SetVis(false);
|
|
return;
|
|
end
|
|
|
|
local Pawn = UGCGameSystem.GetPlayerPawnByPlayerKey(InPlayerKey);
|
|
if UE.IsValid(Pawn) then
|
|
self:ShowDistance(Pawn);
|
|
self:SetVis(true);
|
|
else
|
|
self:SetVis(false);
|
|
end
|
|
end
|
|
|
|
---@param InActor AActor
|
|
function WB_ShowEnemyPos:ShowDistance(InActor)
|
|
UGCLogSystem.Log("[WB_ShowEnemyPos:ShowDistance] 设置距离")
|
|
if UE.IsValid(InActor) then
|
|
UGCLogSystem.Log("[WB_ShowEnemyPos:ShowDistance] 当前有值")
|
|
local Loc = InActor:K2_GetActorLocation()
|
|
|
|
local SelfDis = UGCSystemLibrary.GetLocalPlayerPawn():K2_GetActorLocation()
|
|
local Dis = VectorHelper.GetDistance(Loc, SelfDis);
|
|
self.TextBlock_Dis:SetText(string.format("%.1fm", Dis / 100.));
|
|
end
|
|
end
|
|
|
|
function WB_ShowEnemyPos:SetVis(InVis)
|
|
if InVis then
|
|
UGCLogSystem.Log("[WB_ShowEnemyPos:SetVis] 设置显示")
|
|
self.Overlay_Main:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
|
|
else
|
|
UGCLogSystem.Log("[WB_ShowEnemyPos:SetVis] 设置隐藏")
|
|
self.Overlay_Main:SetVisibility(ESlateVisibility.Collapsed);
|
|
end
|
|
end
|
|
|
|
return WB_ShowEnemyPos; |