2025-01-04 23:00:19 +08:00

65 lines
2.4 KiB
Lua
Raw 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_Play = {
GameTime = 0;
GameEndEvent = "";
}
-- 触发器激活时将执行Action的Execute
function Action_Play:Execute(...)
self.bEnableActionTick = true
UGCGameSystem.GameState:SetGameStateType(Enum.EGameState.Playing)
local TempPlayerControllers = UGCGameSystem.GetAllPlayerController()
for _,PlayerController in pairs(TempPlayerControllers) do
local Pawn = UGCGameSystem.GetPlayerPawnByPlayerKey(PlayerController.PlayerKey);
if UE.IsValid(Pawn) then Pawn:K2_DestroyActor() end
UGCGameSystem.GetRespawnComponent():AddRespawnPlayer(PlayerController.PlayerKey, 0)
if PlayerController.PlayerState then PlayerController.PlayerState:ResetPlayerState() end
UGCLogSystem.Log("[Action_Play_Execute] ResSpawnSucceed Key: %d", PlayerController.PlayerKey)
end
UGCGameSystem.GameState:ResetTrophy()
UGCGameSystem.GameState:UpdateAllPlayerScoreDatas()
--UGCGameSystem.GameState:ClearPlayerBuff()
UGCEventSystem.AddListener(EventEnum.GameEnd, self.GameFinish, self)
self.GameStartTime = GameplayStatics.GetRealTimeSeconds(self);
self.LastUpdateRemainTime = self.GameTime
UGCGameSystem.GameState.GameTime = self.GameTime
UGCLogSystem.Log("[Action_Play_Execute] Finish")
return true
end
function Action_Play:GameFinish()
self.bEnableActionTick = false
if self.GameEndEvent ~= "" then
UGCGameSystem.SendModeCustomEvent(self.GameEndEvent)
else
UGCLogSystem.Log("[Action_Play_GameFinish] GameEndEvent is nil")
end
end
function Action_Play:Update(DeltaSeconds)
local CurrentRealTime = GameplayStatics.GetRealTimeSeconds(self);
local RemainTime = self.GameTime - (CurrentRealTime - self.GameStartTime);
local CurrentUpdateRemainTime = math.ceil(RemainTime)
if self.LastUpdateRemainTime - CurrentUpdateRemainTime >= 1 then
if CurrentUpdateRemainTime <= 0 then
self.LastUpdateRemainTime = 0
UGCGameSystem.GameState:GameFinish(UGCGameSystem.GameState:GetTop1Player())
-- UGCGameSystem.GameState:SetGameStateType(Enum.EGameState.End)
-- UGCEventSystem.SendEvent(EventEnum.GameEnd)
else
self.LastUpdateRemainTime = CurrentUpdateRemainTime
end
UGCGameSystem.GameState.GameTime = self.LastUpdateRemainTime
UGCLogSystem.Log("[Action_Play_Update] WaitTime: %d", self.LastUpdateRemainTime)
end
end
return Action_Play