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

76 lines
2.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_GameEnd = {
DelayOffDS = 3.;
}
-- 触发器激活时将执行Action的Execute
function EventAction_GameEnd:Execute(...)
if UGCGameSystem.IsServer() then
local AllPC = UGCGameSystem.GetAllPlayerController()
for i, v in pairs(AllPC) do
-- 增加玩家游玩次数
local NumberOfPlay = ArchiveDataConfig.GetPlayerArchiveDataFromType(v.PlayerKey, ArchiveDataConfig.EArchiveType.NumberOfPlay)
ArchiveDataConfig.SavePlayerArchiveData(v.PlayerKey, NumberOfPlay and NumberOfPlay + 1 or 1)
-- 每日任务完成游戏数
UGCGameSystem.GameState:AddTaskCountByType(v.PlayerKey, DailyTasksConfig.ETaskType.CompleteMatch, 1)
end
-- 增加守方MVP每日任务完成数
local DefendMVP = UGCGameSystem.GameState:GetDefendMVP()
if DefendMVP then
UGCGameSystem.GameState:AddTaskCountByType(DefendMVP, DailyTasksConfig.ETaskType.DefensiveMVP, 1)
end
-- 增加攻方MVP每日任务完成数
local AttackMVP = UGCGameSystem.GameState:GetAttackMVP()
if AttackMVP then
UGCGameSystem.GameState:AddTaskCountByType(AttackMVP, DailyTasksConfig.ETaskType.AttackMVP, 1)
end
-- 显示结束界面UI
UGCGameSystem.GameState:ShowSimplePlayModeUI(WidgetConfig.EUIType.Settlement)
-- 删除所有玩家以防出现玩家产生的音效
--local AllPawn = UGCGameSystem.GetAllPlayerPawn()
--for i, PlayerPawn in pairs(AllPawn) do
-- PlayerPawn:K2_DestroyActor()
--end
-- 发送结束协议等关闭操作
self:SendUGCModeBattleResult()
else
end
return true
end
-- 结算、关闭DS
function EventAction_GameEnd:SendUGCModeBattleResult()
-- 保存成就数据
UGCEventSystem.SendEvent(EventEnum.AchievementSettlement)
-- 向所有玩家发送结束协议
local AllPC = UGCGameSystem.GetAllPlayerController()
for _, PC in pairs(AllPC) do
if PC then
UGCGameSystem.SendPlayerSettlement(PC.PlayerKey);
UGCLogSystem.Log("[EventAction_GameEnd_SendUGCModeBattleResult] SendPlayerSettlement %s", tostring(PC.PlayerKey))
else
UGCLogSystem.LogError("[EventAction_GameEnd_SendUGCModeBattleResult] PC is nil !")
end
end
-- 延迟关闭DS
UGCEventSystem.SetTimer(
UGCGameSystem.GameState,
function()
UGCGameSystem.SendModeCustomEvent("GameEndAgreement")
UGCLogSystem.Log("[EventAction_GameEnd_SendUGCModeBattleResult] Close DS Finsh")
end,
self.DelayOffDS
)
end
return EventAction_GameEnd