88 lines
3.0 KiB
Lua
88 lines
3.0 KiB
Lua
|
local EventAction_RoundEnd = {
|
|||
|
GameTime = 0;
|
|||
|
GameEndEvent = -1;
|
|||
|
NewRoundEvent = -1
|
|||
|
}
|
|||
|
|
|||
|
-- 触发器激活时,将执行Action的Execute
|
|||
|
function EventAction_RoundEnd:Execute(...)
|
|||
|
if not UGCGameSystem.IsServer() then return end
|
|||
|
UGCLogSystem.Log("[EventAction_RoundEnd_Execute]")
|
|||
|
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()
|
|||
|
local MaxScore = UGCGameSystem.GameState:GetMaxTeamScore()
|
|||
|
UGCLogSystem.Log("[EventAction_RoundEnd_CheckGameEnd] MaxScore:%s", tostring(MaxScore))
|
|||
|
return UGCGameSystem.GameState:IsFinishRound()
|
|||
|
or MaxScore > 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 AllPawn = UGCGameSystem.GetAllPlayerPawn()
|
|||
|
for i, v in pairs(AllPawn) do
|
|||
|
UGCPawnSystem.DisabledPawnState(v, EPawnState.GunFire, true)
|
|||
|
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
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
|
|||
|
|
|||
|
return EventAction_RoundEnd
|