local Action_PlayerDeadUpdateInfo = { DeadPlayerKey = ""; KillerPlayerKey = ""; WeaponID = -1; } -- 触发器激活时,将执行Action的Execute function Action_PlayerDeadUpdateInfo:Execute(...) self.N_KillerPlayerKey = tonumber(self.KillerPlayerKey) self.N_DeadPlayerKey = tonumber(self.DeadPlayerKey) -- 判断是否在游戏 if UGCGameSystem.GameState.GameStateType ~= Enum.EGameState.Playing and UGCGameSystem.GameState.GameStateType ~= Enum.EGameState.Waiting then -- UGCGameSystem.GetRespawnComponent():AddRespawnPlayer(self.DeadPlayerKey, 0) UGCGameSystem.GameMode:Server_RespawnPlayer(self.N_DeadPlayerKey) return end local NowTime = KismetSystemLibrary.GetGameTimeInSeconds(self) local KillerPlayerState = UGCGameSystem.GetPlayerStateByPlayerKey(self.N_KillerPlayerKey) if UE.IsValid(KillerPlayerState) and KillerPlayerState ~= DeadPlayerState then -- 增加杀敌数 KillerPlayerState.ScoreData.Kill = KillerPlayerState.ScoreData.Kill + 1 table.insert(KillerPlayerState.CurrentLifeKilledPlayers, {DeadPlayerKey = self.N_DeadPlayerKey, Time = NowTime, WeaponID = self.WeaponID}) end local DeadPlayerState = UGCGameSystem.GetPlayerStateByPlayerKey(self.N_DeadPlayerKey) if UE.IsValid(DeadPlayerState) then -- 增加死亡数 DeadPlayerState.ScoreData.Dead = DeadPlayerState.ScoreData.Dead + 1 DeadPlayerState:PlayerDead() table.insert(DeadPlayerState.PlayerDeadInfo, {KillerKey = self.N_KillerPlayerKey, Time = NowTime}) -- 重置死亡者Buff槽 -- UGCGameSystem.GameState:RemovePlayerBuff(self.DeadPlayerKey) end -- 更新玩家得分 self:UpdatePlayerScore() return true end function Action_PlayerDeadUpdateInfo:UpdatePlayerScore() local DeadPlayerRewardScore = UGCGameSystem.GameState:GetPlayerRewardScore(self.N_DeadPlayerKey) local AddGoldCoin = GlobalConfigs.RewardScoreToGoldCoin(DeadPlayerRewardScore) -- 增加玩家金币数 UGCGameSystem.GameState:AddPlayerOwnGoldCoin(self.N_KillerPlayerKey, AddGoldCoin) -- 增加玩家悬赏分 UGCGameSystem.GameState:AddPlayerRewardScore(self.N_KillerPlayerKey, 1) -- 增加玩家得分 UGCGameSystem.GameState:AddScore(self.N_KillerPlayerKey, GlobalConfigs.GetPlayerAddScoreFromRewardScore(DeadPlayerRewardScore)) -- 刷新玩家数据 UGCGameSystem.GameState:UpdateAllPlayerScoreDatas() -- 重置死亡玩家悬赏分 UGCGameSystem.GameState:ResetPlayerRewardScore(self.N_DeadPlayerKey) end --[[ -- 需要勾选Action的EnableTick,才会执行Update -- 触发器激活后,将在每个tick执行Action的Update,直到self.bEnableActionTick为false function Action_PlayerDeadUpdateInfo:Update(DeltaSeconds) end ]] return Action_PlayerDeadUpdateInfo