64 lines
1.5 KiB
Lua
64 lines
1.5 KiB
Lua
---@class WB_PlayerKills_C:UUserWidget
|
|
---@field TextBlock_CurrKill UTextBlock
|
|
---@field TextBlock_TotalKill UTextBlock
|
|
---@field WidgetSwitcher_God UWidgetSwitcher
|
|
--Edit Below--
|
|
---@type WB_PlayerKills_C
|
|
local WB_PlayerKills = { bInitDoOnce = false; };
|
|
|
|
function WB_PlayerKills:Construct()
|
|
self:LuaInit();
|
|
end
|
|
|
|
function WB_PlayerKills:LuaInit()
|
|
if self.bInitDoOnce then return; end
|
|
|
|
self.WidgetSwitcher_God:SetActiveWidgetIndex(0);
|
|
|
|
self.bInitDoOnce = true;
|
|
end
|
|
|
|
-- function WB_PlayerKills:Tick(MyGeometry, InDeltaTime)
|
|
|
|
-- end
|
|
|
|
-- function WB_PlayerKills:Destruct()
|
|
|
|
-- end
|
|
|
|
WB_PlayerKills.KillColor = {
|
|
{ 0, 0, 1, },
|
|
{ 0, 1, 1, };
|
|
}
|
|
|
|
function WB_PlayerKills:SetPlayerKills(InKill, InTotal)
|
|
if InKill == nil then InKill = 0; end
|
|
local Percent = InKill / InTotal;
|
|
local Color = {};
|
|
for i = 1, 3 do
|
|
table.insert(Color, (self.KillColor[2][i] - self.KillColor[1][i]) * Percent);
|
|
end
|
|
-- 设置进去
|
|
self.TextBlock_CurrKill:SetColorAndOpacity(UITool.MakeSlateColor(Color));
|
|
self.TextBlock_CurrKill:SetText(InKill);
|
|
|
|
if InKill >= InTotal then
|
|
if self.WidgetSwitcher_God:GetActiveWidgetIndex() ~= 1 then
|
|
UGCEventSystem.SetTimer(self, function()
|
|
self.WidgetSwitcher_God:SetActiveWidgetIndex(1);
|
|
end, 1);
|
|
end
|
|
else
|
|
self.WidgetSwitcher_God:SetActiveWidgetIndex(0);
|
|
end
|
|
end
|
|
|
|
WB_PlayerKills.TotalKillCount = 0;
|
|
|
|
function WB_PlayerKills:SetTotalKillCount(InCount)
|
|
UGCLogSystem.Log("[WB_PlayerKills:SetTotalKillCount] 执行")
|
|
self.TotalKillCount = InCount;
|
|
self.TextBlock_TotalKill:SetText(self.TotalKillCount);
|
|
end
|
|
|
|
return WB_PlayerKills; |