191 lines
7.5 KiB
Lua
191 lines
7.5 KiB
Lua
---@class UGCPlayerController_C:BP_UGCPlayerController_C
|
|
--Edit Below--
|
|
---@type UGCPlayerController_C
|
|
local UGCPlayerController = {
|
|
NeedExePlayerIsFirstTimePlaying = false;
|
|
bAutoShowGuide = false;
|
|
IsSpectateOther = false;
|
|
bPlayerIsDead = false;
|
|
};
|
|
|
|
|
|
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()
|
|
UnrealNetwork.CallUnrealRPC(self, UGCGameSystem.GameState, "Server_ControllerInitFinish", self.PlayerKey)
|
|
UGCEventSystem.AddListener(EventEnum.GameStateChange, self.GameStateChange, self)
|
|
UGCEventSystem.AddListener(EventEnum.PlayerDeathInfo, self.PlayerDead, self)
|
|
if GlobalConfigs.GameModeSetting.TeamModeType == CustomEnum.ETeamMode.TurnBase then
|
|
UGCEventSystem.AddListener(EventEnum.RoundBegining, self.SetEndSpectateOther, self)
|
|
self.LoopCheckDefaultPanelHandle = UGCEventSystem.SetTimerLoop(self, self.CheckHPJYDefalutPanel, 3.)
|
|
end
|
|
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)
|
|
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.Key, false)
|
|
|
|
|
|
-- WidgetManager:ShowPanel(WidgetConfig.EUIType.Shop, false)
|
|
WidgetManager:ShowPanel(WidgetConfig.EUIType.FightPanel, false)
|
|
UGCLogSystem.Log("[UGCPlayerController_ShowDefaultUI] Finish")
|
|
if self.NeedExePlayerIsFirstTimePlaying then
|
|
self:PlayerIsFirstTimePlaying()
|
|
end
|
|
|
|
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: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:PlayerIsFirstTimePlaying()
|
|
if UGCGameSystem.GameState:GetGameStateType() == CustomEnum.EGameState.Playing then
|
|
WidgetManager:ShowPanel(WidgetConfig.EUIType.Guide, false)
|
|
else
|
|
self.bAutoShowGuide = true
|
|
end
|
|
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
|
|
self.bPlayerIsDead = true
|
|
-- 观战
|
|
--UGCGameSystem.MyObserversChangeTarget(self)
|
|
--UGCEventSystem.SetTimer(self, self.SpectateOther, 2.)
|
|
--self:SpectateOther()
|
|
else
|
|
-- 摄像机过渡
|
|
-- self:CameraMoveToKiller(VictimKey, CauserKey)
|
|
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:GetReplicatedProperties()
|
|
return
|
|
end
|
|
|
|
--- 观战
|
|
function UGCPlayerController:SpectateOther()
|
|
if UGCGameSystem.IsServer() then
|
|
if GlobalConfigs.GameSetting.SpectateAllPlayer then
|
|
--观战所有玩家
|
|
local OBPlayerKeys = {}
|
|
local PlayerControllerList = UGCGameSystem.GetAllPlayerController()
|
|
for _, PlayerController in ipairs(PlayerControllerList) do
|
|
if PlayerController and PlayerController ~= self and UE.IsValid(PlayerController.Pawn) and PlayerController.Pawn:IsAlive() then
|
|
table.insert(OBPlayerKeys, PlayerController.PlayerKey)
|
|
end
|
|
end
|
|
UGCGameSystem.EnterSpectating(self) --进入观战
|
|
UGCGameSystem.ChangeAllowOBPlayerKeys(self, OBPlayerKeys) --设置该玩家可以观战所有玩家。
|
|
|
|
UGCLogSystem.Log("[UGCPlayerController_SpectateOther] PlayerKey:%s", tostring(self.PlayerKey))
|
|
UGCLogSystem.LogTree("[UGCPlayerController_SpectateOther] OBPlayerKeys:", OBPlayerKeys)
|
|
else
|
|
-- 默认观看队友
|
|
UGCGameSystem.EnterSpectating(self);
|
|
end
|
|
|
|
|
|
|
|
UGCSendRPCSystem.ActorRPCNotify(self.PlayerKey, self, "SpectateOther")
|
|
else
|
|
self.IsSpectateOther = true
|
|
self:CastUIMsg("UIMsg_HideQuitWatch", "");
|
|
UGCEventSystem.SetTimer(self, function()
|
|
self:CastUIMsg("UIMsg_HideQuitWatch", "");
|
|
end, 1.)
|
|
end
|
|
end
|
|
|
|
function UGCPlayerController:SetEndSpectateOther()
|
|
self.IsSpectateOther = false
|
|
self.bPlayerIsDead = false
|
|
end
|
|
|
|
function UGCPlayerController:CheckHPJYDefalutPanel()
|
|
-- UGCLogSystem.Log("[UGCPlayerController_CheckHPJYDefalutPanel] self.IsSpectateOther:%s", tostring(self.IsSpectateOther))
|
|
if self.IsSpectateOther then
|
|
self:CastUIMsg("UIMsg_HideQuitWatch", "");
|
|
else
|
|
local MainControlPanel = GameBusinessManager.GetWidgetFromName(ingame, "MainControlPanelTochButton_C")
|
|
MainControlPanel:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
end
|
|
end
|
|
|
|
function UGCPlayerController:GetAvailableServerRPCs()
|
|
return
|
|
"Client_PlayerIsFirstTimePlaying"
|
|
end
|
|
|
|
|
|
return UGCPlayerController; |