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

56 lines
1.6 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 EventAction_RoundEnd = {
GameTime = 0;
GameEndEvent = -1;
NewRoundEvent = -1
}
-- 触发器激活时将执行Action的Execute
function EventAction_RoundEnd:Execute(...)
if not UGCGameSystem.IsServer() then return end
self.GameTimeInst = self.GameTime
-- 临时保存当前地图信息
UGCGameSystem.GameState:UpdateLastPlayMapInfo()
local IsAttackSucceed = UGCGameSystem.GameState:IsAttackSucceed()
-- 显示回合结束界面UI
UGCGameSystem.GameState:ShowSimplePlayModeUI(WidgetConfig.EUIType.RoundFinish, { IsAttackSucceed, UGCGameSystem.GameState:GetNowDefenderSelectMap() })
-- 设置无敌状态
local AllPawn = UGCGameSystem.GetAllPlayerPawn()
for i, v in pairs(AllPawn) do
UGCPawnSystem.SetIsInvincible(v, true)
end
self.bEnableActionTick = true
return true
end
function EventAction_RoundEnd:GameFinish()
self.bEnableActionTick = false
-- 判断游戏是否结束
if UGCGameSystem.GameState:IsFinishPlayer() or self:CheckGameEnd() then
UGCGameSystem.GameState:GameFinish()
-- 发送游戏结束事件
UGCEventSystem.SendEvent(self.GameEndEvent)
else
-- 触发新的回合事件
UGCEventSystem.SendEvent(self.NewRoundEvent)
end
end
function EventAction_RoundEnd:Update(DeltaSeconds)
self.GameTimeInst = self.GameTimeInst - DeltaSeconds
if self.GameTimeInst <= 0 then
self:GameFinish()
end
end
--- 检查玩法人数是否足够
function EventAction_RoundEnd:CheckGameEnd()
return #UGCGameSystem.GetAllPlayerController() <= 1
end
return EventAction_RoundEnd