Esempio n. 1
0
        public static GameObject CreateNetworkManager()
        {
            var go = new GameObject("NetworkManager", typeof(TcpTransport), typeof(NetworkSceneManager), typeof(NetworkClient), typeof(NetworkServer), typeof(NetworkManager), typeof(PlayerSpawner), typeof(NetworkManagerHud));

            TcpTransport        transport = go.GetComponent <TcpTransport>();
            NetworkSceneManager nsm       = go.GetComponent <NetworkSceneManager>();

            NetworkClient networkClient = go.GetComponent <NetworkClient>();

            networkClient.Transport = transport;

            NetworkServer networkServer = go.GetComponent <NetworkServer>();

            networkServer.transport = transport;

            NetworkManager networkManager = go.GetComponent <NetworkManager>();

            networkManager.client = networkClient;
            networkManager.server = networkServer;

            PlayerSpawner playerSpawner = go.GetComponent <PlayerSpawner>();

            playerSpawner.client = networkClient;
            playerSpawner.server = networkServer;

            nsm.client = networkClient;
            nsm.server = networkServer;
            return(go);
        }
Esempio n. 2
0
        public void Setup()
        {
            go                         = new GameObject();
            client                     = go.AddComponent <NetworkClient>();
            server                     = go.AddComponent <NetworkServer>();
            spawner                    = go.AddComponent <PlayerSpawner>();
            sceneManager               = go.AddComponent <NetworkSceneManager>();
            serverObjectManager        = go.AddComponent <ServerObjectManager>();
            clientObjectManager        = go.AddComponent <ClientObjectManager>();
            spawner.sceneManager       = sceneManager;
            sceneManager.client        = client;
            sceneManager.server        = server;
            serverObjectManager.server = server;
            clientObjectManager.client = client;
            clientObjectManager.networkSceneManager = sceneManager;
            spawner.client = client;
            spawner.server = server;
            spawner.serverObjectManager = serverObjectManager;
            spawner.clientObjectManager = clientObjectManager;

            playerPrefab = new GameObject();
            NetworkIdentity playerId = playerPrefab.AddComponent <NetworkIdentity>();

            spawner.playerPrefab = playerId;

            pos1 = new GameObject().transform;
            pos2 = new GameObject().transform;
            spawner.startPositions.Add(pos1);
            spawner.startPositions.Add(pos2);
        }
Esempio n. 3
0
        public static GameObject CreateNetworkManager()
        {
            var go = new GameObject("NetworkManager", typeof(NetworkManager), typeof(NetworkServer), typeof(NetworkClient), typeof(NetworkSceneManager), typeof(ServerObjectManager), typeof(ClientObjectManager), typeof(PlayerSpawner), typeof(KcpTransport), typeof(LogSettings));

            KcpTransport        transport = go.GetComponent <KcpTransport>();
            NetworkSceneManager nsm       = go.GetComponent <NetworkSceneManager>();

            NetworkClient networkClient = go.GetComponent <NetworkClient>();

            networkClient.Transport = transport;

            NetworkServer networkServer = go.GetComponent <NetworkServer>();

            networkServer.transport = transport;

            ServerObjectManager serverObjectManager = go.GetComponent <ServerObjectManager>();

            serverObjectManager.server = networkServer;
            serverObjectManager.networkSceneManager = nsm;

            ClientObjectManager clientObjectManager = go.GetComponent <ClientObjectManager>();

            clientObjectManager.client = networkClient;
            clientObjectManager.networkSceneManager = nsm;

            NetworkManager networkManager = go.GetComponent <NetworkManager>();

            networkManager.client = networkClient;
            networkManager.server = networkServer;
            networkManager.serverObjectManager = serverObjectManager;
            networkManager.clientObjectManager = clientObjectManager;
            networkManager.sceneManager        = nsm;

            PlayerSpawner playerSpawner = go.GetComponent <PlayerSpawner>();

            playerSpawner.client              = networkClient;
            playerSpawner.server              = networkServer;
            playerSpawner.sceneManager        = nsm;
            playerSpawner.serverObjectManager = serverObjectManager;
            playerSpawner.clientObjectManager = clientObjectManager;

            nsm.client = networkClient;
            nsm.server = networkServer;
            return(go);
        }