private void ExecuteRemoteCommand(IDebugCommandHost host, string command, IList <string> arguments) { if (NetworkSession == null) { try { GamerServicesDispatcher.WindowHandle = Game.Window.Handle; GamerServicesDispatcher.Initialize(Game.Services); } catch { } if (SignedInGamer.SignedInGamers.Count > 0) { commandHost.Echo("Finding available sessions..."); asyncResult = NetworkSession.BeginFind( NetworkSessionType.SystemLink, 1, null, null, null); phase = ConnectionPahse.FindSessions; } else { host.Echo("Please signed in."); phase = ConnectionPahse.EnsureSignedIn; } } else { ConnectedToRemote(); } }
// System Constructor, performs initialization public SystemMain() { Height = 720; Width = 1280; //Height = 600; Width = 800; // graphics initializer Also initialize the height and width to 720p //_graphics = new GraphicsDeviceManager(this); _graphics = new GraphicsDeviceManager(this) { PreferredBackBufferWidth = Width, PreferredBackBufferHeight = Height }; //content location Content.RootDirectory = "Content"; GamerServicesDispatcher.Initialize(Services); // initialize font package and texture package FontPackage = new Dictionary <String, SpriteFont>(); TexturePackage = new Dictionary <String, Texture2D>(); // create the stack _menuStack = new Stack <IScreen>(); // create the DataManager and load name list _dataManager = new DataManager(); // create a list of booklets the system can run off of Booklets = _dataManager.LoadBooklets(0); }
} // BeginRun #endregion #region Update /// <summary> /// Called when the game has determined that game logic needs to be processed. /// </summary> protected override void Update(GameTime gameTime) { base.Update(gameTime); if (ResetDevice) { GraphicsDeviceManager.ApplyChanges(); ResetDevice = false; } if (UseGamerServices) GamerServicesDispatcher.Update(); if (ShowExceptionsWithGuide) // If we want to show exception in the Guide. { // If no exception was raised. if (exception == null) { try { GameLoop.Update(gameTime); } catch (Exception e) { Time.PauseGame(); exception = e; } } } else // If not then the StarEngine method will managed them. GameLoop.Update(gameTime); } // Update
public static NetworkSession Create( NetworkSessionType sessionType, IEnumerable <SignedInGamer> localGamers, int maxGamers, int privateGamerSlots, NetworkSessionProperties sessionProperties ) { IAsyncResult result = BeginCreate( sessionType, localGamers, maxGamers, privateGamerSlots, sessionProperties, null, null ); while (!result.IsCompleted) { if (!GamerServicesDispatcher.UpdateAsync()) { activeAction.IsCompleted = true; } } return(EndCreate(result)); }
/// <summary> /// Creates a new instance /// </summary> public LiveSessionManager(Application application) : base(Application.SunBurn) { if (!GamerServicesDispatcher.IsInitialized) { GamerServicesDispatcher.Initialize(application.Services); } GamerServicesDispatcher.WindowHandle = application.Window.Handle; SignedInGamer.SignedIn += OnLiveGamerSignedIn; SignedInGamer.SignedOut += OnLiveGamerSignedOut; }
public static NetworkSession JoinInvited( int maxLocalGamers ) { IAsyncResult result = BeginJoinInvited(maxLocalGamers, null, null); while (!result.IsCompleted) { if (!GamerServicesDispatcher.UpdateAsync()) { activeAction.IsCompleted = true; } } return(EndJoinInvited(result)); }
public static NetworkSession Join( AvailableNetworkSession availableSession ) { IAsyncResult result = BeginJoin(availableSession, null, null); while (!result.IsCompleted) { if (!GamerServicesDispatcher.UpdateAsync()) { activeAction.IsCompleted = true; } } return(EndJoin(result)); }
} // EngineManager #endregion #region Initialize /// <summary> /// Initialize. /// </summary> protected override void Initialize() { // Intercept events // GraphicsDeviceManager.PreparingDeviceSettings += OnPreparingDeviceSettings; GraphicsDeviceManager.DeviceReset += OnDeviceReset; Window.ClientSizeChanged += OnWindowClientSizeChanged; // Reset to take new parameters // GraphicsDevice.Reset(GraphicsDevice.PresentationParameters); // In classes that derive from Game, you need to call base.Initialize in Initialize, // which will automatically enumerate through any game components that have been added to Game.Components and call their Initialize methods. base.Initialize(); if (UseGamerServices) { try { // Initialize Gamer Services Dispatcher if (!GamerServicesDispatcher.IsInitialized) GamerServicesDispatcher.Initialize(Services); GamerServicesDispatcher.WindowHandle = Window.Handle; } catch (GamerServicesNotAvailableException) { throw new InvalidOperationException("Engine Manager: Games for Windows - LIVE is unavailable. Please install it and try again."); } } #region Maximize // If we put 0,0 to window size then we need to maximize. This has to be done here and not before. #if (WINDOWS) if (oldScreenWidth <= 0 || oldScreenHeight <= 0) { Form form = (Form)Control.FromHandle(Window.Handle); form.Location = new Point(0, 0); form.Size = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Size; form.WindowState = FormWindowState.Maximized; } #endif #endregion } // Initialize
public override void Initialize() { if (IsHost) { commandHost.RegisterEchoListner(this); // Create network session if NetworkSession is not set. if (NetworkSession == null) { GamerServicesDispatcher.WindowHandle = Game.Window.Handle; GamerServicesDispatcher.Initialize(Game.Services); NetworkSession = NetworkSession.Create(NetworkSessionType.SystemLink, 1, 2); OwnsNetworkSession = true; } } base.Initialize(); }
void UpdateNetworkSession(GameTime gameTime) { GamerServicesDispatcher.Update(); // TODO: Work out how to do this right... BroadcastLocalShips(); networkSession.Update(); if (networkSession == null) { // If here, then network session has ended. //Go back to join/new session menu //mainGame.setGameState(MainGame.GameState.Menu); return; } foreach (LocalNetworkGamer gamer in networkSession.LocalGamers) { ReadIncomingPackets(gamer); } }
public static AvailableNetworkSessionCollection Find( NetworkSessionType sessionType, IEnumerable <SignedInGamer> localGamers, NetworkSessionProperties searchProperties ) { IAsyncResult result = BeginFind( sessionType, localGamers, searchProperties, null, null ); while (!result.IsCompleted) { if (!GamerServicesDispatcher.UpdateAsync()) { activeAction.IsCompleted = true; } } return(EndFind(result)); }
public static NetworkSession Create( NetworkSessionType sessionType, int maxLocalGamers, int maxGamers ) { IAsyncResult result = BeginCreate( sessionType, maxLocalGamers, maxGamers, null, null ); while (!result.IsCompleted) { if (!GamerServicesDispatcher.UpdateAsync()) { activeAction.IsCompleted = true; } } return(EndCreate(result)); }
public static void initializeGamerServices(BeatShift mainGame) { #if (XBOX || DEBUG) // Console.Write("Initializing networking (GamerServicesDispatcher)... "); //This block of code needs to be uncommented somewhere //Unfortunately it is very slow (5s) on my PC and delays //Startup significantly. try { GamerServicesDispatcher.WindowHandle = mainGame.Window.Handle; if (!GamerServicesDispatcher.IsInitialized) { GamerServicesDispatcher.Initialize(mainGame.Services); } } catch (Exception e) { //DO SOMTHING SENSIBLE HERE. //triggered if live services not running Console.WriteLine("Unable to initialize GamerServicesDispatcher."); } // Console.WriteLine(" ...done."); #endif }
/// <summary> /// Update /// </summary> public override void Update(GameTime gameTime) { // Process different phases. switch (phase) { case ConnectionPahse.EnsureSignedIn: GamerServicesDispatcher.Update(); break; case ConnectionPahse.FindSessions: GamerServicesDispatcher.Update(); if (asyncResult.IsCompleted) { AvailableNetworkSessionCollection sessions = NetworkSession.EndFind(asyncResult); if (sessions.Count > 0) { asyncResult = NetworkSession.BeginJoin(sessions[0], null, null); commandHost.EchoError("Connecting to the host..."); phase = ConnectionPahse.Joining; } else { commandHost.EchoError("Couldn't find a session."); phase = ConnectionPahse.None; } } break; case ConnectionPahse.Joining: GamerServicesDispatcher.Update(); if (asyncResult.IsCompleted) { NetworkSession = NetworkSession.EndJoin(asyncResult); NetworkSession.SessionEnded += new EventHandler <NetworkSessionEndedEventArgs>( NetworkSession_SessionEnded); OwnsNetworkSession = true; commandHost.EchoError("Connected to the host."); phase = ConnectionPahse.None; asyncResult = null; ConnectedToRemote(); } break; } // Update Network session. if (OwnsNetworkSession) { GamerServicesDispatcher.Update(); NetworkSession.Update(); if (NetworkSession != null) { // Process received packets. foreach (LocalNetworkGamer gamer in NetworkSession.LocalGamers) { while (gamer.IsDataAvailable) { NetworkGamer sender; gamer.ReceiveData(packetReader, out sender); if (!sender.IsLocal) { ProcessRecievedPacket(packetReader.ReadString()); } } } } } base.Update(gameTime); }
/// <summary> /// Initializes the XNA GamerServicesDispatcher /// </summary> public void Initialize() { GamerServicesDispatcher.WindowHandle = (IntPtr)_window["WINDOW"]; GamerServicesDispatcher.Initialize(_renderSystem); _engine.FrameStarted += Update; }
/// <summary> /// Updates the object and its contained resources. /// </summary> /// <param name="gameTime"/> public override void Update(GameTime gameTime) { GamerServicesDispatcher.Update(); base.Update(gameTime); }
public override void Initialize() { GamerServicesDispatcher.WindowHandle = Game.Window.Handle; GamerServicesDispatcher.Initialize(Game.Services); }
/// <summary> /// Helper method to call <see cref="GamerServicesDispatcher.Update"/> every frame. /// </summary> /// <param name="sender">object that invoked the event</param> /// <param name="e">per-frame specfic arguments</param> private void Update(object sender, FrameEventArgs e) { GamerServicesDispatcher.Update(); }