43 lines
1.4 KiB
Lua
Raw Normal View History

2025-01-04 23:00:19 +08:00
---@class WB_PlayerCount_C:UUserWidget
---@field Image_Head UImage
---@field Image_IsLocalPlayer UImage
---@field TextBlock_PlayerNum_Debug UTextBlock
---@field TextBlock_Score UTextBlock
--Edit Below--
local WB_PlayerCount = {
bInitDoOnce = false;
};
function WB_PlayerCount: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_PlayerCount:UpdatePlayerScore(NewScore)
if NewScore == nil then
NewScore = 0
end
if NewScore ~= self.LastScore then
self.TextBlock_Score:SetText(tostring(NewScore))
end
end
function WB_PlayerCount:GetPlayerKey()
return self.PlayerKey
end
return WB_PlayerCount;