diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs b/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs new file mode 100644 index 0000000..8395748 --- /dev/null +++ b/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using ZoFo.GameCore.GameManagers.NetworkManager.Updates; + +namespace ZoFo.GameCore.GameManagers.NetworkManager +{ + public class ServerNetworkManager + { + private IPAddress ip = IPAddress.Any; + private int port = 7632; + private IPEndPoint endPoint; + private Socket socket; + private List clients; + private List updates; + delegate void OnDataSend(string data); // + + public void Init() //create Socket + { + endPoint = new IPEndPoint(ip, port); + socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + } + + public void SendData() + { + + } + public void AddData(IUpdateData data) { } + + + //Поток 2 + public void StartWaitingForPlayers()//Слушает игроков, которые хотят подключиться + { + socket.Bind(endPoint); + socket.Listen(10); + for (int i = 0; i < 10; i++) + { + Socket client = socket.Accept(); + clients.Add(client); //добавляем клиентов в лист + } + + StartListening(); + } + + public void StartListening()//начать слушать клиентов в самой игре активируют Ивент + { + var buff = new byte[1024]; + foreach (var client in clients) + { + var answ = client.Receive(buff); + } + } + } +} diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ClientToServer/UpdateInput.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ClientToServer/UpdateInput.cs new file mode 100644 index 0000000..017ab85 --- /dev/null +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ClientToServer/UpdateInput.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer +{ + internal class UpdateInput + { + } +} diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ClientToServer/UpdatePlayerExit.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ClientToServer/UpdatePlayerExit.cs new file mode 100644 index 0000000..ba6c6ca --- /dev/null +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ClientToServer/UpdatePlayerExit.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer +{ + public class UpdatePlayerExit : IUpdateData + { + public int IdEntity { get; set; } + public string UpdateType { get; set; } + } +} diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/IUpdateData.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/IUpdateData.cs index fc9b2d1..edf1cd5 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/IUpdateData.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/IUpdateData.cs @@ -1,5 +1,15 @@ -interface IUpdateData +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates { - -} \ No newline at end of file + public interface IUpdateData + { + public int IdEntity { get; set; } //Id объекта + public string UpdateType { get; set; } //тип обновления + } +} diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateAnimation.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateAnimation.cs new file mode 100644 index 0000000..6f07770 --- /dev/null +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateAnimation.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient +{ + public class UpdateAnimation : IUpdateData //хранит новую анимации + { + public int IdEntity { get; set; } + public string UpdateType { get; set; } + } +} diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateEntityHealth.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateEntityHealth.cs new file mode 100644 index 0000000..618770e --- /dev/null +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateEntityHealth.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient +{ + public class UpdateEntityHealth : IUpdateData//хранит новое хп entity + { + public int IdEntity { get; set; } + public string UpdateType { get; set; } + } +} diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateGameEnded.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateGameEnded.cs new file mode 100644 index 0000000..10173b7 --- /dev/null +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateGameEnded.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient +{ + public class UpdateGameEnded : IUpdateData //хранит полученый лут и уведомляет о конце игры + { + public int IdEntity { get; set; } + public string UpdateType { get; set; } + } +} diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateGameObjectCreated.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateGameObjectCreated.cs new file mode 100644 index 0000000..4cf8a42 --- /dev/null +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateGameObjectCreated.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient +{ + public class UpdateGameObjectCreated : IUpdateData //Хранит объект, который только отправили + { + public int IdEntity { get; set; } + public string UpdateType { get; set; } + } +} diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateLoot.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateLoot.cs new file mode 100644 index 0000000..e7f8a51 --- /dev/null +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateLoot.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient +{ + public class UpdateLoot : IUpdateData //Хранит лут + { + public int IdEntity { get; set; } + public string UpdateType { get; set; } + } +} diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdatePlayerParametrs.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdatePlayerParametrs.cs new file mode 100644 index 0000000..36a2544 --- /dev/null +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdatePlayerParametrs.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient +{ + public class UpdatePlayerParametrs : IUpdateData //Хранит хп, радиацию + { + public int IdEntity { get; set; } + public string UpdateType { get; set; } + } +} diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdatePosition.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdatePosition.cs new file mode 100644 index 0000000..fda8a39 --- /dev/null +++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdatePosition.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient +{ + public class UpdatePosition : IUpdateData //Хранит новую позицию + { + public int IdEntity { get; set; } + public string UpdateType { get; set; } + } +} diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/Update.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/Update.cs deleted file mode 100644 index 8f819c3..0000000 --- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/Update.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates; - -public class Update -{ - //helll -} \ No newline at end of file diff --git a/ZoFo/GameCore/Server.cs b/ZoFo/GameCore/Server.cs new file mode 100644 index 0000000..948ee0e --- /dev/null +++ b/ZoFo/GameCore/Server.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZoFo.GameCore.GameObjects; + +namespace ZoFo.GameCore +{ + public class Server + { + private List gameObjects; + // private List<> entity; //entity + + public void OnDataSend(string data) { } + public void CreateRoom() { } + public void StartGame() { } + public void EndGame() { } + + + } +}