]> Dogcows Code - chaz/carfire/commitdiff
updated search for games screen, loading on second comp to test search
authorbrady <brady@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Sat, 20 Mar 2010 09:06:06 +0000 (09:06 +0000)
committerbrady <brady@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Sat, 20 Mar 2010 09:06:06 +0000 (09:06 +0000)
git-svn-id: https://bd85.net/svn/cs3505_group@16 92bb83a3-7c8f-8a45-bc97-515c4e399668

Project06/CS 3505 Project 06/CS 3505 Project 06/LobbyGUI.cs
Project06/CS 3505 Project 06/CS 3505 Project 06/NetworkGame.cs

index 0fe4ad1f2063606e654b86f8dae5a2a455aac4c2..516a85a1302e44abb64c5212d35d0d4bb692383b 100644 (file)
@@ -55,7 +55,9 @@ namespace CS_3505_Project_06
         KeyboardState currentKeyboardState;\r
 \r
         GamerCollection<LocalNetworkGamer> players;\r
-        \r
+        AvailableNetworkSessionCollection availableSessions;\r
+\r
+        int selectedSessionIndex;\r
 \r
         private enum lobbyState\r
         {\r
@@ -69,7 +71,9 @@ namespace CS_3505_Project_06
 \r
         public lobbyGUI()\r
         {\r
-            currentState = lobbyState.Welcome; \r
+            currentState = lobbyState.Welcome;\r
+            selectedSessionIndex = 0;\r
+            ready = false;\r
         }\r
 \r
         public void LoadContent(ContentManager contentManager, GraphicsDeviceManager graphics)\r
@@ -92,13 +96,14 @@ namespace CS_3505_Project_06
             MinY = 100;\r
 \r
             scale = MaxX / 1600f;\r
+\r
             //playerlist stuff\r
             checkedBox = contentManager.Load<Texture2D>("checkedBox");\r
             deselectBox = contentManager.Load<Texture2D>("deselectBox");\r
             emptySelectBox = contentManager.Load<Texture2D>("emptySelectBox");\r
             menuItem = contentManager.Load<Texture2D>("menuItem");\r
 \r
-            ready = false;\r
+            \r
 \r
             //menu fonts\r
             menuFont = contentManager.Load<SpriteFont>("menuFont");\r
@@ -112,7 +117,7 @@ namespace CS_3505_Project_06
             returnToMainPos = new Vector2(MaxX / 2, MaxY - 120);\r
             returnToMainText = "press [ X ] to return to main menu";\r
 \r
-\r
+            \r
         }\r
 \r
         public void UnloadContent()\r
@@ -126,6 +131,11 @@ namespace CS_3505_Project_06
             UpdateSpotLight(gameTime);\r
             currentKeyboardState = Keyboard.GetState();\r
 \r
+            if (networkGame.sessionExists())\r
+            {\r
+                players = networkGame.LocalGamers;\r
+            }\r
+\r
             //check inputs\r
             switch (currentState)\r
             {\r
@@ -145,12 +155,17 @@ namespace CS_3505_Project_06
                             selected = createGameText;\r
                     }\r
                     break;\r
+\r
                 case lobbyState.CreateGame:\r
                     if (currentKeyboardState.IsKeyDown(Keys.X) && previousKeyboardState.IsKeyUp(Keys.X))\r
                     {\r
                         currentState = lobbyState.Welcome;\r
                         ready = false;\r
-                        networkGame.LeaveSession();\r
+                        if (networkGame.sessionExists())\r
+                        {\r
+                            players = null;\r
+                            networkGame.LeaveSession();\r
+                        }\r
                     }\r
                     if (currentKeyboardState.IsKeyDown(Keys.Y) && previousKeyboardState.IsKeyUp(Keys.Y))\r
                     {\r
@@ -159,17 +174,28 @@ namespace CS_3505_Project_06
                         players = networkGame.LocalGamers;\r
                     }   \r
                     break;\r
+\r
                 case lobbyState.FindGame:\r
                     if (currentKeyboardState.IsKeyDown(Keys.X) && previousKeyboardState.IsKeyUp(Keys.X))\r
                     {\r
                         currentState = lobbyState.Welcome;\r
                         ready = false;\r
                     }\r
+                    availableSessions = networkGame.FindSessions();\r
 \r
                     break;\r
+\r
                 case lobbyState.Connected:\r
                     if (currentKeyboardState.IsKeyDown(Keys.X) && previousKeyboardState.IsKeyUp(Keys.X))\r
+                    {\r
+                        ready = false;\r
+                        if (networkGame.sessionExists())\r
+                        {\r
+                            players = null;\r
+                            networkGame.LeaveSession();\r
+                        }\r
                         currentState = lobbyState.Welcome;\r
+                    }\r
                     if (currentKeyboardState.IsKeyDown(Keys.R) && previousKeyboardState.IsKeyUp(Keys.R))\r
                         ready = true;\r
                     break;\r
@@ -210,14 +236,32 @@ namespace CS_3505_Project_06
                     spriteBatch.DrawString(menuFont, "X to return to main menu", new Vector2(MaxX /2 + 40, (MaxY / 3) + 2 * menuFont.LineSpacing), Color.White, 0f, zero, .6f, SpriteEffects.None, 0.5f);\r
 \r
                     break;\r
+\r
                 case lobbyState.FindGame:\r
                     spriteBatch.Draw(selectGameScreen, backgroundPos, null, Color.White, 0, zero, scale, SpriteEffects.None, 0);\r
-                    //spriteBatch.DrawString(menuFont, "Select Game", new Vector2(100, 100), Color.Gray, 0, zero, 1f, SpriteEffects.None, 0.5f);\r
+                    if(availableSessions == null)\r
+                        spriteBatch.DrawString(menuFont, "searching for available games ....", new Vector2(150, 100), Color.Gray, 0f, zero, .7f, SpriteEffects.None, 0.5f);\r
+                    else if (availableSessions.Count == 0)\r
+                        spriteBatch.DrawString(menuFont, "no games currently available, searching ....", new Vector2(150, 100), Color.Gray, 0f, zero, .7f, SpriteEffects.None, 0.5f);\r
+                    else\r
+                    {\r
+                        for (int sessionIndex = 0; sessionIndex < availableSessions.Count; sessionIndex++)\r
+                        {\r
+                            Color color = Color.Gray;\r
+\r
+                            if (sessionIndex == selectedSessionIndex)\r
+                                color = Color.Red;\r
 \r
-                    //spriteBatch.DrawString(menuFont, returnToMainText, returnToMainPos, Color.Gray, 0, new Vector2(180 , 0), .6f, SpriteEffects.None, 0.5f);\r
+                            spriteBatch.DrawString(menuFont, availableSessions[sessionIndex].HostGamertag, new Vector2(150, 100 + sessionIndex * menuFont.LineSpacing), color, 0f, zero, .7f, SpriteEffects.None, 0.5f);\r
+                            spriteBatch.DrawString(menuFont, availableSessions[sessionIndex].CurrentGamerCount + " / " + availableSessions[sessionIndex].OpenPublicGamerSlots, new Vector2(400, 300 + sessionIndex * menuFont.LineSpacing), color, 0f, zero, .7f, SpriteEffects.None, 0.5f);\r
+                            spriteBatch.DrawString(menuFont, availableSessions[sessionIndex].QualityOfService + "", new Vector2(350, 100 + sessionIndex * menuFont.LineSpacing), color, 0f, zero, .7f, SpriteEffects.None, 0.5f);\r
+                        }\r
+                    }\r
                     break;\r
+\r
                 case lobbyState.Connected:\r
                     DrawPlayerList(spriteBatch);\r
+                    spriteBatch.DrawString(menuFont, "Waiting for ready players...", new Vector2(MaxX / 2, MaxY / 2), Color.White, 0f, zero, .7f, SpriteEffects.None, 0.5f);\r
                     break;\r
             }\r
 \r
@@ -325,8 +369,6 @@ namespace CS_3505_Project_06
                     spriteBatch.DrawString(menuFont, players[g].Gamertag, new Vector2(topOfList.X + 10, topOfList.Y + 10 + 65*g), Color.White, 0f, zero, .75f, SpriteEffects.None, 1f);\r
                 }\r
             }\r
-\r
-            //top player\r
         }\r
     }\r
 }\r
index c8cc60c907f3be7788c4c5983ffda2bbed1bc1c5..b27393201e3b793331abb547d6208c5654bed132 100644 (file)
@@ -98,7 +98,7 @@ namespace CS_3505_Project_06
         //    -Brady\r
         public bool sessionExists()\r
         {\r
-            return mNetworkSession == null;\r
+            return mNetworkSession != null;\r
         }\r
 \r
         public AvailableNetworkSessionCollection FindSessions()\r
This page took 0.031159 seconds and 4 git commands to generate.