示例#1
0
    // A client has just requested to connect to the server
    void ConnectionRequest(ServerNetwork.ConnectionRequestInfo data)
    {
        Debug.Log("Connection request from IP " + data.connection.RemoteEndPoint.Address);

        // Approve connections as long as we are in the login state
        if (currentState == GameState.Login)
        {
            Player newPlayer = new Player();
            newPlayer.clientId    = data.id;
            newPlayer.isConnected = false;
            newPlayer.name        = "";
            newPlayer.isReady     = false;
            newPlayer.playerClass = 0;
            newPlayer.teamId      = 0;
            newPlayer.xPosition   = 0;
            newPlayer.yPosition   = 0;
            players.Add(newPlayer);

            serverNet.ConnectionApproved(data.id);
        }
        else
        {
            serverNet.ConnectionDenied(data.id);
        }
    }
示例#2
0
    // A client has just requested to connect to the server
    void ConnectionRequest(ServerNetwork.ConnectionRequestInfo data)
    {
        Debug.Log("Connection request from " + data.username);

        // We either need to approve a connection or deny it
        if (gameState == GameState.pregame) //Make this bigger for the final game
        {
            Player newPlayer = new Player();
            newPlayer.clientId    = data.id;
            newPlayer.playerName  = data.username;
            newPlayer.isConnected = false;
            newPlayer.isReady     = false;
            players.Add(newPlayer);

            serverNet.ConnectionApproved(data.id);
        }
        else
        {
            serverNet.ConnectionDenied(data.id);
        }
    }
示例#3
0
    void ConnectionRequest(ServerNetwork.ConnectionRequestInfo data)
    {
        Debug.Log("Connection request from " + data.username);

        // We either need to approve a connection or deny it
        //if (players.Count < 2)
        {
            Player newPlayer = new Player();
            newPlayer.clientId    = data.id;
            newPlayer.playerName  = data.username;
            newPlayer.isConnected = false;
            newPlayer.isReady     = false;
            players.Add(newPlayer);

            serverNet.ConnectionApproved(data.id);
        }

        /*
         * else
         * {
         *  serverNet.ConnectionDenied(data.id);
         * }
         */
    }
示例#4
0
    // A client has just requested to connect to the server
    void ConnectionRequest(ServerNetwork.ConnectionRequestInfo data)
    {
        Debug.Log("Connection request from " + data.username);

        serverNet.ConnectionApproved(data.id);
    }