From: Charles Date: Sat, 3 Apr 2010 02:54:49 +0000 (+0000) Subject: fixed problems with the join-game screen; can now join one of up to four games listed, X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=e4d9151151e2ef64c6b26cf2f4867734c6b53ee7;p=chaz%2Fcarfire fixed problems with the join-game screen; can now join one of up to four games listed, and fixed the bug which made it pick the first game every time. git-svn-id: https://bd85.net/svn/cs3505_group@51 92bb83a3-7c8f-8a45-bc97-515c4e399668 --- diff --git a/Project06/CS 3505 Project 06/CS 3505 Project 06/LobbyGUI.cs b/Project06/CS 3505 Project 06/CS 3505 Project 06/LobbyGUI.cs index 8fd3db8..74bc9a7 100644 --- a/Project06/CS 3505 Project 06/CS 3505 Project 06/LobbyGUI.cs +++ b/Project06/CS 3505 Project 06/CS 3505 Project 06/LobbyGUI.cs @@ -269,22 +269,27 @@ namespace CS_3505_Project_06 currentState = lobbyState.FindGame; else if (availableSessions != null && availableSessions.Count > 0) { - if (currentKeyboardState.IsKeyDown(Keys.D1) && previousKeyboardState.IsKeyUp(Keys.D1)) + if (currentKeyboardState.IsKeyDown(Keys.D1) && previousKeyboardState.IsKeyUp(Keys.D1) && availableSessions.Count > 0) { networkGame.JoinSession(availableSessions[0], JoinedSession); - currentState = lobbyState.JoiningGame; - - availableSessions.Dispose(); - availableSessions = null; } - if (currentKeyboardState.IsKeyDown(Keys.D2) && previousKeyboardState.IsKeyUp(Keys.D2)) + else if (currentKeyboardState.IsKeyDown(Keys.D2) && previousKeyboardState.IsKeyUp(Keys.D2) && availableSessions.Count > 1) { - networkGame.JoinSession(availableSessions[0], JoinedSession); - currentState = lobbyState.JoiningGame; - - availableSessions.Dispose(); - availableSessions = null; + networkGame.JoinSession(availableSessions[1], JoinedSession); + } + else if (currentKeyboardState.IsKeyDown(Keys.D3) && previousKeyboardState.IsKeyUp(Keys.D3) && availableSessions.Count > 2) + { + networkGame.JoinSession(availableSessions[2], JoinedSession); } + else if (currentKeyboardState.IsKeyDown(Keys.D4) && previousKeyboardState.IsKeyUp(Keys.D4) && availableSessions.Count > 3) + { + networkGame.JoinSession(availableSessions[3], JoinedSession); + } + + currentState = lobbyState.JoiningGame; + + availableSessions.Dispose(); + availableSessions = null; } break;