218 lines
8.2 KiB
Lua
218 lines
8.2 KiB
Lua
---@class UGCPlayerController_C:BP_UGCPlayerController_C
|
|
--Edit Below--
|
|
---@type UGCPlayerController_C
|
|
local UGCPlayerController = {
|
|
NeedExePlayerIsFirstTimePlaying = false;
|
|
bAutoShowGuide = false;
|
|
IsEnableSceneCamera = false;
|
|
};
|
|
|
|
function UGCPlayerController:GetReplicatedProperties()
|
|
return
|
|
"IsEnableSceneCamera"
|
|
end
|
|
|
|
|
|
function UGCPlayerController:ReceiveBeginPlay()
|
|
self.SuperClass.ReceiveBeginPlay(self);
|
|
require("Script.Global.WidgetManager.WidgetManager")
|
|
|
|
-- 不要自动切换相机
|
|
self.bAutoManageActiveCameraTarget = false
|
|
|
|
if self:HasAuthority() then
|
|
UGCEventSystem.AddListener(EventEnum.PlayerDeathInfo, self.PlayerDead, self)
|
|
else
|
|
TipConfig.Init(self)
|
|
WidgetManager:Init()
|
|
self:ShowNowGameStateTypeUI()
|
|
self:ShowDefaultUI()
|
|
UGCEventSystem.AddListener(EventEnum.GameStateChange, self.GameStateChange, self)
|
|
UGCEventSystem.AddListener(EventEnum.PlayerDeathInfo, self.PlayerDead, self)
|
|
UGCEventSystem.AddListener(EventEnum.SetSceneCameraControl, self.SetSceneCameraControl, self)
|
|
end
|
|
|
|
end
|
|
|
|
function UGCPlayerController:ShowNowGameStateTypeUI()
|
|
if self:HasAuthority() then return end
|
|
if UGCGameSystem.GameState.GameStateType == CustomEnum.EGameState.Waiting then
|
|
WidgetManager:ShowPanel(WidgetConfig.EUIType.WaitingTime, false)
|
|
elseif UGCGameSystem.GameState.GameStateType == CustomEnum.EGameState.Playing then
|
|
UGCLogSystem.Log("[UGCPlayerController_ShowNowGameStateTypeUI] CloseWaitWidget")
|
|
WidgetManager:ClosePanel(WidgetConfig.EUIType.WaitingTime)
|
|
WidgetManager:ShowPanel(WidgetConfig.EUIType.DefaultMiniGame, false)
|
|
UGCEventSystem.SetTimer(self, self.AutoShowGuide, GlobalConfigs.GameSetting.ClientLoadMapTime)
|
|
--WidgetManager:ShowPanel(WidgetConfig.EUIType.TeamScore)
|
|
elseif UGCGameSystem.GameState.GameStateType == CustomEnum.EGameState.End then
|
|
WidgetManager:ShowPanel(WidgetConfig.EUIType.Settlement)
|
|
elseif UGCGameSystem.GameState.GameStateType == CustomEnum.EGameState.InsufficientNumberOfPeople then
|
|
WidgetManager:ShowPanel(WidgetConfig.EUIType.InsufficientNumberOfPeople)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
-- 显示默认UI
|
|
function UGCPlayerController:ShowDefaultUI()
|
|
if self:HasAuthority() then return end
|
|
--WidgetManager:ShowPanel(WidgetConfig.EUIType.DamageAnim, false)
|
|
--WidgetManager:ShowPanel(WidgetConfig.EUIType.KillInfo, false)
|
|
--WidgetManager:ShowPanel(WidgetConfig.EUIType.BroadcastMid, false)
|
|
-- WidgetManager:ShowPanel(WidgetConfig.EUIType.Key, false)
|
|
|
|
|
|
-- WidgetManager:ShowPanel(WidgetConfig.EUIType.Shop, false)
|
|
-- WidgetManager:ShowPanel(WidgetConfig.EUIType.FightPanel, false)
|
|
UGCLogSystem.Log("[UGCPlayerController_ShowDefaultUI] Finish")
|
|
|
|
end
|
|
|
|
-- 游戏模式改变
|
|
function UGCPlayerController:GameStateChange(NerwGameStateType)
|
|
if NerwGameStateType == CustomEnum.EGameState.End or NerwGameStateType == 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:AutoShowGuide()
|
|
if self.bAutoShowGuide then
|
|
-- WidgetManager:ShowPanel(WidgetConfig.EUIType.Guide, false)
|
|
end
|
|
end
|
|
|
|
function UGCPlayerController:PlayerDead(VictimKey, CauserKey)
|
|
--if VictimKey == self.PlayerKey then
|
|
-- if UGCGameSystem.IsServer() then
|
|
-- -- 观战
|
|
-- if GlobalConfigs.GameSetting.bEnableSpectateOther then
|
|
-- self:SpectateOther()
|
|
-- end
|
|
-- else
|
|
-- -- 摄像机过渡
|
|
-- if GlobalConfigs.GameSetting.bEnableCameraMoveToKiller then
|
|
-- self:CameraMoveToKiller(VictimKey, CauserKey)
|
|
-- end
|
|
-- end
|
|
--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, 1.,EViewTargetBlendFunction.VTBlend_Linear, 0., false);
|
|
UGCLogSystem.Log("[UGCPlayerController_CameraMoveToKiller] Succeed")
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
|
|
--- 观战
|
|
function UGCPlayerController:SpectateOther()
|
|
if UGCGameSystem.IsServer() then
|
|
UGCGameSystem.MyObserversChangeTarget(self)
|
|
|
|
-- 默认观看队友
|
|
UGCGameSystem.EnterSpectating(self);
|
|
UGCSendRPCSystem.ActorRPCNotify(self.PlayerKey, self, "SpectateOther")
|
|
else
|
|
self:CastUIMsg("UIMsg_HideQuitWatch", "");
|
|
end
|
|
end
|
|
|
|
-- 服务器设置为场景摄像机
|
|
function UGCPlayerController:Server_SetSceneCamera(InIsEnableSceneCamera)
|
|
self.IsEnableSceneCamera = InIsEnableSceneCamera
|
|
end
|
|
|
|
function UGCPlayerController:OnRep_IsEnableSceneCamera()
|
|
if self.IsEnableSceneCamera then
|
|
self:BlendToGodCamera()
|
|
else
|
|
if UE.IsValid(self.Pawn) then
|
|
self:SetViewTargetWithBlend(self.Pawn, 0.,EViewTargetBlendFunction.VTBlend_Linear, 0., false);
|
|
end
|
|
end
|
|
end
|
|
|
|
--- 摄像机混合到上帝视角摄像机
|
|
function UGCPlayerController:BlendToGodCamera()
|
|
if not UGCGameSystem.IsServer() then
|
|
local GodCamera = UGCSystemLibrary.GetUniqueInstanceFromPath(UGCGameSystem.GetUGCResourcesFullPath('Asset/Blueprint/SceneActor/BP_GodCamera.BP_GodCamera_C'))
|
|
if UE.IsValid(GodCamera) then
|
|
self:SetViewTargetWithBlend(GodCamera, 0.,EViewTargetBlendFunction.VTBlend_Linear, 0., false);
|
|
UGCLogSystem.Log("[UGCPlayerController_BlendToGodCamera] Succeed")
|
|
end
|
|
end
|
|
end
|
|
|
|
function UGCPlayerController:SetSceneCameraControl(bIsSet)
|
|
if bIsSet then
|
|
self:SetGodCameraControlPlayer()
|
|
else
|
|
self:EnableCameraSetMove(false)
|
|
end
|
|
end
|
|
|
|
function UGCPlayerController:SetGodCameraControlPlayer()
|
|
if not UGCGameSystem.IsServer() and UE.IsValid(self.Pawn) then
|
|
local GodCamera = UGCSystemLibrary.GetUniqueInstanceFromPath(UGCGameSystem.GetUGCResourcesFullPath('Asset/Blueprint/SceneActor/BP_GodCamera.BP_GodCamera_C'))
|
|
self:SetCameraControlPlayer(GodCamera)
|
|
end
|
|
end
|
|
|
|
function UGCPlayerController:SetCameraControlPlayer(CameraActor)
|
|
if UE.IsValid(CameraActor) then
|
|
self.TargetCamera = CameraActor
|
|
self:SetViewTargetWithBlend(CameraActor, 0.,EViewTargetBlendFunction.VTBlend_Linear, 0., false);
|
|
self:EnableCameraSetMove(true)
|
|
end
|
|
end
|
|
|
|
function UGCPlayerController:EnableCameraSetMove(bInEnable)
|
|
if self.bEnableCameraControlMove ~= bInEnable then
|
|
self.bEnableCameraControlMove = bInEnable
|
|
if self.bEnableCameraControlMove then
|
|
UGCGameSystem.SetMoveInputEventEnable(self, true, true)
|
|
UGCGameSystem.SetLookInputEventEnable(self, false, true);
|
|
self:SetControllerTouchEnabled(false);
|
|
else
|
|
UGCGameSystem.SetMoveInputEventEnable(self, true, false)
|
|
UGCGameSystem.SetLookInputEventEnable(self, true, false);
|
|
self:SetControllerTouchEnabled(true);
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
function UGCPlayerController:UGCMoveEvent(InVector2D)
|
|
if UE.IsValid(self.Pawn) and UE.IsValid(self.TargetCamera) then
|
|
local TargetForward = VectorHelper.MulNumber(self.TargetCamera:GetActorForwardVector(), InVector2D.Y)
|
|
local TargetRight = VectorHelper.MulNumber(self.TargetCamera:GetActorRightVector(), InVector2D.X)
|
|
local TargetMove = VectorHelper.Add(TargetForward, TargetRight)
|
|
TargetMove.Z = 0.
|
|
UGCLogSystem.Log("[UGCPlayerController:UGCMoveEvent]X = %s, Y= %s, TargetMove:%s", tostring(InVector2D.X), tostring(InVector2D.Y), VectorHelper.ToString(TargetMove))
|
|
self:K2_SetActorRotation(KismetMathLibrary.MakeRotFromX(TargetMove))
|
|
self.Pawn:AddMovementInput(TargetMove, 1)
|
|
end
|
|
end
|
|
|
|
function UGCPlayerController:UGCLookEvent(Rot)
|
|
end
|
|
|
|
function UGCPlayerController:GetAvailableServerRPCs()
|
|
return
|
|
end
|
|
|
|
|
|
return UGCPlayerController; |