44 lines
1.5 KiB
Lua
44 lines
1.5 KiB
Lua
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 |