local MiniGameMode_CollectNotes = { IsGameEnd = false; bIsInGame = false; -- 给玩家结算添加的得分{[PlayerKey] = AddScore, ...} PlayerAddScore = {}; MiniGameScore = {}; PlayerGravityScale = 1; JumpScale = 1; MoveSpeedScale = 1; } --- 游戏初始化 function MiniGameMode_CollectNotes:Init() self.PlayerGravityScale = MiniGameConfig.MiniGameInfo[MiniGameConfig.MiniGameType.CollectNotes].GameParam.GravityScale self.JumpScale = MiniGameConfig.MiniGameInfo[MiniGameConfig.MiniGameType.CollectNotes].GameParam.JumpVelocityScale self.MoveSpeedScale = MiniGameConfig.MiniGameInfo[MiniGameConfig.MiniGameType.CollectNotes].GameParam.MoveSpeedScale self.RotatorAttachPath = MiniGameConfig.MiniGameInfo[MiniGameConfig.MiniGameType.CollectNotes].GameParam.RotatorAttachPath UGCEventSystem.AddListener(EventEnum.PlayerPickNote, self.PlayerPickNote, self) end --- 准备时间结束游戏开始 function MiniGameMode_CollectNotes:GameBegin() self.bIsInGame = true local AllRotatorAttach = GameplayStatics.GetAllActorsOfClass(UGCGameSystem.GameState, UE.LoadClass(self.RotatorAttachPath), {}) for i, FloorAttach in pairs(AllRotatorAttach) do FloorAttach:StartRotator(true) end end function MiniGameMode_CollectNotes:Update(DeltaTime) -- 判断该玩法是否已结束 if self.IsGameEnd then return end -- Update逻辑 -- Update逻辑 End end --- 设置游戏结束,手动触发会结束该玩法,倒计时结束将自动触发该函数 function MiniGameMode_CollectNotes:SetMiniGameModeEnd() if not self.IsGameEnd then self.IsGameEnd = true self:MiniGameEnd() end end --- 获取当前回合游戏结算, ---@return "{[PlayerKey] = AddScore, ...}" function MiniGameMode_CollectNotes:GetPlayerAddScore() return self.PlayerAddScore end --- 外层调用,判断该玩法是否已结束 function MiniGameMode_CollectNotes:CheckGameFinish() return self.IsGameEnd end --- 内部作用,判断玩法是否结束函数 function MiniGameMode_CollectNotes:CheckTrapGameIsFinish_InternalCall() return #UGCGameSystem.GetAllPlayerPawn() <= 1 end --- 结束触发 function MiniGameMode_CollectNotes:MiniGameEnd() self.PlayerAddScore = UGCGameSystem.GameState:GetPlayerMiniGameAddScore() UGCEventSystem.RemoveListener(EventEnum.PlayerPickNote, self.PlayerPickNote, self) end --self.PlayerAddScore = UGCGameSystem.GameState:GetPlayerMiniGameAddScore() --UGCGameSystem.GameState:PlayerAddMiniGameScore(PlayerKey, 1) --UGCGameSystem.GameState:GetPlayerMiniGameScore(VictimKey) ------------------------------------------ Player ------------------------------------------ --- 玩家死亡 function MiniGameMode_CollectNotes:PlayerDead(VictimKey, CauserKey, WeaponID, DamageType, IsHeadShotDamage, Distance, DamageValue, Assister) end --- 玩家伤害修改 function MiniGameMode_CollectNotes:PlayerDamageModify(DamageAmount, VictimPawn, CauserPC) --if CauserPC.Pawn then -- SkillConfig.ExeSkill(SkillConfig.ESkillType.DetectPlayer, CauserPC.Pawn) -- UGCLogSystem.Log("[MiniGameMode_CollectNotes_PlayerDamageModify] Succeed") --end if VictimPawn ~= nil and CauserPC ~= nil and CauserPC.PlayerKey ~= nil and VictimPawn.PlayerKey ~= CauserPC.PlayerKey then SkillConfig.ExeSkill(SkillConfig.ESkillType.Stun, VictimPawn) end return 0. end --- 玩家受控时 function MiniGameMode_CollectNotes:PlayerPossessed(PlayerKey) end --- 玩家BeginPlay触发 function MiniGameMode_CollectNotes:PlayerBeginPlay(PlayerPawn) PlayerPawn:SetGravityScale(self.PlayerGravityScale) PlayerPawn:SetCustomJumpZVelocity(443 * self.JumpScale) UGCEventSystem.SetTimer(UGCGameSystem.GameState, function() if UE.IsValid(PlayerPawn) then PlayerPawn:SetGravityScale(self.PlayerGravityScale) PlayerPawn:SetCustomJumpZVelocity(443 * self.JumpScale) UGCPawnAttrSystem.SetSpeedScale(PlayerPawn, self.MoveSpeedScale) UGCLogSystem.Log("[MiniGameMode_CollectNotes_PlayerBeginPlay]") end end, 1) end ---------------------------------------- Player End ---------------------------------------- function MiniGameMode_CollectNotes:PlayerPickNote(PlayerKey) if self.bIsInGame then UGCGameSystem.GameState:PlayerAddMiniGameScore(PlayerKey, 1) MiniGameConfig.CheckPlayerTask(PlayerKey, MiniGameConfig.MiniGameType.CollectNotes, UGCGameSystem.GameState:GetPlayerMiniGameScore(PlayerKey), false) end end return MiniGameMode_CollectNotes