166 lines
5.9 KiB
Lua
166 lines
5.9 KiB
Lua
---@class WB_GameEnd_PlayerInfo_C:UUserWidget
|
|
---@field ShowAddScore UWidgetAnimation
|
|
---@field Common_Avatar UCommon_Avatar_BP_C
|
|
---@field Image_Arrow UImage
|
|
---@field Image_Icon UImage
|
|
---@field NewButton_AddFirend UNewButton
|
|
---@field TextBlock_0 UTextBlock
|
|
---@field TextBlock_ChangeHideScore UTextBlock
|
|
---@field TextBlock_Diff UTextBlock
|
|
---@field TextBlock_Dir UTextBlock
|
|
---@field TextBlock_HideScore UTextBlock
|
|
---@field TextBlock_PlayerName UTextBlock
|
|
---@field TextBlock_Rank UTextBlock
|
|
---@field TextBlock_Score UTextBlock
|
|
---@field TextBlock_SubScore UTextBlock
|
|
---@field TextBlock_TipScore UTextBlock
|
|
---@field TextBlock_WinRate UTextBlock
|
|
---@field TextBlock_WinTimes UTextBlock
|
|
---@field WidgetSwitcher_AddScore UWidgetSwitcher
|
|
---@field WidgetSwitcher_Icon UWidgetSwitcher
|
|
---@field WidgetSwitcher_IsSelf UWidgetSwitcher
|
|
--Edit Below--
|
|
---@type WB_GameEnd_PlayerInfo_C
|
|
local WB_GameEnd_PlayerInfo = { bInitDoOnce = false; };
|
|
|
|
WB_GameEnd_PlayerInfo.PlayerKey = nil;
|
|
WB_GameEnd_PlayerInfo.ChangeRankTimer = nil;
|
|
WB_GameEnd_PlayerInfo.AddScoreInterval = 0.02;
|
|
WB_GameEnd_PlayerInfo.UpdateTotalTime = 3.;
|
|
WB_GameEnd_PlayerInfo.EachAddScore = 0;
|
|
WB_GameEnd_PlayerInfo.CurrRank = 0;
|
|
WB_GameEnd_PlayerInfo.CurrHide = 0;
|
|
|
|
--[==[ Construct
|
|
function WB_GameEnd_PlayerInfo:Construct()
|
|
|
|
end
|
|
-- Construct ]==]
|
|
|
|
function WB_GameEnd_PlayerInfo:LuaInit(IsSelf)
|
|
if IsSelf ~= nil then
|
|
self.TextBlock_Dir:SetText(IsSelf and "己方" or "敌方");
|
|
else
|
|
|
|
end
|
|
self.TextBlock_Score:SetText("0");
|
|
self.TextBlock_Rank:SetText(string.format("%d", DefaultSettings.RankScore));
|
|
|
|
UGCLogSystem.Log("[WB_GameEnd_PlayerInfo:LuaInit] 执行")
|
|
|
|
UITool.BindButtonPressed(self.NewButton_AddFirend, function()
|
|
UITool.AddFriend(self.PlayerKey);
|
|
end, self);
|
|
self.WidgetSwitcher_Icon:SetActiveWidgetIndex(1);
|
|
end
|
|
|
|
function WB_GameEnd_PlayerInfo:SetPlayerInfo(PlayerKey, Info, IsSelf)
|
|
self.TextBlock_Score:SetText(tostring(Info == nil and 0 or Info));
|
|
end
|
|
|
|
function WB_GameEnd_PlayerInfo:SetPlayerKey(PlayerKey, Info)
|
|
self.TextBlock_PlayerName:SetText(Info.PlayerName);
|
|
UGCLogSystem.LogTree(string.format("[WB_GameEnd_PlayerInfo:SetPlayerKey] Info"), Info)
|
|
UITool.DownloadImage(Info.IconURL, function(Texture)
|
|
self.Image_Icon:SetBrushFromTextureDynamic(Texture);
|
|
end);
|
|
|
|
self.PlayerKey = PlayerKey;
|
|
|
|
if FriendSystem.IsMyFriend(UE.GetPlayerUID(PlayerKey)) then
|
|
self.NewButton_AddFirend:SetVisibility(ESlateVisibility.Hidden);
|
|
else
|
|
self.NewButton_AddFirend:SetVisibility(ESlateVisibility.Visible);
|
|
end
|
|
|
|
if LocalIsGlobalSpectator then
|
|
-- 显示一下
|
|
self.NewButton_AddFirend:SetVisibility(ESlateVisibility.Hidden);
|
|
else
|
|
self:LuaInit(PlayerKey == LocalPlayerKey);
|
|
if LocalPlayerKey == PlayerKey then
|
|
self.NewButton_AddFirend:SetVisibility(ESlateVisibility.Hidden);
|
|
end
|
|
end
|
|
self.Common_Avatar:InitView(2, tostring(UE.GetPlayerUID(PlayerKey)), UE.GetPlayerIconURL(PlayerKey), UE.GetPlayerGender(PlayerKey), UE.GetPlayerAvatarBoxId(PlayerKey), UE.GetPlayerLevel(PlayerKey), false, false);
|
|
end
|
|
|
|
function WB_GameEnd_PlayerInfo:SetWin(IsWin)
|
|
if LocalIsGlobalSpectator then
|
|
UGCLogSystem.Log("[WB_GameEnd_PlayerInfo:SetWin] 执行: %s", tostring(IsWin));
|
|
self.TextBlock_Dir:SetText(IsWin and "胜利" or "失败");
|
|
else
|
|
local Archive = ArchiveTable[self.PlayerKey];
|
|
if Archive then
|
|
-- 当前胜利数 + 1
|
|
local GameTimes = Archive.TotalGameTimes or 1;
|
|
local WinTimes = Archive.GameWinTimes or 0;
|
|
self.TextBlock_WinTimes:SetText(string.format("%d/%d", WinTimes, GameTimes));
|
|
self.TextBlock_WinRate:SetText(string.format('%0.1f%%', WinTimes / GameTimes * 100));
|
|
end
|
|
end
|
|
end
|
|
|
|
---@param RankScore MiniSolo_RankScore
|
|
function WB_GameEnd_PlayerInfo:SetTargetRank(RankScore)
|
|
UGCLogSystem.LogTree(string.format("[WB_GameEnd_PlayerInfo:SetTargetRank] RankScore ="), RankScore)
|
|
UGCLogSystem.Log("[WB_GameEnd_PlayerInfo:SetTargetRank] Rank = %d", RankScore.Current);
|
|
|
|
self.TextBlock_Rank:SetText(RankScore.Current); -- 这个值一直都不变
|
|
self.TextBlock_HideScore:SetText('(' .. tostring(RankScore.HideScore) .. ')');
|
|
RankScore.AddHide = math.abs(RankScore.AddHide)
|
|
self.CurrRank = RankScore.Add - RankScore.AddHide;
|
|
if self.CurrRank >= 0 then
|
|
self.TextBlock_Diff:SetText('+' .. tostring(self.CurrRank));
|
|
else
|
|
self.TextBlock_Diff:SetText(self.CurrRank);
|
|
end
|
|
|
|
if RankScore.AddHide > 0 then
|
|
self.TextBlock_ChangeHideScore:SetText(RankScore.AddHide);
|
|
else
|
|
self.TextBlock_ChangeHideScore:SetVisibility(ESlateVisibility.Collapsed);
|
|
self.Image_Arrow:SetVisibility(ESlateVisibility.Collapsed);
|
|
return ;
|
|
end
|
|
|
|
self.TargetRank = RankScore.Add; -- 目标加的分
|
|
self.CurrHide = RankScore.AddHide; -- 当前的隐藏分,最终的一定是 0
|
|
|
|
UGCEventSystem.SetTimer(self, function()
|
|
self:ChangeRankAnime();
|
|
end, 2);
|
|
end
|
|
|
|
function WB_GameEnd_PlayerInfo:ChangeRankAnime()
|
|
-- 每次加分情况
|
|
-- 每次加多少分
|
|
self.EachAddScore = (self.CurrHide) / (self.UpdateTotalTime / self.AddScoreInterval);
|
|
self.ChangeRankTimer = UGCEventSystem.SetTimerLoop(self, function()
|
|
self.CurrHide = self.CurrHide - self.EachAddScore;
|
|
self.CurrRank = self.CurrRank + self.EachAddScore;
|
|
|
|
self.TextBlock_ChangeHideScore:SetText(math.ceil(self.CurrHide));
|
|
|
|
if self.CurrRank >= 0 then
|
|
self.TextBlock_Diff:SetText('+' .. tostring(math.floor(self.CurrRank)));
|
|
else
|
|
self.TextBlock_Diff:SetText(math.ceil(self.CurrRank));
|
|
end
|
|
end, self.AddScoreInterval);
|
|
UGCEventSystem.SetTimer(self, function()
|
|
if self.ChangeRankTimer then
|
|
UGCEventSystem.StopTimer(self.ChangeRankTimer);
|
|
self.ChangeRankTimer = nil;
|
|
end
|
|
if self.TargetRank >= 0 then
|
|
self.TextBlock_Diff:SetText('+' .. tostring(self.TargetRank));
|
|
else
|
|
self.TextBlock_Diff:SetText(self.TargetRank);
|
|
end
|
|
self.TextBlock_ChangeHideScore:SetVisibility(ESlateVisibility.Collapsed);
|
|
self.Image_Arrow:SetVisibility(ESlateVisibility.Collapsed);
|
|
end, self.UpdateTotalTime);
|
|
end
|
|
|
|
return WB_GameEnd_PlayerInfo; |