136 lines
5.2 KiB
Lua
136 lines
5.2 KiB
Lua
|
---@class UGCPlayerController_C:BP_UGCPlayerController_C
|
|||
|
--Edit Below--
|
|||
|
---@type UGCPlayerController_C
|
|||
|
local UGCPlayerController = {
|
|||
|
NeedExePlayerIsFirstTimePlaying = false;
|
|||
|
bAutoShowGuide = false;
|
|||
|
};
|
|||
|
|
|||
|
|
|||
|
--function UGCPlayerController:GetReplicatedProperties()
|
|||
|
-- return
|
|||
|
--end
|
|||
|
|
|||
|
function UGCPlayerController:ReceiveBeginPlay()
|
|||
|
self.SuperClass.ReceiveBeginPlay(self);
|
|||
|
require("Script.Global.WidgetManager.WidgetManager")
|
|||
|
require("Script.Blueprint.PlaceItems.PlacementModeConfig")
|
|||
|
|
|||
|
-- 不要自动切换相机
|
|||
|
self.bAutoManageActiveCameraTarget = false
|
|||
|
|
|||
|
if self:HasAuthority() then
|
|||
|
if PlacementModeConfig.IsPlaceMode() then
|
|||
|
self:SetStartPointType(EPlayerStartType.Defender)
|
|||
|
end
|
|||
|
else
|
|||
|
TipConfig.Init(self)
|
|||
|
if PlacementModeConfig.IsPlaceMode() then
|
|||
|
WidgetManager:Init(WidgetConfig.PlaceModeUI)
|
|||
|
else
|
|||
|
WidgetManager:Init(WidgetConfig.PlayModeUI)
|
|||
|
end
|
|||
|
-- self:ShowNowGameStateTypeUI()
|
|||
|
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()
|
|||
|
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 then
|
|||
|
WidgetManager:ShowPanel(WidgetConfig.EUIType.Guide, false)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
-- 显示默认UI
|
|||
|
function UGCPlayerController:ShowDefaultUI()
|
|||
|
WidgetManager:ShowPanel(WidgetConfig.EUIType.DamageAnim, false)
|
|||
|
if PlacementModeConfig.IsPlaceMode() then
|
|||
|
WidgetManager:ShowPanel(WidgetConfig.EUIType.Currency, 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
|
|||
|
-- WidgetManager:ShowPanel(WidgetConfig.EUIType.SceneItemGuide, false);
|
|||
|
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'))
|
|||
|
--local KillerPawn = UGCGameSystem.GetPlayerPawnByPlayerKey(CauserKey)
|
|||
|
--if UE.IsValid(KillerPawn) then
|
|||
|
-- --KillerPawn.Camera:Activate();
|
|||
|
-- --KillerPawn.CustomSpringArm:Activate();
|
|||
|
-- self:SetViewTargetWithBlend(KillerPawn, 1.,EViewTargetBlendFunction.VTBlend_Linear, 0., false);
|
|||
|
--end
|
|||
|
if UE.IsValid(TrackCamera) then
|
|||
|
self:SetViewTargetWithBlend(TrackCamera, 1.,EViewTargetBlendFunction.VTBlend_Linear, 0., false);
|
|||
|
UGCLogSystem.Log("[UGCPlayerController_CameraMoveToKiller] Succeed")
|
|||
|
else
|
|||
|
UGCLogSystem.LogError("[UGCPlayerController_CameraMoveToKiller] TrackCamera is nil")
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function UGCPlayerController:GetReplicatedProperties()
|
|||
|
return
|
|||
|
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:GetAvailableServerRPCs()
|
|||
|
return
|
|||
|
"Client_PlayerIsFirstTimePlaying"
|
|||
|
end
|
|||
|
|
|||
|
return UGCPlayerController;
|