Beispiel #1
0
        public void Setup(NetPeerConfiguration config)
        {
            server = new NetPeer(config);
            server.Start();

            networkInfo           = new NetworkInfo();
            networkInfo.IPAddress = server.Configuration.BroadcastAddress.ToString();
            networkInfo.port      = server.Port;
        }
Beispiel #2
0
        public void Draw()
        {
            // Welcome Message
            SpriteFont LobbyWelcomeText = new SpriteFont("Welcome To Lobby", 10, 450);

            LobbyWelcomeText.Update();
            LobbyWelcomeText.Draw();

            if (state == LOBBY_STATE.START)
            {
                SpriteFont SelectionMessage1 = new SpriteFont("Press H to Host", 10, 400);
                SelectionMessage1.Update();
                SelectionMessage1.Draw();
            }
            else if (state == LOBBY_STATE.HOST)
            {
                SpriteFont msg1 = new SpriteFont("You are currently Hosting", 10, 400);
                msg1.Update();
                msg1.Draw();

                NetworkInfo temp = MyServer.Instance.getNetworkInfo();

                SpriteFont msg2 = new SpriteFont("Server IP: " + temp.IPAddress + " Port: " + temp.port, 50, 350);
                msg2.Update();
                msg2.Draw();

                SpriteFont msg3 = new SpriteFont("Connected Clients", 10, 300);
                msg3.Update();
                msg3.Draw();

                List <NetConnection> connections = MyServer.Instance.getConnectionList();
                int numConnections = connections.Count;
                for (int i = 0; i < numConnections; i++)
                {
                    NetConnection c = connections[i];

                    SpriteFont tmp = new SpriteFont("Client " + i + " - IP: " + c.RemoteEndPoint.Address.ToString() + " Port: " + c.RemoteEndPoint.Port, 20, 250 - (i * 25));
                    tmp.Update();
                    tmp.Draw();
                }
            }
        }
Beispiel #3
0
        public void Draw()
        {
            // Welcome Message
            SpriteFont LobbyWelcomeText = new SpriteFont("Welcome To Lobby", 10, 450);

            LobbyWelcomeText.Update();
            LobbyWelcomeText.Draw();

            if (state == LOBBY_STATE.START)
            {
                SpriteFont SelectionMessage1 = new SpriteFont("Press J to Join", 10, 400);
                SelectionMessage1.Update();
                SelectionMessage1.Draw();
            }

            else if (state == LOBBY_STATE.CLIENT)
            {
                if (MyClient.Instance.isConnected() == false)
                {
                    SpriteFont msg1 = new SpriteFont("Attempting To Join", 10, 400);
                    msg1.Update();
                    msg1.Draw();
                }
                else
                {
                    SpriteFont msg1 = new SpriteFont("Connected To Server", 10, 400);
                    msg1.Update();
                    msg1.Draw();

                    NetworkInfo temp = MyClient.Instance.getConnectedServerInfo();

                    //SpriteFont msg2 = new SpriteFont("Server IP: " + temp.IPAddress + " Port: " + temp.port, 50, 350);
                    //msg2.Update();
                    //msg2.Draw();
                }
            }
        }