public GameRoom(string gameRoomId, Server server,  ManagerLogger logger)
 {
     GameRoomId = gameRoomId;
     _server = server; 
     Players = new List<PlayerAndConnection>();
     _cancellationTokenSource = new CancellationTokenSource();
     _task = new Task(Update,_cancellationTokenSource.Token);
     _task.Start();
     _logger = logger; 
     ManagerCamera = new ManagerCamera();
 }
Exemplo n.º 2
0
 private PlayerAndConnection CreatePlayer(NetIncomingMessage inc, List<PlayerAndConnection> players, ManagerCamera managerCamera)
 {
     var random = new Random();
     var player = new Player
     {
         Username = inc.ReadString(),
         Position = new Position {XPosition = random.Next(0, 750), YPosition = random.Next(0, 420) }
     };
     var playerVectorPosition = new Vector2(player.Position.XPosition, player.Position.YPosition);
     var screenPosition = managerCamera.WorldToScreenPosition(playerVectorPosition);
     player.Position.ScreenXPosition = (int) screenPosition.X;
     player.Position.ScreenYPosition = (int) screenPosition.Y;
     player.Position.Visible = managerCamera.InScreenCheck(playerVectorPosition);
     var playerAndConnection = new PlayerAndConnection(player, inc.SenderConnection);
     players.Add(playerAndConnection);
     return playerAndConnection;
 }