예제 #1
0
        private void OnSetNickname(NetworkConnection conn, SetupPlayerMessage message)
        {
            GameObject  player      = Instantiate(playerPrefab);
            LobbyPlayer lobbyPlayer = player.GetComponent <LobbyPlayer>();

            //lobbyPlayer.nickname = message.nickname;

            NetworkServer.AddPlayerForConnection(conn, player);
        }
예제 #2
0
        /// <summary>
        /// Called on the server when a network error occurs for a client connection.
        /// </summary>
        /// <param name="conn">Connection from client.</param>
        /// <param name="errorCode">Error code.</param>


        #endregion

        #region Client System Callbacks

        /// <summary>
        /// Called on the client when connected to a server.
        /// <para>The default implementation of this function sets the client as ready and adds a player. Override the function to dictate what happens when the client connects.</para>
        /// </summary>
        /// <param name="conn">Connection to the server.</param>
        public override void OnClientConnect(NetworkConnection conn)
        {
            base.OnClientConnect(conn);

            SetupPlayerMessage setupPlayerMessage = new SetupPlayerMessage();

            setupPlayerMessage.nickname = tempNickName;

            conn.Send(setupPlayerMessage);
        }
예제 #3
0
        private void OnSetNickname(NetworkConnection conn, SetupPlayerMessage message)
        {
            clientIndex++;

            if (IsSceneActive(RoomScene))
            {
                if (roomSlots.Count == maxConnections)
                {
                    return;
                }

                allPlayersReady = false;

                GameObject  newRoomGameObject = Instantiate(roomPlayerPrefab.gameObject);
                LobbyPlayer lobbyPlayer       = newRoomGameObject.GetComponent <LobbyPlayer>();
                lobbyPlayer.playerInfo.nickname = message.nickname;

                NetworkServer.AddPlayerForConnection(conn, newRoomGameObject);
            }
            else
            {
                OnRoomServerAddPlayer(conn);
            }
        }