Esempio n. 1
0
        private void SceneLoadedForPlayer(NetworkConnection conn, GameObject lobbyPlayerGameObject)
        {
            NetworkLobbyPlayer component = lobbyPlayerGameObject.GetComponent <NetworkLobbyPlayer>();

            if (component == null)
            {
                return;
            }
            string name = SceneManager.GetSceneAt(0).name;

            if (LogFilter.logDebug)
            {
                Debug.Log("NetworkLobby SceneLoadedForPlayer scene:" + name + " " + conn);
            }
            if (name == m_LobbyScene)
            {
                PendingPlayer item = default(PendingPlayer);
                item.conn        = conn;
                item.lobbyPlayer = lobbyPlayerGameObject;
                m_PendingPlayers.Add(item);
                return;
            }
            short      playerControllerId = lobbyPlayerGameObject.GetComponent <NetworkIdentity>().playerControllerId;
            GameObject gameObject         = OnLobbyServerCreateGamePlayer(conn, playerControllerId);

            if (gameObject == null)
            {
                Transform startPosition = GetStartPosition();
                gameObject = ((!(startPosition != null)) ? Object.Instantiate(gamePlayerPrefab, Vector3.zero, Quaternion.identity) : Object.Instantiate(gamePlayerPrefab, startPosition.position, startPosition.rotation));
            }
            if (OnLobbyServerSceneLoadedForPlayer(lobbyPlayerGameObject, gameObject))
            {
                NetworkServer.ReplacePlayerForConnection(conn, gameObject, playerControllerId);
            }
        }
Esempio n. 2
0
 public override void OnServerSceneChanged(string sceneName)
 {
     if (sceneName != m_LobbyScene)
     {
         for (int i = 0; i < m_PendingPlayers.Count; i++)
         {
             PendingPlayer pendingPlayer = m_PendingPlayers[i];
             SceneLoadedForPlayer(pendingPlayer.conn, pendingPlayer.lobbyPlayer);
         }
         m_PendingPlayers.Clear();
     }
     OnLobbyServerSceneChanged(sceneName);
 }
Esempio n. 3
0
 public override void OnServerSceneChanged(string sceneName)
 {
     if (sceneName != m_LobbyScene)
     {
         foreach (PendingPlayer pendingPlayer in m_PendingPlayers)
         {
             PendingPlayer current = pendingPlayer;
             SceneLoadedForPlayer(current.conn, current.lobbyPlayer);
         }
         m_PendingPlayers.Clear();
     }
     OnLobbyServerSceneChanged(sceneName);
 }