Lets override the Draw function, so that we can render the connected players:
/// <summary>
/// Draw the lobby screen.
/// </summary>
/// <param name="gameTime"></param>
public override void Draw(Microsoft.Xna.Framework.GameTime gameTime)
{
ScreenManager.SpriteBatch.Begin();
// Display all the connected players
if (networkSession != null)
{
ScreenManager.SpriteBatch.End();
base.Draw(gameTime);
}// Display all the connected players
if (networkSession != null)
{
for (int i = 0; i < networkSession.AllGamers.Count; i++)
{
}{
// Display the players gamer tag followed by true or false (true = ready to play)
ScreenManager.SpriteBatch.DrawString(ScreenManager.Font, networkSession.AllGamers[i].Gamertag + " Ready: "
+ networkSession.AllGamers[i].IsReady, new Vector2(500, 120 + (i * 20)), Color.White);
}ScreenManager.SpriteBatch.DrawString(ScreenManager.Font, networkSession.AllGamers[i].Gamertag + " Ready: "
+ networkSession.AllGamers[i].IsReady, new Vector2(500, 120 + (i * 20)), Color.White);
ScreenManager.SpriteBatch.End();
base.Draw(gameTime);
That was pretty simple, now if you try it out you should see your XBox Live GamerTag displayed with a True next to it, next we need to allow players to join this session so that we can test that it displays all connected GamerTags and that it actually updates the display correctly when the player is ready sets there status to ready to play.

No comments:
Post a Comment