UGCProjects/ProjectTemp_T/Script/gamemode/Action_RoundSettle.lua
2025-01-04 23:00:19 +08:00

80 lines
2.2 KiB
Lua
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local Action_RoundSettle = {
}
-- 触发器激活时将执行Action的Execute
function Action_RoundSettle:Execute(...)
-- 倒计时时间
UGCLogSystem.Log("[Action_RoundSettle:Execute] 执行")
self.LastRoundTime = DefaultSettings.RoundInfo.RoundSettleTime;
--
self.TotalRoundTime = self.LastRoundTime;
UGCGameSystem.GameState:StartRoundSettle();
self.bEnableActionTick = true;
self.CounterTime = 0.;
-- 重置一下当前所有玩家
self:RespawnPlayers();
local PCs = UGCGameSystem.GetAllPlayerController();
for i, v in pairs(PCs) do
if v.InSpectate then
v:ExitSpectate();
end
end
return true
end
-- 需要勾选Action的EnableTick才会执行Update
-- 触发器激活后将在每个tick执行Action的Update直到self.bEnableActionTick为false
function Action_RoundSettle:Update(DeltaSeconds)
if self.LastRoundTime > 0. then
self.LastRoundTime = self.LastRoundTime - DeltaSeconds;
self.CounterTime = self.CounterTime + DeltaSeconds;
if self.CounterTime >= 1 then
self.CounterTime = self.CounterTime - 1;
if self.LastRoundTime > 0 then
UGCGameSystem.GameState:UpdateRoundSettleTime(self.LastRoundTime);
end
end
if self.LastRoundTime <= 0 then
UGCGameSystem.GameState:UpdateRoundSettleTime();
self.bEnableActionTick = false;
end
end
end
-- 重置所有玩家
function Action_RoundSettle:ResetPlayers()
for TeamId, PlayerKeyList in pairs(UGCGameSystem.GameState.PlayerTeams) do
for i, PlayerKey in pairs(PlayerKeyList) do
--- 击杀玩家
local Pawn = UGCGameSystem.GetPlayerPawnByPlayerKey(PlayerKey);
local PC = UGCGameSystem.GetPlayerControllerByPlayerKey(PlayerKey);
if UE.IsValid(Pawn) then
Pawn:K2_DestroyActor();
end
if UE.IsValid(PC) then
PC:ExitSpectate();
end
end
end
end
-- 所有玩家重生
function Action_RoundSettle:RespawnPlayers()
for TeamId, PlayerKeyList in pairs(UGCGameSystem.GameState.PlayerTeams) do
for i, PlayerKey in pairs(PlayerKeyList) do
local Pawn = UGCGameSystem.GetPlayerPawnByPlayerKey(PlayerKey);
if UE.IsValid(Pawn) and Pawn:IsAlive() then
else
--UGCGameSystem.GetRespawnComponent():AddRespawnPlayer(PlayerKey);
end
end
end
end
return Action_RoundSettle