ZoFo/ZoFo/GameCore/Server.cs
2024-08-15 19:21:30 +03:00

42 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using ZoFo.GameCore.GameManagers.NetworkManager;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.GameObjects;
namespace ZoFo.GameCore
{
public class Server
{
private List<GameObject> gameObjects;
private ServerNetworkManager networkManager;
private List<Entity> entity; //entity
public Server()
{
networkManager = new ServerNetworkManager();
networkManager.GetDataSend += OnDataSend;
}
public void OnDataSend(string data)
{
List<IUpdateData> updateDatas = JsonSerializer.Deserialize<List<IUpdateData>>(data);
//ТУТ Switch case будет честное слово
}
public void CreateRoom(int players) //Создает комнату и запускает ожидание подключений
{
networkManager.StartWaitingForPlayers(players);
}
// public void StartGame() { } принудительный запуск
public void EndGame() //Добавляет UpdateGameEnded и отключает игроков
{
UpdateGameEnded gameEnded = new UpdateGameEnded();
networkManager.AddData(gameEnded);
networkManager.CloseConnection();
}
}
}