83 lines
2.8 KiB
Lua
Raw Normal View History

2025-01-04 23:00:19 +08:00
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
-- 设置无敌状态
local AllPawn = UGCGameSystem.GetAllPlayerPawn()
for i, v in pairs(AllPawn) do
UGCPawnSystem.SetIsInvincible(v, true)
end
self:ExecuteOtherLogic()
self.bEnableActionTick = true
return true
end
function EventAction_RoundEnd:GameFinish()
self.bEnableActionTick = false
self:OtherGameFinishLogic()
-- 判断游戏是否结束
if 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.GameState:IsFinishRound()
or UGCGameSystem.GameState:GetMaxTeamScore() > GlobalConfigs.GameSetting.MaxRound // 2
or #UGCTeamSystem.GetPlayerKeysByTeamID(1) < 1 or #UGCTeamSystem.GetPlayerKeysByTeamID(2) < 1
end
--其他逻辑可修改替换 ------------------------
function EventAction_RoundEnd:ExecuteOtherLogic()
local AllPC = UGCGameSystem.GetAllPlayerController()
for i, PC in pairs(AllPC) do
UGCGameSystem.LeaveSpectating(PC)
end
--local IsAttackSucceed = UGCGameSystem.GameState:IsBreakThroughSucceed()
-- 显示回合结束界面UI
UGCSendRPCSystem.ClientShowUI(nil, WidgetConfig.EUIType.RoundFinish, true, false, UGCGameSystem.GameState:GetWinningTeam())
--UGCGameSystem.GameState:ShowSimplePlayModeUI(WidgetConfig.EUIType.RoundFinish, { UGCGameSystem.GameState:GetWinningTeam(),})
end
function EventAction_RoundEnd:OtherGameFinishLogic()
-- 调换出生点
if GlobalConfigs.GameSetting.ActiveChangeTeam then
if UGCGameSystem.GameState:GetRoundCount() == GlobalConfigs.GameSetting.MaxRound // 2 then
local AllPC = UGCGameSystem.GetAllPlayerController()
for i, PC in pairs(AllPC) do
if PC:GetStartPointType() == EPlayerStartType.Team1 then
PC:SetStartPointType(EPlayerStartType.Team2)
else
PC:SetStartPointType(EPlayerStartType.Team1)
end
end
UGCGameSystem.GameState:SetAttackTeam(2)
end
end
end
return EventAction_RoundEnd