76 lines
2.8 KiB
Lua
76 lines
2.8 KiB
Lua
|
---@class WB_TeamSettlementItem_C:UUserWidget
|
||
|
---@field Button_Result_AddFriend UButton
|
||
|
---@field Image_0 UImage
|
||
|
---@field Image_PlayerIcon UImage
|
||
|
---@field TextBlock_Deaths UTextBlock
|
||
|
---@field TextBlock_Kills UTextBlock
|
||
|
---@field TextBlock_PlayerName UTextBlock
|
||
|
---@field TextBlock_RankNum UTextBlock
|
||
|
---@field WidgetSwitcher_IsLocalPlayer UWidgetSwitcher
|
||
|
--Edit Below--
|
||
|
---@type WB_TeamSettlementItem_C
|
||
|
local WB_TeamSettlementItem = {
|
||
|
bInitDoOnce = false;
|
||
|
PlayerKey = -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:SetIndex(Index)
|
||
|
self.TextBlock_RankNum:SetText(tostring(Index));
|
||
|
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})
|
||
|
else
|
||
|
UGCLogSystem.LogError("[WB_TeamRankItem_SetTeam] TeamType:%s, TeamColorType: %s", tostring(TeamType), type(TeamColor))
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WB_TeamSettlementItem:InitRankInfo(PlayerKey)
|
||
|
self:LuaInit()
|
||
|
self.PlayerKey = PlayerKey
|
||
|
if self.PlayerKey == UGCSystemLibrary.GetLocalPlayerKey() then
|
||
|
self.WidgetSwitcher_IsLocalPlayer:SetActiveWidgetIndex(1)
|
||
|
self.Button_Result_AddFriend:SetVisibility(ESlateVisibility.Collapsed)
|
||
|
else
|
||
|
self.WidgetSwitcher_IsLocalPlayer:SetActiveWidgetIndex(0)
|
||
|
end
|
||
|
|
||
|
local PlayerName = UGCGameSystem.GameState:GetPlayerNameByPlayerKey(self.PlayerKey);
|
||
|
--local RankNum = UGCGameSystem.GameState:GetPlayerRankByPlayerKey(self.PlayerKey)
|
||
|
local Kills = PlayerScoreSystem.GetPlayerScoreDataFromType(PlayerKey, PlayerScoreSystem.Config.EScoreType.Kills)
|
||
|
local Damage = PlayerScoreSystem.GetPlayerScoreDataFromType(PlayerKey, PlayerScoreSystem.Config.EScoreType.Damage)
|
||
|
|
||
|
local Deaths = PlayerScoreSystem.GetPlayerScoreDataFromType(PlayerKey, PlayerScoreSystem.Config.EScoreType.Deaths)
|
||
|
|
||
|
self.TextBlock_PlayerName:SetText(PlayerName);
|
||
|
--self.TextBlock_RankNum:SetText(tostring(RankNum));
|
||
|
|
||
|
|
||
|
--self.TextBlock_Kills:SetText(tostring(Kills));
|
||
|
self.TextBlock_Kills:SetText(math.floor(Damage));
|
||
|
self.TextBlock_Deaths:SetText(tostring(Deaths));
|
||
|
|
||
|
UGCSystemLibrary.DownloadImageToUImage(self.Image_PlayerIcon, UGCGameSystem.GameState:GetHeadIconByPlayerKey(PlayerKey), true);
|
||
|
end
|
||
|
|
||
|
function WB_TeamSettlementItem:AddFriend()
|
||
|
local TargetPlayerData = UGCGameSystem.GameState.PlayerPersonalInfos[self.PlayerKey]
|
||
|
if TargetPlayerData then
|
||
|
UGCGameSystem.AddFriend(TargetPlayerData.UID)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return WB_TeamSettlementItem;
|