478 lines
19 KiB
Lua
478 lines
19 KiB
Lua
|
---@class UGCPlayerController_C:BP_UGCPlayerController_C
|
|||
|
--Edit Below--
|
|||
|
---@type UGCPlayerController_C
|
|||
|
local UGCPlayerController = {
|
|||
|
NeedExePlayerIsFirstTimePlaying = false;
|
|||
|
bAutoShowGuide = false;
|
|||
|
|
|||
|
|
|||
|
-- 可获得的增益次数
|
|||
|
CanObtainIncreaseCount = 0;
|
|||
|
-- 当前可选择的增益
|
|||
|
NowCanSelectIncrease = {};
|
|||
|
-- 拥有的增益
|
|||
|
OwnedIncrease = {}; -- [IncreaseType] = Level
|
|||
|
-- 增益已满
|
|||
|
IncreaseIsFull = false;
|
|||
|
};
|
|||
|
|
|||
|
-- Replicated -------------------------------------------------------------------------------------------------------
|
|||
|
|
|||
|
function UGCPlayerController:GetReplicatedProperties()
|
|||
|
return
|
|||
|
"CanObtainIncreaseCount",
|
|||
|
"NowCanSelectIncrease",
|
|||
|
"OwnedIncrease"
|
|||
|
end
|
|||
|
|
|||
|
function UGCPlayerController:OnRep_CanObtainIncreaseCount()
|
|||
|
if UGCEventSystem then
|
|||
|
UGCEventSystem.SendEvent(EventEnum.UpdateCanObtainIncreaseCount, self, self.CanObtainIncreaseCount)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function UGCPlayerController:OnRep_NowCanSelectIncrease()
|
|||
|
if UGCEventSystem then
|
|||
|
UGCEventSystem.SendEvent(EventEnum.UpdateNowCanSelectIncrease, self, self.NowCanSelectIncrease)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function UGCPlayerController:OnRep_OwnedIncrease()
|
|||
|
if UGCEventSystem then
|
|||
|
UGCEventSystem.SendEvent(EventEnum.UpdateOwnedIncrease, self, self.OwnedIncrease)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
-- Replicated End ---------------------------------------------------------------------------------------------------
|
|||
|
|
|||
|
function UGCPlayerController:ReceiveBeginPlay()
|
|||
|
self.SuperClass.ReceiveBeginPlay(self);
|
|||
|
require("Script.Global.WidgetManager.WidgetManager")
|
|||
|
|
|||
|
-- 不要自动切换相机
|
|||
|
self.bAutoManageActiveCameraTarget = false
|
|||
|
|
|||
|
self.OnPlayerTeamIDChanged:Add(self.PlayerTeamIDChanged, self)
|
|||
|
if self:HasAuthority() then
|
|||
|
-- 更新出生点位置
|
|||
|
self:UpdatePlayerStartType()
|
|||
|
self.PlayerControllerRespawnedDelegate:AddInstance(self.ServerRespawnPlayer, self)
|
|||
|
else
|
|||
|
TipConfig.Init(self)
|
|||
|
WidgetManager:Init(WidgetConfig.PlayModeUI)
|
|||
|
self:ShowDefaultUI()
|
|||
|
UGCEventSystem.AddListener(EventEnum.GameStateChange, self.GameStateChange, self)
|
|||
|
UGCEventSystem.AddListener(EventEnum.PlayerDeathInfo, self.CameraMoveToKiller, self)
|
|||
|
UGCEventSystem.AddListener(ArchiveDataConfig.GetParamNotifyEvent(ArchiveDataConfig.EArchiveType.NumberOfPlays), self.ShowGuide, self)
|
|||
|
self:ShowGuide()
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_ReceiveBeginPlay] Finish")
|
|||
|
self.PlayerControllerRespawnedDelegate:AddInstance(self.ShowRespawnWidget, self)
|
|||
|
|
|||
|
-- 更新加入队伍聊天房间
|
|||
|
--UGCEventSystem.AddListener(EventEnum.Player, self.CameraMoveToKiller, self)
|
|||
|
self:UpdateTeamVoiceRoom()
|
|||
|
|
|||
|
-- self:ShowNowGameStateTypeUI()
|
|||
|
|
|||
|
end
|
|||
|
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_ReceiveBeginPlay] PC Name:%s", tostring(KismetSystemLibrary.GetObjectName(self)))
|
|||
|
|
|||
|
|
|||
|
end
|
|||
|
|
|||
|
function UGCPlayerController:ServerRespawnPlayer()
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_ServerRespawnPlayer]")
|
|||
|
|
|||
|
-- 更新背包
|
|||
|
--if self.AddMagnifyingGlassHandle then
|
|||
|
-- UGCEventSystem.StopTimer(self.AddMagnifyingGlassHandle)
|
|||
|
--end
|
|||
|
-- self.AddMagnifyingGlassHandle = UGCEventSystem.SetTimer(self, self.AddMagnifyingGlass, 3)
|
|||
|
-- self:UpdatePlayerBackPack()
|
|||
|
-- self:UpdatePlayerBackPack_V2()
|
|||
|
-- 更新增益到Pawn
|
|||
|
self.bCanAddBuff = false
|
|||
|
if self.UpdateAlreadyOwnedBuffsHandle then UGCEventSystem.StopTimer(self.UpdateAlreadyOwnedBuffsHandle) end
|
|||
|
self.UpdateAlreadyOwnedBuffsHandle = UGCEventSystem.SetTimer(self, function()
|
|||
|
self.UpdateAlreadyOwnedBuffsHandle = nil
|
|||
|
self:UpdateAlreadyOwnedBuffs()
|
|||
|
end, 2.)
|
|||
|
|
|||
|
end
|
|||
|
|
|||
|
function UGCPlayerController:AddMagnifyingGlass()
|
|||
|
self.AddMagnifyingGlassHandle = nil
|
|||
|
if UE.IsValid(self.Pawn) then
|
|||
|
for i, ItemInfo in pairs(WeaponSelectionCombinationConfig.MagnifyingGlass) do
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_AddMagnifyingGlass] ItemID:%s, ItemCount:%s", tostring(ItemInfo.ItemID), tostring(ItemInfo.Count))
|
|||
|
UGCBackPackSystem.AddItem(self.Pawn, ItemInfo.ItemID, ItemInfo.Count)
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function UGCPlayerController:UpdatePlayerBackPack()
|
|||
|
|
|||
|
self.DefaultBackPack = TableHelper.DeepCopy(UGCGameSystem.GameState:GetPlayerBeBornParts(self.PlayerKey))
|
|||
|
-- 默认装备
|
|||
|
UGCGameSystem.GameState:PlayerAddItemInfo(self.PlayerKey, self.DefaultBackPack)
|
|||
|
-- 默认武器
|
|||
|
UGCGameSystem.GameState:UpdatePlayerWeapon(self.PlayerKey)
|
|||
|
|
|||
|
UGCLogSystem.LogTree("[UGCPlayerController_UpdatePlayerBackPack] DefaultBackPack:", self.DefaultBackPack)
|
|||
|
|
|||
|
UGCEventSystem.SetTimer(self, function()
|
|||
|
local TargetPawn = UGCGameSystem.GetPlayerPawnByPlayerKey(self.PlayerKey)
|
|||
|
if UE.IsValid(TargetPawn) then
|
|||
|
TargetPawn:SetAllWeaponBulletNumToMaxOnServer(true, false)
|
|||
|
for i, v in pairs(ShootWeaponEnums) do
|
|||
|
local Weapon = UGCWeaponManagerSystem.GetWeaponBySlot(TargetPawn, v)
|
|||
|
if UE.IsValid(Weapon) then
|
|||
|
UGCGunSystem.EnableClipInfiniteBullets(Weapon, true)
|
|||
|
local MaxBulletNumInOneClip = UGCGunSystem.GetMaxBulletNumInOneClip(Weapon)
|
|||
|
Weapon:SetCurrentBulletNumInClipOnServer(MaxBulletNumInOneClip, true)
|
|||
|
-- 玩家离开换弹状态
|
|||
|
UGCPawnSystem.LeavePawnState(TargetPawn, EPawnState.Roload)
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
end, 3)
|
|||
|
end
|
|||
|
|
|||
|
function UGCPlayerController:UpdatePlayerBackPack_V2()
|
|||
|
|
|||
|
|
|||
|
-- 默认武器
|
|||
|
if self.BackPackHandle2 then UGCEventSystem.StopTimer(self.BackPackHandle2) end
|
|||
|
self.BackPackHandle2 = UGCEventSystem.SetTimer(self, function()
|
|||
|
self.BackPackHandle2 = nil
|
|||
|
UGCGameSystem.GameState:UpdatePlayerWeapon(self.PlayerKey)
|
|||
|
end, 1.)
|
|||
|
|
|||
|
-- 默认装备
|
|||
|
if self.BackPackHandle1 then UGCEventSystem.StopTimer(self.BackPackHandle1) end
|
|||
|
self.BackPackHandle1 = UGCEventSystem.SetTimer(self, function()
|
|||
|
self.BackPackHandle1 = nil
|
|||
|
self.DefaultBackPack = TableHelper.DeepCopy(UGCGameSystem.GameState:GetPlayerBeBornParts(self.PlayerKey))
|
|||
|
UGCGameSystem.GameState:PlayerAddItemInfo(self.PlayerKey, self.DefaultBackPack)
|
|||
|
end, 2.)
|
|||
|
|
|||
|
-- 校验玩家的武器和配件1次
|
|||
|
if self.BackPackHandle3 then UGCEventSystem.StopTimer(self.BackPackHandle3) end
|
|||
|
self.BackPackHandle3 = UGCEventSystem.SetTimer(self, function()
|
|||
|
self.BackPackHandle3 = nil
|
|||
|
UGCGameSystem.GameState:CheckWeaponAndParts(self.PlayerKey)
|
|||
|
end, 6.)
|
|||
|
-- 校验玩家的武器和配件2次
|
|||
|
if self.BackPackHandle4 then UGCEventSystem.StopTimer(self.BackPackHandle4) end
|
|||
|
self.BackPackHandle4 = UGCEventSystem.SetTimer(self, function()
|
|||
|
self.BackPackHandle4 = nil
|
|||
|
UGCGameSystem.GameState:CheckWeaponAndParts(self.PlayerKey)
|
|||
|
end, 8.)
|
|||
|
|
|||
|
-- 补满武器弹夹
|
|||
|
UGCEventSystem.SetTimer(self, function()
|
|||
|
UGCSystemLibrary.PlayerFullBullet(self.PlayerKey)
|
|||
|
end, 3.)
|
|||
|
|
|||
|
end
|
|||
|
|
|||
|
function UGCPlayerController:PlayerTeamIDChanged(Controller)
|
|||
|
local TeamID = UGCPlayerControllerSystem.GetTeamID(Controller)
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_PlayerTeamIDChanged] TeamID:%s", tostring(TeamID))
|
|||
|
UGCEventSystem.SendEvent(EventEnum.PlayerTeamChange, Controller, TeamID)
|
|||
|
end
|
|||
|
|
|||
|
function UGCPlayerController:UpdatePlayerStartType()
|
|||
|
if self.UpdatePlayerStartCount == nil then
|
|||
|
self.UpdatePlayerStartCount = 1
|
|||
|
else
|
|||
|
self.UpdatePlayerStartCount = 1 + self.UpdatePlayerStartCount
|
|||
|
end
|
|||
|
local TeamID = UGCPlayerControllerSystem.GetTeamID(self)
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_UpdatePlayerStartType] TeamID:%s, UpdatePlayerStartCount:%s", tostring(TeamID), tostring(self.UpdatePlayerStartCount))
|
|||
|
if TeamID > 0 then
|
|||
|
if TeamID == 1 then
|
|||
|
self:SetStartPointType(EPlayerStartType.Team1)
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_UpdatePlayerStartType] 1")
|
|||
|
else
|
|||
|
self:SetStartPointType(EPlayerStartType.Team2)
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_UpdatePlayerStartType] 2")
|
|||
|
end
|
|||
|
-- UGCSystemLibrary.RespawnPlayer(self.PlayerKey)
|
|||
|
-- 重置位置
|
|||
|
UGCEventSystem.SendEvent(EventEnum.ResetPlayerTransformToPlayerStart, self, UGCGameSystem.GetPlayerPawnByPlayerKey(self.PlayerKey))
|
|||
|
|
|||
|
else
|
|||
|
self:SetStartPointType(EPlayerStartType.Team1)
|
|||
|
UGCEventSystem.SetTimer(self, self.UpdatePlayerStartType, 0.1)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
-- 判断显示拍脸图
|
|||
|
function UGCPlayerController:ShowGuide()
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_ShowGuide] PlayerKey:%s", tostring(self.PlayerKey))
|
|||
|
local PlayNumber = ArchiveDataConfig.GetPlayerArchiveDataFromType(self.PlayerKey, ArchiveDataConfig.EArchiveType.NumberOfPlays)
|
|||
|
if PlayNumber and PlayNumber <= 1 and self.ShowOnce == nil then
|
|||
|
self.ShowOnce = true
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_ShowGuide] PlayNumber:%s", tostring(PlayNumber))
|
|||
|
WidgetManager:ShowPanel(WidgetConfig.EUIType.Guide, false)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function UGCPlayerController:ShowRespawnWidget()
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_ShowRespawnWidget]")
|
|||
|
-- 客户端显示重选武器按键
|
|||
|
WidgetManager:ShowPanel(WidgetConfig.EUIType.ReselectWeaponBtn, false)
|
|||
|
-- 海岛工程会重生小地图会显示错误 这里刷新一下
|
|||
|
UGCGameSystem.GameState:LoadNowMiniMap()
|
|||
|
end
|
|||
|
|
|||
|
-- 显示默认UI
|
|||
|
function UGCPlayerController:ShowDefaultUI()
|
|||
|
for i, UIType in pairs(WidgetConfig.DefaultShowWidget) do
|
|||
|
WidgetManager:ShowPanel(UIType, false)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
-- 游戏模式改变
|
|||
|
function UGCPlayerController:GameStateChange(NewGameStateType)
|
|||
|
if NewGameStateType == CustomEnum.EGameState.End or NewGameStateType == CustomEnum.EGameState.InsufficientNumberOfPeople then
|
|||
|
-- 移除不可显示UI
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_GameStateChange]")
|
|||
|
WidgetManager:DestroyPanel(WidgetConfig.EUIType.InvincibleTime)
|
|||
|
WidgetManager:DestroyPanel(WidgetConfig.EUIType.WaitingTime)
|
|||
|
end
|
|||
|
-- self:ShowNowGameStateTypeUI()
|
|||
|
end
|
|||
|
|
|||
|
function UGCPlayerController:Client_PlayerIsFirstTimePlaying()
|
|||
|
if self:HasAuthority() then return end
|
|||
|
UGCLogSystem.Log("[UGCGameState_Client_PlayerIsFirstTimePlaying]")
|
|||
|
if WidgetManager.Initialized == false then
|
|||
|
self.NeedExePlayerIsFirstTimePlaying = true
|
|||
|
else
|
|||
|
self:PlayerIsFirstTimePlaying()
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
|
|||
|
--- 根据是否为第一次进入该游戏进行判断
|
|||
|
function UGCPlayerController:AutoShowGuide()
|
|||
|
if self.bAutoShowGuide then
|
|||
|
WidgetManager:ShowPanel(WidgetConfig.EUIType.Guide, false)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function UGCPlayerController:CameraMoveToKiller(VictimKey, CauserKey)
|
|||
|
if GlobalConfigs.GameSetting.EnableLerpCamera and VictimKey == self.PlayerKey then
|
|||
|
local TrackCamera = UGCSystemLibrary.GetUniqueInstanceFromPath(UGCGameSystem.GetUGCResourcesFullPath('Asset/Blueprint/SceneActor/BP_TrackKillerCamera.BP_TrackKillerCamera_C'))
|
|||
|
if UE.IsValid(TrackCamera) then
|
|||
|
self:SetViewTargetWithBlend(TrackCamera, 0.,EViewTargetBlendFunction.VTBlend_Linear, 0., false);
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_CameraMoveToKiller] Succeed")
|
|||
|
else
|
|||
|
UGCLogSystem.LogError("[UGCPlayerController_CameraMoveToKiller] TrackCamera is nil")
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
|
|||
|
|
|||
|
--- 设置玩家的出生点类型
|
|||
|
function UGCPlayerController:SetStartPointType(InStartPointType)
|
|||
|
self.StartPointType = InStartPointType
|
|||
|
end
|
|||
|
|
|||
|
--- 获取玩家的出生点类型
|
|||
|
function UGCPlayerController:GetStartPointType()
|
|||
|
if self.StartPointType == nil then
|
|||
|
self.StartPointType = EPlayerStartType.Default
|
|||
|
end
|
|||
|
return self.StartPointType
|
|||
|
end
|
|||
|
|
|||
|
--- 商城注册
|
|||
|
function UGCPlayerController:Server_OnUGCCommodityPlayerDataReady()
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_Server_OnUGCCommodityPlayerDataReady]")
|
|||
|
--注册了名为PlacementModeConfig.PlacingAttr.GoldBrickName的协议,用于购买9000001号商品(商品表已配置该商品),单次购买数量为1
|
|||
|
--UGCCommoditySystem.RegBuyCMD(PlacementModeConfig.PlacingAttr.GoldBrickName, 9000000, 100)
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_Server_OnUGCCommodityPlayerDataReady] Finish")
|
|||
|
end
|
|||
|
|
|||
|
--- 更新加入队伍聊天房间
|
|||
|
function UGCPlayerController:UpdateTeamVoiceRoom()
|
|||
|
local TeamID = UGCGameSystem.GameState:GetPlayerTeamIDByPlayerKey(self.PlayerKey)
|
|||
|
if TeamID then
|
|||
|
local RoomName = "TeamVoiceRoom"..tostring(TeamID)
|
|||
|
UGCVoiceManagerSystem.JoinVoiceRoom(RoomName)
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_UpdateTeamVoiceRoom] JoinTeamRoom:%s", tostring(TeamID))
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
|
|||
|
|
|||
|
-- 临时存储玩家的增幅 和 战神进度-------------------------------------------------
|
|||
|
function UGCPlayerController:SetOwnedIncrease(InOwnedIncrease)
|
|||
|
self.OwnedIncrease = InOwnedIncrease
|
|||
|
end
|
|||
|
|
|||
|
function UGCPlayerController:GetOwnedIncrease()
|
|||
|
if self.OwnedIncrease then
|
|||
|
return self.OwnedIncrease
|
|||
|
else
|
|||
|
return {}
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
-- -----------------------------------------------------------------------------
|
|||
|
|
|||
|
UGCPlayerController.bCanAddBuff = false
|
|||
|
function UGCPlayerController:UpdateAlreadyOwnedBuffs()
|
|||
|
local TargetPawn = UGCGameSystem.GetPlayerPawnByPlayerKey(self.PlayerKey)
|
|||
|
if UE.IsValid(TargetPawn) then
|
|||
|
for IncreaseType, Level in pairs(self.OwnedIncrease) do
|
|||
|
BuffSystemAPI.PlayerAddBuff(TargetPawn, GodOfWarConfig.BuffList[IncreaseType][Level])
|
|||
|
end
|
|||
|
end
|
|||
|
self.bCanAddBuff = true
|
|||
|
end
|
|||
|
|
|||
|
--- 获取可获得增量次数的数值
|
|||
|
function UGCPlayerController:GetCanObtainIncreaseCount()
|
|||
|
if self.CanObtainIncreaseCount then
|
|||
|
return self.CanObtainIncreaseCount
|
|||
|
else
|
|||
|
return 0
|
|||
|
end
|
|||
|
end
|
|||
|
--- 设置可获得增量次数的数值
|
|||
|
function UGCPlayerController:SetCanObtainIncreaseCount(InCanObtainIncreaseCount)
|
|||
|
self.CanObtainIncreaseCount = InCanObtainIncreaseCount
|
|||
|
end
|
|||
|
--- 获取当前可选择增量类型的列表
|
|||
|
function UGCPlayerController:GetNowCanSelectIncrease()
|
|||
|
if self.NowCanSelectIncrease then
|
|||
|
return self.NowCanSelectIncrease
|
|||
|
else
|
|||
|
return {}
|
|||
|
end
|
|||
|
end
|
|||
|
--- 设置当前可选择增量类型的列表
|
|||
|
function UGCPlayerController:SetNowCanSelectIncrease(InNowCanSelectIncrease)
|
|||
|
self.NowCanSelectIncrease = InNowCanSelectIncrease
|
|||
|
end
|
|||
|
|
|||
|
--- 增加可选增益层数
|
|||
|
function UGCPlayerController:AddCanObtainIncreaseCount()
|
|||
|
-- 判断增益是否满了
|
|||
|
if self.IncreaseIsFull then return end
|
|||
|
if self.CanObtainIncreaseCount > 0 then
|
|||
|
self.CanObtainIncreaseCount = self.CanObtainIncreaseCount + 1
|
|||
|
else
|
|||
|
self.CanObtainIncreaseCount = 1
|
|||
|
self:UpdateNowCanSelectIncrease()
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
|
|||
|
--- 玩家选择增益
|
|||
|
function UGCPlayerController:PlayerSelectIncrease(SelectIndex)
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_PlayerSelectIncrease] PlayerKey:%s, SelectIndex:%s", tostring(self.PlayerKey), tostring(SelectIndex))
|
|||
|
if self.CanObtainIncreaseCount > 0 and SelectIndex > 0 and SelectIndex <= GodOfWarConfig.CanSelectIncreaseCount then
|
|||
|
-- 给予玩家增幅
|
|||
|
if self:PlayerAddIncrease(self.NowCanSelectIncrease[SelectIndex]) then
|
|||
|
self.CanObtainIncreaseCount = self.CanObtainIncreaseCount - 1
|
|||
|
if self.CanObtainIncreaseCount > 0 then
|
|||
|
self:UpdateNowCanSelectIncrease()
|
|||
|
else
|
|||
|
self.NowCanSelectIncrease = {}
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
|
|||
|
|
|||
|
--- 玩家获得增益
|
|||
|
function UGCPlayerController:PlayerAddIncrease(InIncreaseType)
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_PlayerAddIncrease] PlayerKey:%s, InIncreaseType:%s", tostring(self.PlayerKey), tostring(InIncreaseType))
|
|||
|
if self.OwnedIncrease[InIncreaseType] == nil then
|
|||
|
self.OwnedIncrease[InIncreaseType] = 0
|
|||
|
end
|
|||
|
if #GodOfWarConfig.BuffList[InIncreaseType] > self.OwnedIncrease[InIncreaseType] then
|
|||
|
self.OwnedIncrease[InIncreaseType] = self.OwnedIncrease[InIncreaseType] + 1
|
|||
|
local TargetPawn = UGCGameSystem.GetPlayerPawnByPlayerKey(self.PlayerKey)
|
|||
|
if UE.IsValid(TargetPawn) then
|
|||
|
if self.OwnedIncrease[InIncreaseType] > 1 then
|
|||
|
-- 移除上一级增幅
|
|||
|
BuffSystemAPI.PlayerRemoveBuffFromBuffAssetType(TargetPawn, GodOfWarConfig.BuffList[InIncreaseType][self.OwnedIncrease[InIncreaseType] - 1], 1)
|
|||
|
end
|
|||
|
if self.bCanAddBuff then
|
|||
|
local UseBuffRes = BuffSystemAPI.PlayerAddBuff(TargetPawn, GodOfWarConfig.BuffList[InIncreaseType][self.OwnedIncrease[InIncreaseType]])
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_PlayerAddIncrease] UseBuffRes:%s", tostring(UseBuffRes))
|
|||
|
end
|
|||
|
-- 播放特效
|
|||
|
ParticleConfig.ClientAddParticleAttachPlayer(self.PlayerKey, TargetPawn, ParticleConfig.EParticleType.AddBuff)
|
|||
|
end
|
|||
|
return true
|
|||
|
end
|
|||
|
return false
|
|||
|
end
|
|||
|
|
|||
|
--- 更新当前可选增益
|
|||
|
function UGCPlayerController:UpdateNowCanSelectIncrease()
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_UpdateNowCanSelectIncrease]")
|
|||
|
local PlayerCanAddIncrease = {}
|
|||
|
for i, IncreaseType in pairs(GodOfWarConfig.EIncreaseType) do
|
|||
|
if self.OwnedIncrease[IncreaseType] == nil or #GodOfWarConfig.BuffList[IncreaseType] > self.OwnedIncrease[IncreaseType] then
|
|||
|
PlayerCanAddIncrease[#PlayerCanAddIncrease + 1] = IncreaseType
|
|||
|
end
|
|||
|
end
|
|||
|
if #PlayerCanAddIncrease > 0 then
|
|||
|
table.Shuffle(PlayerCanAddIncrease)
|
|||
|
if self.BaseIncreaseType and table.hasValue(PlayerCanAddIncrease, self.BaseIncreaseType) then
|
|||
|
table.Swap(PlayerCanAddIncrease, table.getIndex(PlayerCanAddIncrease, self.BaseIncreaseType), 1)
|
|||
|
end
|
|||
|
|
|||
|
UGCLogSystem.LogTree("[UGCPlayerController_UpdateNowCanSelectIncrease] PlayerCanAddIncrease:", PlayerCanAddIncrease)
|
|||
|
for i = 0, GodOfWarConfig.CanSelectIncreaseCount - 1 do
|
|||
|
self.NowCanSelectIncrease[i + 1] = PlayerCanAddIncrease[(i % #PlayerCanAddIncrease) + 1]
|
|||
|
end
|
|||
|
UGCLogSystem.LogTree("[UGCPlayerController_UpdateNowCanSelectIncrease] NowCanSelectIncrease:", self.NowCanSelectIncrease)
|
|||
|
else
|
|||
|
-- 已满
|
|||
|
self.NowCanSelectIncrease = {}
|
|||
|
self.CanObtainIncreaseCount = 0
|
|||
|
self.IncreaseIsFull = true
|
|||
|
end
|
|||
|
-- Test Buff
|
|||
|
--local TestBuffType = GodOfWarConfig.EIncreaseType.Sensing
|
|||
|
--if self.OwnedIncrease[TestBuffType] == nil or #GodOfWarConfig.BuffList[TestBuffType] > self.OwnedIncrease[TestBuffType] then
|
|||
|
-- self.NowCanSelectIncrease[1] = TestBuffType
|
|||
|
--end
|
|||
|
end
|
|||
|
|
|||
|
function UGCPlayerController:SetBaseIncrease(IncreaseType)
|
|||
|
if table.hasValue(GodOfWarConfig.EIncreaseType, IncreaseType) then
|
|||
|
self.BaseIncreaseType = IncreaseType
|
|||
|
self:UpdateNowCanSelectIncrease()
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--- 获取玩家拥有增效的等级
|
|||
|
function UGCPlayerController:GetOwnedIncreaseLevel(InIncreaseType)
|
|||
|
return self.OwnedIncrease[InIncreaseType] and self.OwnedIncrease[InIncreaseType] or 0
|
|||
|
end
|
|||
|
|
|||
|
function UGCPlayerController:GetAllOwnedIncreaseLevel()
|
|||
|
return self.OwnedIncrease
|
|||
|
end
|
|||
|
|
|||
|
-- 临时存储玩家的增幅 End ---------------------------------------------
|
|||
|
|
|||
|
function UGCPlayerController:GetAvailableServerRPCs()
|
|||
|
return
|
|||
|
"Client_PlayerIsFirstTimePlaying"
|
|||
|
end
|
|||
|
|
|||
|
return UGCPlayerController;
|