Développement XNA pour la XBox et le PC
252
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
}
protected override void Update(GameTime gameTime)
{
if ((Keyboard.GetState().IsKeyDown(Keys.C) || GamePad.GetState
➥(PlayerIndex.One).IsButtonDown(Buttons.A)) && session == null)
session = NetworkSession.Create(NetworkSessionType.SystemLink, 2, 31);
if ((Keyboard.GetState().IsKeyDown(Keys.S) || GamePad.GetState
➥(PlayerIndex.One).IsButtonDown(Buttons.B)) &&
➥SignedInGamer.SignedInGamers.Count != 0 && session == null)
{
availableSessions = NetworkSession.Find(NetworkSessionType.SystemLink,
➥2, null);
if (availableSessions != null && availableSessions.Count > 0)
session = NetworkSession.Join(availableSessions[0]);
}
if (session != null)
{
if (session.IsHost)
Window.Title = "Je suis le serveur";
else
Window.Title = "Je suis client sur la partie de " +
➥session.Host.ToString();
session.Update();
}
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
base.Draw(gameTime);
}
}
Figure 11-8
Cette instance du jeu est correctement connectée à une partie en réseau
=Labat FM.book Page 252 Vendredi, 19. juin 2009 4:01 16
252
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
}
protected override void Update(GameTime gameTime)
{
if ((Keyboard.GetState().IsKeyDown(Keys.C) || GamePad.GetState
➥(PlayerIndex.One).IsButtonDown(Buttons.A)) && session == null)
session = NetworkSession.Create(NetworkSessionType.SystemLink, 2, 31);
if ((Keyboard.GetState().IsKeyDown(Keys.S) || GamePad.GetState
➥(PlayerIndex.One).IsButtonDown(Buttons.B)) &&
➥SignedInGamer.SignedInGamers.Count != 0 && session == null)
{
availableSessions = NetworkSession.Find(NetworkSessionType.SystemLink,
➥2, null);
if (availableSessions != null && availableSessions.Count > 0)
session = NetworkSession.Join(availableSessions[0]);
}
if (session != null)
{
if (session.IsHost)
Window.Title = "Je suis le serveur";
else
Window.Title = "Je suis client sur la partie de " +
➥session.Host.ToString();
session.Update();
}
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
base.Draw(gameTime);
}
}
Figure 11-8
Cette instance du jeu est correctement connectée à une partie en réseau
=Labat FM.book Page 252 Vendredi, 19. juin 2009 4:01 16
