104 lines
3.3 KiB
Lua
104 lines
3.3 KiB
Lua
---@class MiniGameMode_CountingHeartShaped
|
|
---@field IsGameEnd bool
|
|
---@field PlayerAddScore table<PlayerKey, int32> 玩家获取的分数
|
|
|
|
|
|
---@type MiniGameMode_CountingHeartShaped
|
|
local MiniGameMode_CountingHeartShaped = {
|
|
IsGameEnd = false;
|
|
bIsInGame = false;
|
|
-- 给玩家结算添加的得分{[PlayerKey] = AddScore, ...}
|
|
PlayerAddScore = {};
|
|
MiniGameScore = {};
|
|
}
|
|
|
|
--- 游戏初始化
|
|
function MiniGameMode_CountingHeartShaped:Init()
|
|
-- self:InitMiniGameScore()
|
|
--UGCEventSystem.AddListener(EventEnum.AddMiniGameScore, self.PlayerAddMiniGameScore, self)
|
|
--UGCEventSystem.AddListener(EventEnum.AddMiniGameScoreList, self.PlayerAddMiniGameScoreList, self)
|
|
UGCEventSystem.AddListener(EventEnum.MiniGameEndNotify, self.SetMiniGameModeEnd, self)
|
|
|
|
|
|
self.CountingHeartManagerPath = MiniGameConfig.MiniGameInfo[MiniGameConfig.MiniGameType.CountingHeartShaped].GameParam.CountingHeartManagerPath
|
|
self.CountingHeartManager = UGCSystemLibrary.GetUniqueInstanceFromPath(self.CountingHeartManagerPath)
|
|
|
|
end
|
|
|
|
--- 准备时间结束游戏开始
|
|
function MiniGameMode_CountingHeartShaped:GameBegin()
|
|
self.bIsInGame = true
|
|
self.CountingHeartManager:GameStart()
|
|
end
|
|
|
|
function MiniGameMode_CountingHeartShaped:Update(DeltaTime)
|
|
-- 判断该玩法是否已结束
|
|
if self.IsGameEnd then return end
|
|
|
|
-- Update逻辑
|
|
|
|
|
|
|
|
-- Update逻辑 End
|
|
end
|
|
|
|
--- 设置游戏结束,手动触发会结束该玩法,倒计时结束将自动触发该函数
|
|
function MiniGameMode_CountingHeartShaped:SetMiniGameModeEnd()
|
|
if not self.IsGameEnd then
|
|
self.IsGameEnd = true
|
|
self:MiniGameEnd()
|
|
end
|
|
end
|
|
|
|
--- 获取当前回合游戏结算,
|
|
---@return "{[PlayerKey] = AddScore, ...}"
|
|
function MiniGameMode_CountingHeartShaped:GetPlayerAddScore()
|
|
return self.PlayerAddScore
|
|
end
|
|
|
|
--- 外层调用,判断该玩法是否已结束
|
|
function MiniGameMode_CountingHeartShaped:CheckGameFinish()
|
|
return self.IsGameEnd
|
|
end
|
|
|
|
--- 结束触发
|
|
function MiniGameMode_CountingHeartShaped:MiniGameEnd()
|
|
self.CountingHeartManager:StopGame()
|
|
self.PlayerAddScore = UGCGameSystem.GameState:GetPlayerMiniGameAddScore()
|
|
--UGCEventSystem.RemoveListener(EventEnum.AddMiniGameScore, self.PlayerAddMiniGameScore, self)
|
|
--UGCEventSystem.RemoveListener(EventEnum.AddMiniGameScoreList, self.PlayerAddMiniGameScoreList, self)
|
|
UGCEventSystem.RemoveListener(EventEnum.MiniGameEndNotify, self.SetMiniGameModeEnd, self)
|
|
end
|
|
|
|
------------------------------------------ Player ------------------------------------------
|
|
|
|
--- 玩家死亡
|
|
function MiniGameMode_CountingHeartShaped:PlayerDead(VictimKey, CauserKey, WeaponID, DamageType, IsHeadShotDamage, Distance, DamageValue, Assister)
|
|
|
|
end
|
|
|
|
--- 玩家伤害修改
|
|
function MiniGameMode_CountingHeartShaped:PlayerDamageModify(DamageAmount, VictimPawn, CauserPC)
|
|
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_CountingHeartShaped:PlayerPossessed(PlayerKey)
|
|
|
|
end
|
|
|
|
--- 玩家BeginPlay触发
|
|
function MiniGameMode_CountingHeartShaped:PlayerBeginPlay(PlayerPawn)
|
|
|
|
end
|
|
|
|
---------------------------------------- Player End ----------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
return MiniGameMode_CountingHeartShaped |