예제 #1
0
        private void ServerStart()
        {
            _server.Start();
            Console.WriteLine("Server start: {0}", DateTime.Now);
            Console.WriteLine("Server Hashcode: {0}", this.GetHashCode());

            int         currentClients = 0;
            GameHandler game           = new GameHandler(this);

            while (true)
            {
                TcpClient client = _server.AcceptTcpClient();
                Console.WriteLine("Client connected: {0}Added to {1} game{2}", client.GetHashCode(), "\n" + game.GetHashCode(), "");

                game.AddPlayer(client, currentClients);
                currentClients++;

                if (currentClients == MaxPlayersEachGame)
                {
                    game.StartGame();
                    currentClients = 0;
                    game           = new GameHandler(this);
                }
            }
        }
예제 #2
0
        private void ServerStart()
        {
            _server.Start();
            Console.WriteLine("Server start: {0}", DateTime.Now);
            Console.WriteLine("Server Hashcode: {0}", this.GetHashCode());

            int currentClients = 0;
            GameHandler game = new GameHandler(this);

            while (true)
            {
                TcpClient client = _server.AcceptTcpClient();
                Console.WriteLine("Client connected: {0}Added to {1} game{2}",client.GetHashCode(),"\n"+game.GetHashCode(),"");

                game.AddPlayer(client,currentClients);
                currentClients++;

                if (currentClients == MaxPlayersEachGame)
                {
                    game.StartGame();
                    currentClients = 0;
                    game = new GameHandler(this);
                }
            }
        }