78 lines
2.8 KiB
Lua
78 lines
2.8 KiB
Lua
---@class WB_TeamSettlementItem_C:UUserWidget
|
|
---@field Button_Result_AddFriend UButton
|
|
---@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_TeamSettlementItem_C
|
|
local WB_TeamSettlementItem = {
|
|
bInitDoOnce = false;
|
|
TargetPlayerKey = -1;
|
|
};
|
|
|
|
function WB_TeamSettlementItem:LuaInit()
|
|
if self.bInitDoOnce then
|
|
return;
|
|
end
|
|
self.bInitDoOnce = true;
|
|
WidgetLibrary.BindButtonClicked(self.Button_Result_AddFriend, self.AddFriend, self)
|
|
end
|
|
|
|
function WB_TeamSettlementItem: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_TeamSettlementItem:InitRankInfo(PlayerKey)
|
|
self:LuaInit()
|
|
self.TargetPlayerKey = PlayerKey
|
|
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_TeamSettlementItem:AddFriend()
|
|
local TargetPlayerData = UGCGameSystem.GameState.PlayerPersonalInfos[self.TargetPlayerKey]
|
|
if TargetPlayerData then
|
|
UGCGameSystem.AddFriend(TargetPlayerData.UID)
|
|
end
|
|
end
|
|
|
|
function WB_TeamSettlementItem: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_TeamSettlementItem; |