68 lines
2.5 KiB
Lua
68 lines
2.5 KiB
Lua
|
---@class WB_TeamRankItem_C:UUserWidget
|
||
|
---@field Image_PlayerIcon UImage
|
||
|
---@field TextBlock_A UTextBlock
|
||
|
---@field TextBlock_D UTextBlock
|
||
|
---@field TextBlock_K UTextBlock
|
||
|
---@field TextBlock_PlayerName UTextBlock
|
||
|
---@field TextBlock_RankNum UTextBlock
|
||
|
---@field TextBlock_T UTextBlock
|
||
|
---@field WidgetSwitcher_IsLocalPlayer UWidgetSwitcher
|
||
|
--Edit Below--
|
||
|
---@type WB_TeamRankItem_C
|
||
|
local WB_TeamRankItem = {
|
||
|
bInitDoOnce = false;
|
||
|
TargetPlayerKey = -1;
|
||
|
};
|
||
|
|
||
|
function WB_TeamRankItem:SetTeam(TeamType)
|
||
|
-- UGCLogSystem.Log("[WB_TeamRankItem_SetTeam]")
|
||
|
local TeamColor = TeamConfig.TeamColor[TeamType]
|
||
|
-- 设置队伍颜色
|
||
|
if TeamColor then
|
||
|
self.TextBlock_RankNum:SetColorAndOpacity({SpecifiedColor = TeamColor, ColorUseRule = 0})
|
||
|
self.TextBlock_PlayerName:SetColorAndOpacity({SpecifiedColor = TeamColor, ColorUseRule = 0})
|
||
|
-- self.TextBlock_Score:SetColorAndOpacity({SpecifiedColor = TeamColor, ColorUseRule = 0})
|
||
|
else
|
||
|
UGCLogSystem.LogError("[WB_TeamRankItem_SetTeam] TeamType:%s, TeamColorType: %s", tostring(TeamType), type(TeamColor))
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WB_TeamRankItem:InitRankInfo(PlayerKey)
|
||
|
self.TargetPlayerKey = PlayerKey
|
||
|
self:InitWidget()
|
||
|
if PlayerKey == UGCSystemLibrary.GetLocalPlayerKey() then
|
||
|
self.WidgetSwitcher_IsLocalPlayer:SetActiveWidgetIndex(1)
|
||
|
else
|
||
|
self.WidgetSwitcher_IsLocalPlayer:SetActiveWidgetIndex(0)
|
||
|
end
|
||
|
|
||
|
local PlayerName = UGCGameSystem.GameState:GetPlayerNameByPlayerKey(PlayerKey);
|
||
|
local RankNum = UGCGameSystem.GameState:GetPlayerRankByPlayerKey(PlayerKey)
|
||
|
local ScoreData = UGCGameSystem.GameState:GetScoreDataByPlayerKey(PlayerKey)
|
||
|
|
||
|
self.TextBlock_PlayerName:SetText(PlayerName);
|
||
|
self.TextBlock_RankNum:SetText(tostring(RankNum));
|
||
|
|
||
|
if ScoreData then
|
||
|
self.TextBlock_K:SetText(tostring(ScoreData.Kill))
|
||
|
self.TextBlock_D:SetText(tostring(ScoreData.Dead))
|
||
|
self.TextBlock_A:SetText(tostring(ScoreData.Assist))
|
||
|
end
|
||
|
self:PlayerHoldsTheKeyTimeUpdate()
|
||
|
UGCSystemLibrary.DownloadImageToUImage(self.Image_PlayerIcon, UGCGameSystem.GameState:GetHeadIconByPlayerKey(PlayerKey));
|
||
|
end
|
||
|
|
||
|
function WB_TeamRankItem:InitWidget()
|
||
|
if self.InitOnce then return end
|
||
|
self.InitOnce = true
|
||
|
UGCEventSystem.AddListener(EventEnum.PlayerHoldsTheKeyTimeUpdate, self.PlayerHoldsTheKeyTimeUpdate, self)
|
||
|
end
|
||
|
|
||
|
function WB_TeamRankItem:PlayerHoldsTheKeyTimeUpdate()
|
||
|
if self.TargetPlayerKey > 0 then
|
||
|
local HoldsTheKeyTime = UGCGameSystem.GameState:GetPlayerHoldsTheKeyTime(self.TargetPlayerKey)
|
||
|
self.TextBlock_T:SetText(string.format("%0.1f", HoldsTheKeyTime * GlobalConfigs.GameSetting.HoldsTheKeyTimeToScore))
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return WB_TeamRankItem;
|