From 29a7648e5b7ea08719e82f8368c36f6b463dadc0 Mon Sep 17 00:00:00 2001 From: AnloGames <7383an@gmail.com> Date: Tue, 20 Aug 2024 18:42:08 +0300 Subject: [PATCH] SettingmultiplyPlayers in solo --- ZoFo/GameCore/Client.cs | 13 ++++++++----- .../NetworkManager/ClientNetworkManager.cs | 4 ++++ .../NetworkManager/Updates/UpdateData.cs | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ZoFo/GameCore/Client.cs b/ZoFo/GameCore/Client.cs index 16131a0..b2f5ae2 100644 --- a/ZoFo/GameCore/Client.cs +++ b/ZoFo/GameCore/Client.cs @@ -47,12 +47,15 @@ namespace ZoFo.GameCore // Отправляются данные апдейтса с обновлением инпута AppManager.Instance.InputManager.ActionEvent += () => { - networkManager.AddData(new UpdateInput() + if (AppManager.Instance.client.networkManager.PlayerId > 0) { - InputMovementDirection = AppManager.Instance.InputManager.InputMovementDirection.Serialize(), - InputAttackDirection = AppManager.Instance.InputManager.InputAttackDirection.Serialize(), - PlayerId = AppManager.Instance.client.networkManager.PlayerId - }); + networkManager.AddData(new UpdateInput() + { + InputMovementDirection = AppManager.Instance.InputManager.InputMovementDirection.Serialize(), + InputAttackDirection = AppManager.Instance.InputManager.InputAttackDirection.Serialize(), + PlayerId = AppManager.Instance.client.networkManager.PlayerId + }); + } }; AppManager.Instance.InputManager.OnInteract += () => diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/ClientNetworkManager.cs b/ZoFo/GameCore/GameManagers/NetworkManager/ClientNetworkManager.cs index f195a64..6868637 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/ClientNetworkManager.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/ClientNetworkManager.cs @@ -170,6 +170,10 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager update = token.ToObject(); data.Add(update); break; + case "UpdateCreatePlayer": + update = token.ToObject(); + data.Add(update); + break; } } diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/UpdateData.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/UpdateData.cs index 86f3163..f010031 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/UpdateData.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/UpdateData.cs @@ -27,6 +27,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates [JsonDerivedType(typeof(UpdatePlayerExit))] [JsonDerivedType(typeof(UpdateInputInteraction))] [JsonDerivedType(typeof(UpdateInputShoot))] + [JsonDerivedType(typeof(UpdateCreatePlayer))] public class UpdateData {