58 lines
2.4 KiB
Lua
58 lines
2.4 KiB
Lua
|
GlobalLogic_PlayerDeadEffect = GlobalLogic_PlayerDeadEffect or {}
|
||
|
|
||
|
GlobalLogic_PlayerDeadEffect.AllDeadToScore = {};
|
||
|
GlobalLogic_PlayerDeadEffect.SpawnNum = GlobalConfigs.GameModeSetting.MaxPlayerNum;
|
||
|
GlobalLogic_PlayerDeadEffect.DeadToScoreIndex = 1;
|
||
|
|
||
|
function GlobalLogic_PlayerDeadEffect.Init()
|
||
|
if UGCGameSystem.IsServer() then
|
||
|
GlobalLogic_PlayerDeadEffect.ServerInit()
|
||
|
else
|
||
|
GlobalLogic_PlayerDeadEffect.ClientInit()
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function GlobalLogic_PlayerDeadEffect.ServerInit()
|
||
|
-- PlayerKey, KillerKey, WeaponID, DamageType, IsHeadShotDamage, Distance
|
||
|
UGCEventSystem.AddListener(EventEnum.PlayerDeathInfo, GlobalLogic_PlayerDeadEffect.PlayerDead)
|
||
|
end
|
||
|
|
||
|
function GlobalLogic_PlayerDeadEffect.PlayerDead(DeadPlayerKey)
|
||
|
local DeadPlayer = UGCGameSystem.GetPlayerPawnByPlayerKey(DeadPlayerKey)
|
||
|
if UE.IsValid(DeadPlayer) then
|
||
|
local FloorPos = DeadPlayer:K2_GetActorLocation()
|
||
|
FloorPos.Z = FloorPos.Z - DeadPlayer.CapsuleComponent.CapsuleHalfHeight
|
||
|
UGCSendRPCSystem.ExeStaticLogic(nil, LogicConfig.ELogicType.PlayerDeadEffect, "ClientShowDeadScore", DeadPlayer, VectorHelper.ToLuaTable(FloorPos))
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function GlobalLogic_PlayerDeadEffect.ClientInit()
|
||
|
for i = 1, GlobalLogic_PlayerDeadEffect.SpawnNum do
|
||
|
local EffectActor = GlobalInit.SpawnActorFromPath(ObjectPathTable.BP_PlayerDeadParticle_Class)
|
||
|
GlobalLogic_PlayerDeadEffect.AllDeadToScore[i] = EffectActor
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function GlobalLogic_PlayerDeadEffect.AllDeadToScoreIsEmpty()
|
||
|
return #GlobalLogic_PlayerDeadEffect.AllDeadToScore <= 0
|
||
|
end
|
||
|
|
||
|
function GlobalLogic_PlayerDeadEffect.GetNextDeadToScoreActor()
|
||
|
local Res = GlobalLogic_PlayerDeadEffect.AllDeadToScore[GlobalLogic_PlayerDeadEffect.DeadToScoreIndex]
|
||
|
GlobalLogic_PlayerDeadEffect.DeadToScoreIndex = (GlobalLogic_PlayerDeadEffect.DeadToScoreIndex % GlobalLogic_PlayerDeadEffect.SpawnNum) + 1
|
||
|
return Res
|
||
|
end
|
||
|
|
||
|
function GlobalLogic_PlayerDeadEffect.ClientShowDeadScore(DeadPlayer, Pos)
|
||
|
if UE.IsValid(DeadPlayer) then
|
||
|
DeadPlayer:SetActorHiddenInGame(true)
|
||
|
end
|
||
|
if GlobalLogic_PlayerDeadEffect.AllDeadToScoreIsEmpty() then
|
||
|
UGCLogSystem.LogError("[GlobalLogic_PlayerDeadEffect_ClientShowDeadScore] AllDeadToScore is empty")
|
||
|
return
|
||
|
end
|
||
|
local DeadScoreActor = GlobalLogic_PlayerDeadEffect.GetNextDeadToScoreActor()
|
||
|
DeadScoreActor:UpdateDeadInfo(Pos)
|
||
|
end
|
||
|
|
||
|
return GlobalLogic_PlayerDeadEffect
|