예제 #1
0
    private void OnNameIs(int cnnID, Net_NameIs msg)
    {
        // Add him to list
        ServerClient c = new ServerClient();

        c.connectionID = cnnID;
        c.playerName   = msg.playerName;

        clients.Add(c);

        // Link name to connection ID
        //clients.Find(x => x.connectionID == cnnID).playerName = msg.playerName;

        // Tell everyone new player connected
        Net_NewPlayerJoin newPlayerJoin = new Net_NewPlayerJoin();

        newPlayerJoin.playerName = msg.playerName;
        newPlayerJoin.cnnID      = cnnID;

        Send(newPlayerJoin, clients);

        if (clients.Count >= 2)
        {
            CreateAIManager();
        }
    }
예제 #2
0
    private void OnAskName(Net_AskName msg)
    {
        // Set this clients ID
        ourClientID = msg.clientID;

        Net_NameIs nameIs = new Net_NameIs();

        nameIs.playerName = ourPlayerName;

        // Send our name to server
        SendServer(nameIs);

        if (msg.currentPlayers.Length <= 0)
        {
            return;
        }

        // Create all players
        for (int i = 0; i < msg.currentPlayers.Length; i++)
        {
            SpawnPlayer(msg.currentPlayers[i], msg.currentIDs[i]);
        }
    }