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

44 lines
1.5 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_GameStart = { };
-- 触发器激活时将执行Action的Execute
function Action_GameStart:Execute(...)
-- 游戏正式开始
self.GameTime = DefaultSettings.GameTime;
if self.GameTime == -1 then
self.CountTime = 0;
self.GameTimeTick = 0.;
else
self.CountTime = math.floor(DefaultSettings.GameTime);
end
GameState:OnGameStart();
UGCEventSystem.AddListener(EventTypes.GameEnd, self.GameEnd, self);
return true
end
function Action_GameStart:GameEnd()
self.bEnableActionTick = false;
GameState:ChangeGameProgressState(DefaultSettings.EGameProgress.ENDED);
end
-- 需要勾选Action的EnableTick才会执行Update
-- 触发器激活后将在每个tick执行Action的Update直到self.bEnableActionTick为false
function Action_GameStart:Update(DeltaSeconds)
if self.GameTime > 0 then
self.GameTime = self.GameTime - DeltaSeconds;
local CurrTime = math.floor(self.GameTime);
if CurrTime ~= self.CountTime then
--UGCGameSystem.GameState:OnGameProgress_Tick(CurrTime);
self.CountTime = CurrTime;
end
if self.CountTime <= 0 then self:GameEnd(); end
else
self.GameTimeTick = self.GameTimeTick + DeltaSeconds;
local CurrTime = math.floor(self.GameTimeTick);
if CurrTime ~= self.CountTime then
--UGCGameSystem.GameState:OnGameProgress_Tick(CurrTime);
self.CountTime = CurrTime;
end
end
end
return Action_GameStart