예제 #1
0
    public override void ServerChangeScene(string newSceneName)
    {
        if (SceneManager.GetActiveScene().path == lobbyScene && newSceneName.StartsWith("Scene"))
        {
            System.Random rnd     = new System.Random();
            var           players = RoomPlayers.OrderBy(x => rnd.Next()).Take(numScientists);
            foreach (var player in players)
            {
                player.IsScientist = true;
            }
            for (int i = RoomPlayers.Count - 1; i >= 0; i--)
            {
                var conn = RoomPlayers[i].connectionToClient;
                var gamePlayerInstance = Instantiate(gamePlayerPrefab);
                gamePlayerInstance.SetDisplayName(RoomPlayers[i].DisplayName);
                gamePlayerInstance.SetIsScientist(RoomPlayers[i].IsScientist);

                // NetworkServer.Destroy(conn.identity.gameObject);

                NetworkServer.ReplacePlayerForConnection(conn, gamePlayerInstance.gameObject);
            }
        }

        base.ServerChangeScene(newSceneName);
    }