]> Dogcows Code - chaz/carfire/commitdiff
Added to functionality of gui. Also added 2 methods I needed in NetworkGame, comments...
authorbrady <brady@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Sat, 20 Mar 2010 07:03:39 +0000 (07:03 +0000)
committerbrady <brady@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Sat, 20 Mar 2010 07:03:39 +0000 (07:03 +0000)
git-svn-id: https://bd85.net/svn/cs3505_group@15 92bb83a3-7c8f-8a45-bc97-515c4e399668

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

index 2d8fb75b25043d3592a3a3b25ecaa7ab81e423e9..c6f21f66ea14396d518c0abcdad00476bfa1789a 100644 (file)
@@ -40,6 +40,7 @@ namespace CS_3505_Project_06
             lobby = new lobbyGUI();\r
             deterministicGame = new TestHarness();\r
             networkGame = new NetworkGame(lobby, deterministicGame);\r
+            Components.Add(new GamerServicesComponent(this));\r
         }\r
 \r
         /// <summary>\r
index b902822106940bb69c21a4afef6b9b5b19027245..0fe4ad1f2063606e654b86f8dae5a2a455aac4c2 100644 (file)
@@ -2,10 +2,13 @@
 using System.Collections.Generic;\r
 using System.Linq;\r
 using System.Text;\r
-using Microsoft.Xna.Framework.Content;\r
-using Microsoft.Xna.Framework.Input;\r
-using Microsoft.Xna.Framework;\r
+using Microsoft.Xna.Framework.Net;\r
+using System.Diagnostics;\r
+using Microsoft.Xna.Framework.GamerServices;\r
 using Microsoft.Xna.Framework.Graphics;\r
+using Microsoft.Xna.Framework;\r
+using Microsoft.Xna.Framework.Input;\r
+using Microsoft.Xna.Framework.Content;\r
 \r
 namespace CS_3505_Project_06\r
 {\r
@@ -51,6 +54,9 @@ namespace CS_3505_Project_06
         KeyboardState previousKeyboardState;\r
         KeyboardState currentKeyboardState;\r
 \r
+        GamerCollection<LocalNetworkGamer> players;\r
+        \r
+\r
         private enum lobbyState\r
         {\r
             Welcome,\r
@@ -63,7 +69,7 @@ namespace CS_3505_Project_06
 \r
         public lobbyGUI()\r
         {\r
-            currentState = lobbyState.Welcome;\r
+            currentState = lobbyState.Welcome; \r
         }\r
 \r
         public void LoadContent(ContentManager contentManager, GraphicsDeviceManager graphics)\r
@@ -116,8 +122,10 @@ namespace CS_3505_Project_06
 \r
         public long Update(GameTime gameTime, NetworkGame networkGame)\r
         {\r
+            \r
             UpdateSpotLight(gameTime);\r
             currentKeyboardState = Keyboard.GetState();\r
+\r
             //check inputs\r
             switch (currentState)\r
             {\r
@@ -142,9 +150,14 @@ namespace CS_3505_Project_06
                     {\r
                         currentState = lobbyState.Welcome;\r
                         ready = false;\r
+                        networkGame.LeaveSession();\r
                     }\r
-                    if (currentKeyboardState.IsKeyDown(Keys.R) && previousKeyboardState.IsKeyUp(Keys.R))\r
-                        ready = true;\r
+                    if (currentKeyboardState.IsKeyDown(Keys.Y) && previousKeyboardState.IsKeyUp(Keys.Y))\r
+                    {\r
+                        currentState = lobbyState.Connected;\r
+                        networkGame.CreateSession(4);\r
+                        players = networkGame.LocalGamers;\r
+                    }   \r
                     break;\r
                 case lobbyState.FindGame:\r
                     if (currentKeyboardState.IsKeyDown(Keys.X) && previousKeyboardState.IsKeyUp(Keys.X))\r
@@ -175,6 +188,7 @@ namespace CS_3505_Project_06
             spriteBatch.Draw(background, backgroundPos, null, Color.White, 0, zero, scale, SpriteEffects.None, 0);\r
             spriteBatch.Draw(cs, csPos, null, Color.White, 0, zero, 0.5f, SpriteEffects.None, 0);\r
             spriteBatch.Draw(spotLight, spotLightPos, null, Color.White, 0, spotLightCenter, 1f, SpriteEffects.None, 0);\r
+\r
             switch (currentState)\r
             {\r
                 case lobbyState.Welcome:\r
@@ -191,6 +205,9 @@ namespace CS_3505_Project_06
                 \r
                 case lobbyState.CreateGame:\r
                     DrawPlayerList(spriteBatch);\r
+                    spriteBatch.DrawString(menuFont, "You are now the Host!", new Vector2(MaxX / 2, MaxY / 3), Color.White, 0f, zero, .7f, SpriteEffects.None, 0.5f);\r
+                    spriteBatch.DrawString(menuFont, "press: Y to continue", new Vector2(MaxX /2, (MaxY / 3) + menuFont.LineSpacing), Color.White, 0f, zero, .6f, SpriteEffects.None, 0.5f);\r
+                    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
                 case lobbyState.FindGame:\r
@@ -226,12 +243,22 @@ namespace CS_3505_Project_06
         private void DrawPlayerList(SpriteBatch spriteBatch)\r
         {\r
             \r
+            //reference point\r
             Vector2 topOfList = new Vector2(MaxX / 8, MaxY / 4);\r
+\r
+            //command info\r
             spriteBatch.DrawString(menuFont, "Current Players", new Vector2(topOfList.X + 15, topOfList.Y - 25), Color.White);\r
+            spriteBatch.DrawString(menuFont, "Command Options:          to mark your self as ready", new Vector2(20, 20), Color.Gray, 0f, zero, .6f, SpriteEffects.None, 1f);\r
+            spriteBatch.DrawString(menuFont, "type players # to toggle chat", new Vector2(175, 40), Color.Gray, 0f, zero, .6f, SpriteEffects.None, 1f);\r
+            spriteBatch.DrawString(menuFont, "return to main menu", new Vector2(175, 60), Color.Gray, 0f, zero, .6f, SpriteEffects.None, 1f);\r
+            spriteBatch.DrawString(menuFont, "R", new Vector2(145, 20), Color.DarkGreen, 0f, zero, .6f, SpriteEffects.None, 1f);\r
+            spriteBatch.DrawString(menuFont, "#", new Vector2(145, 40), Color.DarkGreen, 0f, zero, .6f, SpriteEffects.None, 1f);\r
+            spriteBatch.DrawString(menuFont, "X", new Vector2(145, 60), Color.DarkGreen, 0f, zero, .6f, SpriteEffects.None, 1f);\r
+            \r
             \r
-            //top player\r
             spriteBatch.Draw(menuItem, topOfList, null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
-            spriteBatch.DrawString(menuFont, "****Player 1****", new Vector2(topOfList.X + 10, topOfList.Y + 10), Color.White, 0f, zero, .75f, SpriteEffects.None, 1f);\r
+\r
+            //player 1\r
             spriteBatch.DrawString(menuFont, "Ready", new Vector2(topOfList.X + 5, topOfList.Y + 45), Color.DarkGray, 0f, zero, .6f, SpriteEffects.None, 1f);\r
             if(!ready)\r
                 spriteBatch.Draw(emptySelectBox, new Vector2(topOfList.X - 32, topOfList.Y + 35), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
@@ -247,7 +274,6 @@ namespace CS_3505_Project_06
 \r
             //player 2\r
             spriteBatch.Draw(menuItem, new Vector2(topOfList.X, topOfList.Y + 65), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
-            spriteBatch.DrawString(menuFont, "****Player 1****", new Vector2(topOfList.X + 10, topOfList.Y + 75), Color.White, 0f, zero, .75f, SpriteEffects.None, 1f);\r
             spriteBatch.DrawString(menuFont, "Ready", new Vector2(topOfList.X + 5, topOfList.Y + 110), Color.DarkGray, 0f, zero, .6f, SpriteEffects.None, 1f);\r
             if (!ready)\r
                 spriteBatch.Draw(emptySelectBox, new Vector2(topOfList.X - 32, topOfList.Y + 100), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
@@ -263,7 +289,6 @@ namespace CS_3505_Project_06
             \r
             //player 3\r
             spriteBatch.Draw(menuItem, new Vector2(topOfList.X, topOfList.Y + 130), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
-            spriteBatch.DrawString(menuFont, "****Player 1****", new Vector2(topOfList.X + 10, topOfList.Y + 140), Color.White, 0f, zero, .75f, SpriteEffects.None, 1f);\r
             spriteBatch.DrawString(menuFont, "Ready", new Vector2(topOfList.X + 5, topOfList.Y + 175), Color.DarkGray, 0f, zero, .6f, SpriteEffects.None, 1f);\r
             if (!ready)\r
                 spriteBatch.Draw(emptySelectBox, new Vector2(topOfList.X - 32, topOfList.Y + 165), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
@@ -279,7 +304,6 @@ namespace CS_3505_Project_06
             \r
             //player 4\r
             spriteBatch.Draw(menuItem, new Vector2(topOfList.X, topOfList.Y + 195), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
-            spriteBatch.DrawString(menuFont, "****Player 1****", new Vector2(topOfList.X + 10, topOfList.Y + 205), Color.White, 0f, zero, .75f, SpriteEffects.None, 1f);\r
             spriteBatch.DrawString(menuFont, "Ready", new Vector2(topOfList.X + 5, topOfList.Y + 240), Color.DarkGray, 0f, zero, .6f, SpriteEffects.None, 1f);\r
             if (!ready)\r
                 spriteBatch.Draw(emptySelectBox, new Vector2(topOfList.X - 32, topOfList.Y + 230), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
@@ -292,6 +316,17 @@ namespace CS_3505_Project_06
             else\r
                 spriteBatch.Draw(checkedBox, new Vector2(topOfList.X + 218, topOfList.Y + 225), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
             \r
+            \r
+            //draw player names\r
+            if (players != null)\r
+            {\r
+                for (int g = 0; g < players.Count; g++)\r
+                {\r
+                    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 abe36ba4a4d4ca1dcd6d84affc91fbad5766960e..c8cc60c907f3be7788c4c5983ffda2bbed1bc1c5 100644 (file)
@@ -59,7 +59,7 @@ namespace CS_3505_Project_06
         }\r
 \r
 \r
-        LocalNetworkGamer LocalGamer\r
+        public LocalNetworkGamer LocalGamer\r
         {\r
             get\r
             {\r
@@ -67,8 +67,18 @@ namespace CS_3505_Project_06
             }\r
         }\r
 \r
+        // I added this as I needed a way to display all gamers not just the first gamer\r
+        //    -Brady\r
+        public GamerCollection<LocalNetworkGamer> LocalGamers\r
+        {\r
+            get\r
+            {\r
+                return mNetworkSession.LocalGamers;\r
+            }\r
+        }\r
+\r
 \r
-        NetworkSession CreateSession()\r
+        public NetworkSession CreateSession()\r
         {\r
             return CreateSession(mGame.MaximumSupportedPlayers);\r
         }\r
@@ -84,6 +94,12 @@ namespace CS_3505_Project_06
             return mNetworkSession;\r
         }\r
 \r
+        // added so I can test if sessionExists and thus be able to call things on NetworkGame safely\r
+        //    -Brady\r
+        public bool sessionExists()\r
+        {\r
+            return mNetworkSession == null;\r
+        }\r
 \r
         public AvailableNetworkSessionCollection FindSessions()\r
         {\r
This page took 0.038539 seconds and 4 git commands to generate.