91 lines
3.5 KiB
Lua
91 lines
3.5 KiB
Lua
|
local BuffAction_ShowEnemyPos = {
|
|||
|
|
|||
|
-- 以下参数信息可以通过manager的 GetBuffDefaultParam(BuffPath, ParamName)来获取 --
|
|||
|
-- 默认颜色信息,非必要参数
|
|||
|
BuffColor = {R = 0.97, G = 0.88, B = 0.1, A = 1.};
|
|||
|
--BuffIconPath = "默认Icon路径,非必要参数";
|
|||
|
--BuffParticlePath = "默认粒子路径,非必要参数";
|
|||
|
--BuffDesc = "Buff描述信息,非必要参数";
|
|||
|
--------------------------------------------------------------------------------
|
|||
|
|
|||
|
PlayerKey = {};
|
|||
|
}
|
|||
|
|
|||
|
--- 必须包含ApplyBuff函数
|
|||
|
---@param BuffTag any Buff的标签
|
|||
|
---@param ValidPawn UGCPlayerPawn_C
|
|||
|
---@tparam Any
|
|||
|
---@return bool
|
|||
|
function BuffAction_ShowEnemyPos:ApplyBuff(BuffTag, ValidPawn)
|
|||
|
local SelfPlayerKey = ValidPawn.PlayerKey
|
|||
|
local TeamId = UGCPlayerStateSystem.GetTeamID(SelfPlayerKey);
|
|||
|
UGCSendRPCSystem.ActorRPCNotify(nil, UGCGameSystem.GameState, "ApplyShowEnemyPos", true, TeamId, self.BuffType);
|
|||
|
|
|||
|
self.PlayerKey = {};
|
|||
|
local PCs = UGCGameSystem.GetAllPlayerController(false);
|
|||
|
for i, v in pairs(PCs) do
|
|||
|
local TheTeamId = UGCPlayerStateSystem.GetTeamID(v.PlayerKey);
|
|||
|
if TeamId == TheTeamId then
|
|||
|
self.PlayerKey[#self.PlayerKey + 1] = v.PlayerKey;
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
return true;
|
|||
|
end
|
|||
|
|
|||
|
--- 可以包含RemoveBuff,若包含该函数则玩家应用该Buff时会保存Buff信息缓存,作为移除或者获取玩家当前Buff的备份信息
|
|||
|
---@param BuffTag any Buff的标签
|
|||
|
---@param ValidPawn UGCPlayerPawn_C
|
|||
|
---@tparam Args ... Any Args顺序必须与ApplyBuff顺序一致
|
|||
|
function BuffAction_ShowEnemyPos:RemoveBuff(BuffTag, ValidPawn)
|
|||
|
-- Remove逻辑
|
|||
|
|
|||
|
-- 通过BuffManager调用RPC
|
|||
|
--BP_BuffManager.GetBuffManager():BuffNotifyRPC(ValidPawn.PlayerKey, BP_BuffManager.GetBuffFileName(), "Client_RPCFunc", ValidPawn, false)
|
|||
|
--UGCLogSystem.Log("[BuffAction_ShowEnemyPos:RemoveBuff] , self.BuffType = %s", self.BuffType);
|
|||
|
--local TeamId = UGCPlayerStateSystem.GetTeamID(ValidPawn.PlayerKey);
|
|||
|
--UGCSendRPCSystem.ActorRPCNotify(nil, UGCGameSystem.GameState, "ApplyShowEnemyPos", false, TeamId, self.BuffType);
|
|||
|
end
|
|||
|
|
|||
|
function BuffAction_ShowEnemyPos:SetBuffType(InType)
|
|||
|
UGCLogSystem.Log("[BuffAction_ShowEnemyPos:SetBuffType] InType = %s", tostring(InType));
|
|||
|
self.BuffType = InType;
|
|||
|
end
|
|||
|
|
|||
|
--- Tick函数 服务器客户端均会调用
|
|||
|
--function BuffAction_ShowEnemyPos:Tick(DeltaTime)
|
|||
|
-- -- Tick逻辑
|
|||
|
--end
|
|||
|
|
|||
|
--- 触发的RPC函数
|
|||
|
---@param ValidPawn UGCPlayerPawn_C
|
|||
|
---@param Enable bool
|
|||
|
function BuffAction_ShowEnemyPos:Client_RPCFunc(ValidPawn, Enable)
|
|||
|
-- 显示一下
|
|||
|
UGCLogSystem.Log("[BuffAction_ShowEnemyPos:Client_RPCFunc] 执行")
|
|||
|
self:ApplyShowEnemyPos(Enable, ValidPawn.PlayerKey)
|
|||
|
end
|
|||
|
|
|||
|
--- 应用显示敌方位置
|
|||
|
function BuffAction_ShowEnemyPos:ApplyShowEnemyPos(Enable, TeamId)
|
|||
|
if self.BuffType ~= nil then
|
|||
|
local ShowTable = BP_BuffManager.CachedInit[self.BuffType];
|
|||
|
local OtherTeamPlayers = UGCGameSystem.GameState:GetOtherPlayerKeys(TeamId);
|
|||
|
if table.isEmpty(OtherTeamPlayers) then
|
|||
|
return
|
|||
|
end
|
|||
|
for i = 1, #OtherTeamPlayers do
|
|||
|
ShowTable[i]:SetTrackPlayerKey(OtherTeamPlayers[i]);
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function BuffAction_ShowEnemyPos:GetBenefitPlayer()
|
|||
|
return self.PlayerKey;
|
|||
|
end
|
|||
|
|
|||
|
--- 当玩家死亡时会触发该函数,作用于以PlayerKey给玩家Buff的BuffAction,以防UGC的Pawn不删除机制所引发的Bug
|
|||
|
function BuffAction_ShowEnemyPos:PlayerDeathCallBack(PlayerKey)
|
|||
|
end
|
|||
|
|
|||
|
return BuffAction_ShowEnemyPos
|