diff --git a/ZoFo/GameCore/Client.cs b/ZoFo/GameCore/Client.cs index f96599a..94e27a0 100644 --- a/ZoFo/GameCore/Client.cs +++ b/ZoFo/GameCore/Client.cs @@ -28,7 +28,7 @@ namespace ZoFo.GameCore public void OnDataSend(string data) { - List updateDatas = JsonSerializer.Deserialize>(data); + List updateDatas = JsonSerializer.Deserialize>(data); // тут будет switch foreach (var item in updateDatas) { diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/ClientNetworkManager.cs b/ZoFo/GameCore/GameManagers/NetworkManager/ClientNetworkManager.cs index f833988..c178154 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/ClientNetworkManager.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/ClientNetworkManager.cs @@ -18,7 +18,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager private int port = 7632; private EndPoint endPoint; private Socket socket; - List updates = new List(); + List updates = new List(); public delegate void OnDataSent(string Data); public event OnDataSent GetDataSent; // event public bool IsConnected { get { return socket.Connected; } } @@ -44,7 +44,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager socket.Send(bytes); } - public void AddData(IUpdateData UpdateData) + public void AddData(UpdateData UpdateData) { updates.Add(UpdateData); } diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs b/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs index bb8717a..0686800 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs @@ -38,7 +38,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); managerThread = new Dictionary(); clients = new List(); - updates = new List(); + updates = new List(); managerThread = new Dictionary(); socket.Bind(endPoint); } @@ -68,7 +68,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager /// добавляет в лист updates новую data /// /// - public void AddData(IUpdateData data) + public void AddData(UpdateData data) { updates.Add(data); } diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ClientToServer/UpdateInput.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ClientToServer/UpdateInput.cs index 81af1d9..bb2ea93 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ClientToServer/UpdateInput.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ClientToServer/UpdateInput.cs @@ -6,9 +6,12 @@ using System.Threading.Tasks; namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer { - public class UpdateInput :IUpdateData + public class UpdateInput :UpdateData { - public int IdEntity { get; set; } - public string UpdateType { get; set; } + // public int IdEntity { get; set; } + public UpdateInput() + { + UpdateType = "UpdateInput"; + } } } diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ClientToServer/UpdatePlayerExit.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ClientToServer/UpdatePlayerExit.cs index ba6c6ca..7cb0b44 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ClientToServer/UpdatePlayerExit.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ClientToServer/UpdatePlayerExit.cs @@ -6,9 +6,8 @@ using System.Threading.Tasks; namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer { - public class UpdatePlayerExit : IUpdateData + public class UpdatePlayerExit : UpdateData { - public int IdEntity { get; set; } - public string UpdateType { get; set; } + public UpdatePlayerExit() { UpdateType = "UpdatePlayerExit"; } } } diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateAnimation.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateAnimation.cs index 6f07770..92fdc73 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateAnimation.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateAnimation.cs @@ -6,9 +6,8 @@ using System.Threading.Tasks; namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient { - public class UpdateAnimation : IUpdateData //хранит новую анимации + public class UpdateAnimation : UpdateData //хранит новую анимации { - public int IdEntity { get; set; } - public string UpdateType { get; set; } + public UpdateAnimation() { UpdateType = "UpdateAnimation"; } } } diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateEntityHealth.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateEntityHealth.cs index 618770e..7e1efd3 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateEntityHealth.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateEntityHealth.cs @@ -6,9 +6,8 @@ using System.Threading.Tasks; namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient { - public class UpdateEntityHealth : IUpdateData//хранит новое хп entity + public class UpdateEntityHealth : UpdateData//хранит новое хп entity { - public int IdEntity { get; set; } - public string UpdateType { get; set; } + public UpdateEntityHealth() { UpdateType = "UpdateEntityHealth"; } } } diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateGameEnded.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateGameEnded.cs index 10173b7..193f6c1 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateGameEnded.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateGameEnded.cs @@ -6,9 +6,8 @@ using System.Threading.Tasks; namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient { - public class UpdateGameEnded : IUpdateData //хранит полученый лут и уведомляет о конце игры + public class UpdateGameEnded : UpdateData //хранит полученый лут и уведомляет о конце игры { - public int IdEntity { get; set; } - public string UpdateType { get; set; } + public UpdateGameEnded() { UpdateType = "UpdateGameEnded"; } } } diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateGameObjectCreated.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateGameObjectCreated.cs index 4cf8a42..d3a154f 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateGameObjectCreated.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateGameObjectCreated.cs @@ -6,9 +6,8 @@ using System.Threading.Tasks; namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient { - public class UpdateGameObjectCreated : IUpdateData //Хранит объект, который только отправили + public class UpdateGameObjectCreated : UpdateData //Хранит объект, который только отправили { - public int IdEntity { get; set; } - public string UpdateType { get; set; } + public UpdateGameObjectCreated() { UpdateType = "UpdateGameObjectCreated"; } } } diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateLoot.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateLoot.cs index e7f8a51..19d390c 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateLoot.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateLoot.cs @@ -6,9 +6,8 @@ using System.Threading.Tasks; namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient { - public class UpdateLoot : IUpdateData //Хранит лут + public class UpdateLoot : UpdateData //Хранит лут { - public int IdEntity { get; set; } - public string UpdateType { get; set; } + public UpdateLoot() { UpdateType = "UpdateLoot"; } } } diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdatePlayerParametrs.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdatePlayerParametrs.cs index 36a2544..818dcce 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdatePlayerParametrs.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdatePlayerParametrs.cs @@ -6,9 +6,8 @@ using System.Threading.Tasks; namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient { - public class UpdatePlayerParametrs : IUpdateData //Хранит хп, радиацию + public class UpdatePlayerParametrs : UpdateData //Хранит хп, радиацию { - public int IdEntity { get; set; } - public string UpdateType { get; set; } + public UpdatePlayerParametrs() { UpdateType = "UpdatePlayerParametrs"; } } } diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdatePosition.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdatePosition.cs index fda8a39..ae58334 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdatePosition.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdatePosition.cs @@ -6,9 +6,8 @@ using System.Threading.Tasks; namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient { - public class UpdatePosition : IUpdateData //Хранит новую позицию + public class UpdatePosition : UpdateData //Хранит новую позицию { - public int IdEntity { get; set; } - public string UpdateType { get; set; } + public UpdatePosition() { UpdateType = "UpdatePosition"; } } } diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateTileCreated.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateTileCreated.cs index 56f9aed..2002a34 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateTileCreated.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateTileCreated.cs @@ -10,11 +10,10 @@ using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer; namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient { - - public class UpdateTileCreated : IUpdateData + + public class UpdateTileCreated : UpdateData { - public int IdEntity { get; set; } - public string UpdateType { get; set; } + public UpdateTileCreated() { UpdateType = "UpdateTileCreated"; } public Texture2D TextureTile { get; set; } public Vector2 Position { get; set; } public Point Size { get; set; } diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/IUpdateData.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/UpdateData.cs similarity index 88% rename from ZoFo/GameCore/GameManagers/NetworkManager/Updates/IUpdateData.cs rename to ZoFo/GameCore/GameManagers/NetworkManager/Updates/UpdateData.cs index 5c363d7..bb462ad 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/IUpdateData.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/UpdateData.cs @@ -20,10 +20,10 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates [JsonDerivedType(typeof(UpdateTileCreated))] [JsonDerivedType(typeof(UpdateInput))] [JsonDerivedType(typeof(UpdatePlayerExit))] - - public interface IUpdateData + + public class UpdateData { public int IdEntity { get; set; } //Id объекта - public string UpdateType { get; set; } //тип обновления + public string UpdateType { get; protected set; } //тип обновления } } diff --git a/ZoFo/GameCore/Server.cs b/ZoFo/GameCore/Server.cs index 0d7fc66..72329d9 100644 --- a/ZoFo/GameCore/Server.cs +++ b/ZoFo/GameCore/Server.cs @@ -50,7 +50,7 @@ namespace ZoFo.GameCore /// добавляет в лист updates новую data /// /// - public void AddData(IUpdateData data) + public void AddData(UpdateData data)//добавляет в лист updates новую data { networkManager.AddData(data); }