示例#1
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     // TODO: Add your initialization logic here
     Settings.Instance.loadSettings();
     TextureCollection.Instance.SetContent(Content);
     SoundCollection.Instance.SetContent(Content);
     FontCollection.Instance.LoadFonts(Content);
     spriteBatch   = new SpriteBatch(GraphicsDevice);
     lobbyOnline   = new LobbyOnline(spriteBatch, this);
     localUpdates  = new Network.LocalUpdates(this, lobbyOnline);
     networkThread = new Network.NetworkThread(localUpdates);
     scene         = new Scene(spriteBatch, Content, new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), this);
     lobbySearch   = new LobbySearch(spriteBatch, this);
     localUpdates.SetNetworkThread(networkThread);
     localUpdates.SetScene(scene);
     mainMenu           = new MainMenu(spriteBatch, this);
     postGameMenu       = new PostGameMenu(spriteBatch, this);
     modifierMenu       = new ModifierMenu(spriteBatch, this);
     menuSettings       = new MenuSettings(spriteBatch, this);
     menuControls       = new MenuControls(spriteBatch, this);
     menuPause          = new MenuPause(spriteBatch, this);
     creditScreen       = new CreditScreen(spriteBatch, this);
     loadingScreen      = new LoadingScreen(spriteBatch, this);
     launchMenu         = new LaunchMenu(spriteBatch, this, networkThread);
     waitForServerStart = new WaitForServerStart(networkThread, spriteBatch);
     music          = SoundCollection.Instance.GetSoundInstance(SoundType.Menu_Music);
     music.IsLooped = true;
     music.Volume   = 0.5f * Settings.Instance.VolumeMusic;
     music.Play();
 }
示例#2
0
        public NetworkThread(LocalUpdates localUpdates)
        {
            this.localUpdates = localUpdates;
            NetPeerConfiguration config = new NetPeerConfiguration("GameServer");

            config.AutoFlushSendQueue = false;
            config.EnableMessageType(NetIncomingMessageType.UnconnectedData);
            s_client = new NetClient(config);

            //s_client.RegisterReceivedCallback(new SendOrPostCallback(GotMessage),new SynchronizationContext());
            port     = 23451;
            Instance = this;
            s_client.Start();
        }