221 lines
7.5 KiB
Lua
221 lines
7.5 KiB
Lua
---@class WB_Main_C:UAEUserWidget
|
|
---@field ShowKDAInfo UWidgetAnimation
|
|
---@field Button_Score UButton
|
|
---@field Button_Test UButton
|
|
---@field Button_Test_Custom UButton
|
|
---@field Button_TestSide UButton
|
|
---@field CanvasPanel_Prepare UCanvasPanel
|
|
---@field CanvasPanel_Test UCanvasPanel
|
|
---@field TextBlock_CountDown UTextBlock
|
|
---@field TextBlock_EnemyScore UTextBlock
|
|
---@field TextBlock_Prepare UTextBlock
|
|
---@field TextBlock_SelfScore UTextBlock
|
|
---@field TextBlock_ServerTime UTextBlock
|
|
---@field TextBlock_State UTextBlock
|
|
---@field TextBlock_Time UTextBlock
|
|
---@field WB_BuyButton UWB_BuyButton_C
|
|
---@field WB_InTest_Side UWB_InTest_Side_C
|
|
---@field WB_KDALine UWB_KDALine_C
|
|
---@field WB_RoundEnd UWB_RoundEnd_C
|
|
---@field WB_SelectParts UWB_SelectParts_C
|
|
---@field WB_TestLog UWB_TestLog_C
|
|
--Edit Below--
|
|
---@type WB_Main_C
|
|
local WB_Main = { bInitDoOnce = false; };
|
|
|
|
WB_Main.IsTestShow = true;
|
|
WB_Main.ShowRoundTimes = false;
|
|
|
|
function WB_Main:Construct()
|
|
UGCEventSystem.AddListener(EventTypes.CountDownTimeChange, self.OnCountDownChange, self)
|
|
UGCEventSystem.AddListener(EventTypes.AllPlayerKDAChange, self.OnAllPlayerKDAChange, self)
|
|
UGCEventSystem.AddListener(EventTypes.MiniStateChange, self.OnMiniStateChange, self)
|
|
UGCEventSystem.AddListener(EventTypes.UpdateRoundTimes, self.OnUpdateRoundTimes, self)
|
|
|
|
--UITool.ButtonOnClickShowPanel(self.Button_FaceNotice, WidgetConfig.EUIType.FaceNotice, true);
|
|
UITool.BindButtonClicked(self.Button_Score, self.OnShowScore, self)
|
|
|
|
if DefaultSettings.EnableTest then
|
|
self.WB_InTest_Side:LuaInit();
|
|
UITool.BindButtonClicked(self.Button_TestSide, self.OnClickTestSide, self);
|
|
UITool.BindButtonClicked(self.Button_Test_Custom, self.OnClickCustomTest, self);
|
|
GlobalTickTool:AddTick(self, function(o, dt, st)
|
|
o.TextBlock_ServerTime:SetText(string.format("服务器时间:%0.1f", st))
|
|
end);
|
|
self.CanvasPanel_Test:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
|
|
else
|
|
self.CanvasPanel_Test:SetVisibility(ESlateVisibility.Collapsed);
|
|
end
|
|
|
|
self.TextBlock_Time:SetText("0")
|
|
self.TextBlock_SelfScore:SetText("0")
|
|
self.TextBlock_EnemyScore:SetText("0")
|
|
self.WB_RoundEnd:SetVisibility(ESlateVisibility.Collapsed);
|
|
|
|
if self.ShowRoundTimes then
|
|
self.TextBlock_Time:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
|
|
else
|
|
self.TextBlock_Time:SetVisibility(ESlateVisibility.Collapsed);
|
|
end
|
|
|
|
UIManager:Register("WB_KDALine", self.WB_KDALine)
|
|
UIManager:Register("WB_RoundEnd", self.WB_RoundEnd);
|
|
UIManager:Register("WB_SelectParts", self.WB_SelectParts);
|
|
UIManager:Register("WB_Main", self);
|
|
|
|
-- 检查当前状态是什么
|
|
UGCLogSystem.Log("[WB_Main:Construct] MiniGameManager.State = %s", tostring(MiniGameManager.State));
|
|
if MiniGameManager.State then
|
|
if MiniGameManager.State < MiniGameState.ROUND_GAMING then
|
|
self.CanvasPanel_Prepare:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
|
|
end
|
|
end
|
|
|
|
self.WB_KDALine:LuaInit();
|
|
self.WB_SelectParts:LuaInit();
|
|
self.WB_SelectParts:SetType({ EWeaponPartType.Telescope, EWeaponPartType.Grip, EWeaponPartType.Muzzle, });
|
|
if DefaultSettings.EnableTest then
|
|
self:OnClickTestSide();
|
|
end
|
|
end
|
|
|
|
function WB_Main:Destruct()
|
|
UGCEventSystem.RemoveListener(EventTypes.CountDownTimeChange, self.OnCountDownChange, self)
|
|
UGCEventSystem.RemoveListener(EventTypes.AllPlayerKDAChange, self.OnAllPlayerKDAChange, self);
|
|
UGCEventSystem.RemoveListener(EventTypes.MiniStateChange, self.OnMiniStateChange, self);
|
|
UGCEventSystem.RemoveListener(EventTypes.UpdateRoundTimes, self.OnUpdateRoundTimes, self);
|
|
end
|
|
|
|
function WB_Main:OnClickTestSide()
|
|
UITool.TurnVisible(self.WB_InTest_Side)
|
|
end
|
|
|
|
function WB_Main:OnClickCustomTest()
|
|
if self.IsTestShow then
|
|
self.WB_InTest_Side:SetVisibility(ESlateVisibility.Collapsed)
|
|
self.Button_FaceNotice:SetVisibility(ESlateVisibility.Collapsed)
|
|
self.Button_Test:SetVisibility(ESlateVisibility.Collapsed)
|
|
self.Button_TestSide:SetVisibility(ESlateVisibility.Collapsed)
|
|
else
|
|
self.WB_InTest_Side:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
self.Button_FaceNotice:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
self.Button_Test:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
self.Button_TestSide:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
end
|
|
self.IsTestShow = not self.IsTestShow;
|
|
end
|
|
|
|
function WB_Main:OnCountDownChange(InTime)
|
|
if not self.ShowRoundTimes then
|
|
UGCLogSystem.Log("[WB_Main:OnCountDownChange] InTime = %s", tostring(InTime));
|
|
if InTime <= 0 then
|
|
self.TextBlock_CountDown:SetText("00:00")
|
|
else
|
|
self.TextBlock_CountDown:SetText(string.format("%02d:%02d", InTime // 60, InTime % 60));
|
|
end
|
|
end
|
|
end
|
|
|
|
---@param InList table<int32, PlayerKDA_DamageItem>
|
|
function WB_Main:OnAllPlayerKDAChange(InList)
|
|
self.TextBlock_SelfScore:SetText(LocalKillNum);
|
|
self.TextBlock_EnemyScore:SetText(MaxKillNum);
|
|
UGCLogSystem.Log("[WB_Main:OnAllPlayerKDAChange] Self Kill = %s, Max Kill = %s", tostring(LocalKillNum), tostring(MaxKillNum));
|
|
end
|
|
|
|
WB_Main.IsShowScore = false;
|
|
|
|
function WB_Main:OnShowScore()
|
|
self.IsShowScore = not self.IsShowScore;
|
|
if self.IsShowScore then
|
|
self:PlayAnimation(self.ShowKDAInfo, 0, 1, EUMGSequencePlayMode.Forward, 1)
|
|
else
|
|
self:PlayAnimation(self.ShowKDAInfo, 0, 1, EUMGSequencePlayMode.Reverse, 1);
|
|
end
|
|
end
|
|
|
|
WB_Main.DotCount = 0;
|
|
|
|
function WB_Main:OnPrepareTick()
|
|
self.DotCount = (self.DotCount + 1) % 3;
|
|
local Str = "游戏准备中."
|
|
for i = 1, self.DotCount do Str = Str .. '.' end
|
|
self.TextBlock_Prepare:SetText(Str);
|
|
end
|
|
|
|
WB_Main.IsShowDetail = false;
|
|
|
|
function WB_Main:OnGameStart()
|
|
self.CanvasPanel_Prepare:SetVisibility(ESlateVisibility.Collapsed);
|
|
GlobalTickTool:RemoveCustomTick(self);
|
|
self.DotCount = nil;
|
|
end
|
|
|
|
WB_Main.ShowRoundWinTimer = nil;
|
|
|
|
function WB_Main:ShowRoundWin(IsShow, Winner)
|
|
if IsShow then
|
|
self.WB_RoundEnd:SetVisibility(ESlateVisibility.HitTestInvisible);
|
|
self.WB_RoundEnd:SetWin(Winner == LocalPlayerKey);
|
|
-- 定时关闭
|
|
UGCEventSystem.SetTimer(self, function()
|
|
self.WB_RoundEnd:SetVisibility(ESlateVisibility.Collapsed);
|
|
end, 10);
|
|
else
|
|
self.WB_RoundEnd:SetVisibility(ESlateVisibility.Collapsed);
|
|
if self.ShowRoundWinTimer ~= nil then
|
|
UGCEventSystem.StopTimer(self.ShowRoundWinTimer);
|
|
self.ShowRoundWinTimer = nil;
|
|
end
|
|
end
|
|
end
|
|
|
|
function WB_Main:OnMiniStateChange(InState)
|
|
self.TextBlock_State:SetText(TableHelper.printEnum(MiniGameState, InState));
|
|
if InState >= MiniGameState.ROUND_GAMING then
|
|
self.CanvasPanel_Prepare:SetVisibility(ESlateVisibility.Collapsed);
|
|
end
|
|
end
|
|
|
|
function WB_Main:OnUpdateRoundTimes(InTimes, InTotal)
|
|
UGCLogSystem.Log("[WB_Main:OnUpdateRoundTimes] InTimes = %s, InTotal = %s", tostring(InTimes), tostring(InTotal));
|
|
if InTimes ~= nil and InTotal ~= nil then
|
|
self.TextBlock_Time:SetText(tostring(InTotal - InTimes));
|
|
end
|
|
end
|
|
|
|
function WB_Main:OnUpdateRoundWinners(InWinners)
|
|
local Rounds = {};
|
|
for i, v in pairs(InWinners) do
|
|
Rounds[v.Winner] = 1 + (Rounds[v.Winner] or 0)
|
|
end
|
|
local Func = function(InPlayerKey)
|
|
if InPlayerKey == nil then return 0; end
|
|
if Rounds[InPlayerKey] then return Rounds[InPlayerKey]; end
|
|
return 0;
|
|
end
|
|
UGCLogSystem.LogTree(string.format("[WB_Main:OnUpdateRoundWinners] Rounds ="), Rounds);
|
|
for i, v in pairs(Rounds) do
|
|
if i == LocalPlayerKey then
|
|
self.TextBlock_SelfScore:SetText(Func(i));
|
|
else
|
|
self.TextBlock_EnemyScore:SetText(Func(i));
|
|
end
|
|
end
|
|
end
|
|
|
|
function WB_Main:ShowTip(IsShow)
|
|
self.WB_BuyButton:ShowTip(IsShow);
|
|
end
|
|
|
|
------------------------------------ Test ------------------------------------
|
|
function WB_Main:AddLogItems(InList)
|
|
self.WB_TestLog:AddLogItems(InList);
|
|
end
|
|
|
|
function WB_Main:AddLogItem(Color, fmt, ...)
|
|
self.WB_TestLog:AddLog(Color, fmt, ...);
|
|
end
|
|
|
|
|
|
return WB_Main; |