+using System;\r
+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.Graphics;\r
+\r
+namespace lobbyTest\r
+{\r
+ public class lobbyGUI\r
+ {\r
+ Texture2D background;\r
+ Texture2D spotLight;\r
+ Texture2D cs;\r
+\r
+ Vector2 backgroundPos;\r
+ Vector2 spotLightPos;\r
+ Vector2 spotLightCenter;\r
+ Vector2 csPos;\r
+\r
+ Vector2 zero;\r
+ Vector2 spotLightVelocity;\r
+\r
+ int MaxX;\r
+ int MinX;\r
+ int MaxY;\r
+ int MinY;\r
+\r
+ SpriteFont menuFont;\r
+ string selected;\r
+ Vector2 createGamePos;\r
+ string createGameText;\r
+ Vector2 findGamePos;\r
+ string findGameText;\r
+\r
+ KeyboardState previousKeyboardState;\r
+ KeyboardState currentKeyboardState;\r
+\r
+ private enum lobbyState\r
+ {\r
+ Welcome,\r
+ CreateGame,\r
+ FindGame,\r
+ Connected\r
+ }\r
+\r
+ lobbyState currentState;\r
+\r
+ public lobbyGUI()\r
+ {\r
+ currentState = lobbyState.Welcome;\r
+ }\r
+\r
+ public void LoadContent(ContentManager contentManager, GraphicsDeviceManager graphics)\r
+ {\r
+ background = contentManager.Load<Texture2D>("background");\r
+ spotLight = contentManager.Load<Texture2D>("spotlight");\r
+ cs = contentManager.Load<Texture2D>("cs");\r
+ backgroundPos = new Vector2(0f, 0f);\r
+ spotLightPos = new Vector2(100f, graphics.GraphicsDevice.Viewport.Height - 98);\r
+ spotLightCenter = new Vector2(800f, 800f);\r
+ spotLightVelocity = new Vector2(-100, 33);\r
+ csPos = new Vector2(10f, graphics.GraphicsDevice.Viewport.Height - 98);\r
+\r
+ zero = new Vector2(0, 0);\r
+\r
+ MaxX = graphics.GraphicsDevice.Viewport.Width;\r
+ MinX = 0;\r
+ MaxY = graphics.GraphicsDevice.Viewport.Height;\r
+ MinY = 100;\r
+\r
+ //menu fonts\r
+ menuFont = contentManager.Load<SpriteFont>("menuFont");\r
+ createGamePos = new Vector2(100f, MaxY / 3);\r
+ createGameText = "Create Game";\r
+ selected = createGameText;\r
+\r
+ findGamePos = new Vector2(100f, (MaxY / 3) + 60);\r
+ findGameText = "Find Game";\r
+ }\r
+\r
+ public void UnloadContent()\r
+ {\r
+ \r
+ }\r
+\r
+ public long Update(GameTime gameTime)\r
+ {\r
+ UpdateSpotLight(gameTime);\r
+ currentKeyboardState = Keyboard.GetState();\r
+ //check inputs\r
+ switch (currentState)\r
+ {\r
+ case lobbyState.Welcome:\r
+ if (selected == createGameText)\r
+ {\r
+ if (currentKeyboardState.IsKeyDown(Keys.Enter) && previousKeyboardState.IsKeyUp(Keys.Enter))\r
+ currentState = lobbyState.CreateGame;\r
+ if (currentKeyboardState.IsKeyDown(Keys.Down) || currentKeyboardState.IsKeyDown(Keys.Up))\r
+ selected = findGameText;\r
+ }\r
+ else\r
+ {\r
+ if (currentKeyboardState.IsKeyDown(Keys.Enter) && previousKeyboardState.IsKeyUp(Keys.Enter))\r
+ currentState = lobbyState.FindGame;\r
+ if (currentKeyboardState.IsKeyDown(Keys.Down) || currentKeyboardState.IsKeyDown(Keys.Up))\r
+ selected = createGameText;\r
+ }\r
+ break;\r
+ case lobbyState.CreateGame:\r
+\r
+ break;\r
+ case lobbyState.FindGame:\r
+\r
+ break;\r
+ case lobbyState.Connected:\r
+\r
+ break;\r
+\r
+ }\r
+ previousKeyboardState = Keyboard.GetState();\r
+\r
+ return 1;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Draws the lobby GUI. Has different states for difference menu configurations\r
+ /// </summary>\r
+ public long Draw(SpriteBatch spriteBatch)\r
+ {\r
+ spriteBatch.Draw(background, backgroundPos, null, Color.White, 0, zero, 0.5f, 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
+ switch (currentState)\r
+ {\r
+ case lobbyState.Welcome:\r
+ if (selected == createGameText)\r
+ spriteBatch.DrawString(menuFont, createGameText, createGamePos, Color.Red, 0, zero, 1f, SpriteEffects.None, 0.5f);\r
+ else\r
+ spriteBatch.DrawString(menuFont, createGameText, createGamePos, Color.Gray, 0, zero, 1f,SpriteEffects.None, 0.5f);\r
+ if (selected == findGameText)\r
+ spriteBatch.DrawString(menuFont, findGameText, findGamePos, Color.Red, 0, zero, 1f, SpriteEffects.None, 0.5f);\r
+ else\r
+ spriteBatch.DrawString(menuFont, findGameText, findGamePos, Color.Gray, 0, zero, 1f, SpriteEffects.None, 0.5f);\r
+ break;\r
+ case lobbyState.CreateGame:\r
+ \r
+ break;\r
+ case lobbyState.FindGame:\r
+ \r
+ break;\r
+ case lobbyState.Connected:\r
+ \r
+ break;\r
+ }\r
+\r
+ return 1;\r
+ }\r
+\r
+ private void UpdateSpotLight(GameTime gameTime)\r
+ {\r
+ spotLightPos = new Vector2(spotLightPos.X + spotLightVelocity.X * (float)gameTime.ElapsedGameTime.TotalSeconds,\r
+ spotLightPos.Y + spotLightVelocity.Y * (float)gameTime.ElapsedGameTime.TotalSeconds);\r
+\r
+ if (spotLightPos.X > MaxX || spotLightPos.X < MinX) //right or left wall\r
+ {\r
+ spotLightVelocity = new Vector2(spotLightVelocity.X * -1, spotLightVelocity.Y);\r
+ }\r
+ else if (spotLightPos.Y > MaxY || spotLightPos.Y < MinY) //top or bottom wall\r
+ {\r
+ spotLightVelocity = new Vector2(spotLightVelocity.X, spotLightVelocity.Y * -1);\r
+ }\r
+ }\r
+ }\r
+}\r