Esempio n. 1
0
    void Connect(GamePlatform platform)
    {
        if (singleplayer)
        {
            if (platform.SinglePlayerServerAvailable())
            {
                platform.SinglePlayerServerStart(singleplayerSavePath);
            }
            else
            {
                serverSimple = new ServerSimple();
                DummyNetwork network = platform.SinglePlayerServerGetNetwork();
                network.Start(platform.MonitorCreate(), platform.MonitorCreate());
                DummyNetServer server = new DummyNetServer();
                server.network  = network;
                server.platform = platform;
                server.Start();
                serverSimple.Start(server, singleplayerSavePath, platform);

                serverSimpleMod        = new ModServerSimple();
                serverSimpleMod.server = serverSimple;
                game.AddMod(serverSimpleMod);
                platform.SinglePlayerServerGetNetwork().ServerReceiveBuffer.Enqueue(new ByteArray());
            }

            connectData          = new ConnectData();
            connectData.Username = "******";
            game.connectdata     = connectData;

            DummyNetClient netclient = new DummyNetClient();
            netclient.SetPlatform(platform);
            netclient.SetNetwork(platform.SinglePlayerServerGetNetwork());
            game.main = netclient;
        }
        else
        {
            game.connectdata = connectData;
            if (platform.EnetAvailable())
            {
                EnetNetClient client = new EnetNetClient();
                client.SetPlatform(platform);
                game.main = client;
            }
            else if (platform.TcpAvailable())
            {
                TcpNetClient client = new TcpNetClient();
                client.SetPlatform(platform);
                game.main = client;
            }
            else if (platform.WebSocketAvailable())
            {
                WebSocketClient client = new WebSocketClient();
                client.SetPlatform(platform);
                game.main = client;
            }
            else
            {
                platform.ThrowException("Network not implemented");
            }
        }
    }
Esempio n. 2
0
    void Connect(GamePlatform platform)
    {
        if (singleplayer)
        {
            if (platform.SinglePlayerServerAvailable())
            {
                platform.SinglePlayerServerStart(singleplayerSavePath);
            }
            else
            {
                serverSimple = new ServerSimple();
                DummyNetwork network = platform.SinglePlayerServerGetNetwork();
                network.Start(platform.MonitorCreate(), platform.MonitorCreate());
                DummyNetServer server = new DummyNetServer();
                server.network = network;
                server.platform = platform;
                server.Start();
                serverSimple.Start(server, singleplayerSavePath, platform);

                serverSimpleMod = new ModServerSimple();
                serverSimpleMod.server = serverSimple;
                game.AddMod(serverSimpleMod);
                platform.SinglePlayerServerGetNetwork().ServerReceiveBuffer.Enqueue(new ByteArray());
            }

            connectData = new ConnectData();
            connectData.Username = "******";
            game.connectdata = connectData;

            DummyNetClient netclient = new DummyNetClient();
            netclient.SetPlatform(platform);
            netclient.SetNetwork(platform.SinglePlayerServerGetNetwork());
            game.main = netclient;
        }
        else
        {
            game.connectdata = connectData;
            if (platform.EnetAvailable())
            {
                EnetNetClient client = new EnetNetClient();
                client.SetPlatform(platform);
                game.main = client;
            }
            else if (platform.TcpAvailable())
            {
                TcpNetClient client = new TcpNetClient();
                client.SetPlatform(platform);
                game.main = client;
            }
            else if (platform.WebSocketAvailable())
            {
                WebSocketClient client = new WebSocketClient();
                client.SetPlatform(platform);
                game.main = client;
            }
            else
            {
                platform.ThrowException("Network not implemented");
            }
        }
    }