50 lines
1.7 KiB
Lua
50 lines
1.7 KiB
Lua
---@class WB_HeadingInfo_C:UUserWidget
|
|
---@field TextBlock_Coin UTextBlock
|
|
---@field TextBlock_RankNum UTextBlock
|
|
---@field TextBlock_Score UTextBlock
|
|
---@field TextBlock_Team UTextBlock
|
|
--Edit Below--
|
|
---@type WB_HeadingInfo_C
|
|
local WB_HeadingInfo = { bInitDoOnce = false; };
|
|
|
|
function WB_HeadingInfo:Construct()
|
|
UGCEventSystem.AddListener(EventEnum.UpdatePlayerScoreData, self.UpdatePlayerScoreData, self)
|
|
UGCEventSystem.AddListener(EventEnum.PlayerGoldCoinChange, self.UpdatePlayerCoin, self)
|
|
--UGCEventSystem.AddListener(EventEnum.UpdatePlayerRank, self.UpdateRank, self)
|
|
|
|
--self:UpdateRank()
|
|
self:UpdatePlayerCoin()
|
|
|
|
local TeamID = UGCPlayerControllerSystem.GetTeamID(UGCSystemLibrary.GetLocalPlayerController())
|
|
if TeamID then
|
|
self.TextBlock_Team:SetText(tostring(TeamConfig.TeamName[TeamID]) .. " 方")
|
|
local TeamColor = TeamConfig.TeamColor[TeamID]
|
|
if TeamColor then
|
|
self.TextBlock_Team:SetColorAndOpacity({SpecifiedColor = TeamColor, ColorUseRule=0})
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
function WB_HeadingInfo:UpdateRank()
|
|
local Rank = UGCGameSystem.GameState:GetPlayerRankByPlayerKey(UGCSystemLibrary.GetLocalPlayerKey())
|
|
if Rank then
|
|
self.TextBlock_RankNum:SetText(tostring(Rank))
|
|
end
|
|
self.TextBlock_RankNum:SetText(tostring(Rank))
|
|
end
|
|
|
|
|
|
function WB_HeadingInfo:UpdatePlayerScoreData()
|
|
local ScoreDatas = UGCGameSystem.GameState:GetScoreDataByPlayerKey(UGCSystemLibrary.GetLocalPlayerKey())
|
|
if ScoreDatas then
|
|
self.TextBlock_Score:SetText(tostring(ScoreDatas.Kill))
|
|
end
|
|
end
|
|
|
|
function WB_HeadingInfo:UpdatePlayerCoin()
|
|
self.TextBlock_Coin:SetText(tostring(UGCGameSystem.GameState:GetPlayerCoin(UGCSystemLibrary.GetLocalPlayerKey())))
|
|
end
|
|
|
|
|
|
return WB_HeadingInfo; |