Beispiel #1
0
public void Start()
	{
Lidgren.Network.NetPeerConfiguration config = new Lidgren.Network.NetPeerConfiguration("AsteroidShooter");
NetworkAPI.Client = new Lidgren.Network.NetClient(config);
NetworkAPI.Client.Start();
NetworkAPI.Client.Connect("127.0.0.1", 5432);
this.Connected = false;
		Ships = (

(new Cons<Ship>(new Ship(new Microsoft.Xna.Framework.Vector2(0f,0f)),(new Empty<Ship>()).ToList<Ship>())).ToList<Ship>()).ToList<Ship>();
		Input = Microsoft.Xna.Framework.Input.Keyboard.GetState();
		Connected = false;
		
foreach(var entity in Ships) {
                                    NetworkAPI.ShipInfos.Add(entity.Net_ID, new NetworkInfo<Ship>(entity, true));;
                                 }}
Beispiel #2
0
        //Refresh the entire server
        public void AutoRestartServer(string name, int port, bool isPublic, string password, bool attemptUPnP, int maxPlayers, Lidgren.Network.NetServer prevserver = null, Lidgren.Network.NetPeerConfiguration prevconfig = null)
        {
            List <Client> PreviousClients = new List <Client>(GameMain.Server.ConnectedClients);
            ushort        LastUpdateID    = GameMain.NetLobbyScreen.LastUpdateID += 1;

            Server.DisconnectRestart();
            Server = null;

            Config = new GameSettings("config.xml");
            if (Config.WasGameUpdated)
            {
                UpdaterUtil.CleanOldFiles();
                Config.WasGameUpdated = false;
                Config.Save("config.xml");
            }

            NilMod = new NilMod();
            NilMod.Load(false);

            NilMod.NilModVPNBanlist = new VPNBanlist();
            NilMod.NilModVPNBanlist.LoadVPNBans();

            GameScreen = new GameScreen();

            //Init();

            Submarine.RefreshSavedSubs();

            Screen.SelectNull();

            NetLobbyScreen = new NetLobbyScreen();

            NetLobbyScreen.ServerName = GameMain.NilMod.ServerName;

            Server = new GameServer(name,
                                    port,
                                    isPublic,
                                    password,
                                    attemptUPnP,
                                    maxPlayers,
                                    prevserver,
                                    prevconfig);

            DefaultServerStartup();

            Timing.Accumulator = 0.0;
            stopwatch.Stop();
            stopwatch = Stopwatch.StartNew();
            prevTicks = stopwatch.ElapsedTicks;

            GameMain.Server.AddRestartClients(PreviousClients, LastUpdateID);
        }
Beispiel #3
0
        public void AutoRestartServer(string name, int port, bool isPublic, string password, bool attemptUPnP, int maxPlayers, Lidgren.Network.NetServer prevserver = null, Lidgren.Network.NetPeerConfiguration prevconfig = null)
        {
            if (Server == null)
            {
                return;
            }
            List <Client> PreviousClients = new List <Client>(GameMain.Server.ConnectedClients);
            ushort        LastUpdateID    = GameMain.NetLobbyScreen.LastUpdateID += 1;

            GameMain.Server.DisconnectRestart();
            GameMain.NetworkMember = null;

            waitForKeyHit           = false;
            NilMod.Skippedtoserver  = true;
            GameMain.NetLobbyScreen = new NetLobbyScreen();

            try
            {
                GameMain.NetworkMember = new GameServer(name,
                                                        port,
                                                        isPublic,
                                                        password,
                                                        attemptUPnP,
                                                        maxPlayers,
                                                        prevserver,
                                                        prevconfig);
            }
            catch (Exception e)
            {
                DebugConsole.ThrowError("Failed to start server", e);
            }

            GameMain.NetLobbyScreen.IsServer = true;
            GameMain.NetLobbyScreen.DefaultServerStartup();
            waitForKeyHit = false;

            if (GameMain.Server != null)
            {
                GameMain.Server.AddRestartClients(PreviousClients, LastUpdateID);
            }
        }