2025-01-04 23:00:19 +08:00

62 lines
1.9 KiB
Lua

---@class WB_HeightItem_C:UUserWidget
---@field Image_Head UImage
---@field Image_IsLocalPlayer UImage
---@field TextBlock_PlayerNum_Debug UTextBlock
---@field TextBlock_Score UTextBlock
--Edit Below--
local WB_HeightItem = {
bInitDoOnce = false;
TargetPos = 0;
NowPos = 0.;
InterpSpeed = 20;
};
--[==[ Construct
function WB_HeightItem:Construct()
end
-- Construct ]==]
function WB_HeightItem:Tick(MyGeometry, InDeltaTime)
self.NowPos = KismetMathLibrary.FInterpTo_Constant(self.NowPos, self.TargetPos, InDeltaTime, self.InterpSpeed)
self:SetRenderTranslation({X = 0, Y = self.NowPos})
UGCLogSystem.Log("[WB_HeightItem_Tick]")
end
-- function WB_HeightItem:Destruct()
-- end
function WB_HeightItem:SetPlayerKey(InPlayerKey)
self.PlayerKey = InPlayerKey
if self.PlayerKey == nil or self.PlayerKey < 0 then
self:SetVisibility(ESlateVisibility.Collapsed)
else
if GlobalConfigs.IsDebug then
self.TextBlock_PlayerNum_Debug:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
self.TextBlock_PlayerNum_Debug:SetText(tostring(InPlayerKey % 10))
end
self:SetVisibility(ESlateVisibility.HitTestInvisible)
if self.PlayerKey == UGCSystemLibrary.GetLocalPlayerKey() then
self.Image_IsLocalPlayer:SetVisibility(ESlateVisibility.HitTestInvisible)
else
self.Image_IsLocalPlayer:SetVisibility(ESlateVisibility.Collapsed)
end
UGCSystemLibrary.DownloadImageToUImage(self.Image_Head, UGCGameSystem.GameState:GetHeadIconByPlayerKey(self.PlayerKey));
end
end
function WB_HeightItem:UpdatePlayerScore(NewScore)
if NewScore == nil then
NewScore = 0
end
self.TextBlock_Score:SetText(string.format("%sm", tostring(NewScore)))
end
function WB_HeightItem:GetPlayerKey()
return self.PlayerKey
end
function WB_HeightItem:SetTargetPos(InPos)
self.TargetPos = InPos
end
return WB_HeightItem;