--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<!--\r
+This file contains an xml description of a font, and will be read by the XNA\r
+Framework Content Pipeline. Follow the comments to customize the appearance\r
+of the font in your game, and to change the characters which are available to draw\r
+with.\r
+-->\r
+<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">\r
+ <Asset Type="Graphics:FontDescription">\r
+\r
+ <!--\r
+ Modify this string to change the font that will be imported.\r
+ -->\r
+ <FontName>Times New Roman</FontName>\r
+\r
+ <!--\r
+ Size is a float value, measured in points. Modify this value to change\r
+ the size of the font.\r
+ -->\r
+ <Size>18</Size>\r
+\r
+ <!--\r
+ Spacing is a float value, measured in pixels. Modify this value to change\r
+ the amount of spacing in between characters.\r
+ -->\r
+ <Spacing>0</Spacing>\r
+\r
+ <!--\r
+ UseKerning controls the layout of the font. If this value is true, kerning information\r
+ will be used when placing characters.\r
+ -->\r
+ <UseKerning>true</UseKerning>\r
+\r
+ <!--\r
+ Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",\r
+ and "Bold, Italic", and are case sensitive.\r
+ -->\r
+ <Style>Bold</Style>\r
+\r
+ <!--\r
+ If you uncomment this line, the default character will be substituted if you draw\r
+ or measure text that contains characters which were not included in the font.\r
+ -->\r
+ <!-- <DefaultCharacter>*</DefaultCharacter> -->\r
+\r
+ <!--\r
+ CharacterRegions control what letters are available in the font. Every\r
+ character from Start to End will be built and made available for drawing. The\r
+ default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin\r
+ character set. The characters are ordered according to the Unicode standard.\r
+ See the documentation for more information.\r
+ -->\r
+ <CharacterRegions>\r
+ <CharacterRegion>\r
+ <Start> </Start>\r
+ <End>~</End>\r
+ </CharacterRegion>\r
+ </CharacterRegions>\r
+ </Asset>\r
+</XnaContent>\r
GraphicsDeviceManager graphics;\r
SpriteBatch spriteBatch;\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
+ lobbyGUI lbGui;\r
\r
public Game1()\r
{\r
// TODO: Add your initialization logic here\r
graphics.PreferredBackBufferWidth = 800;\r
graphics.PreferredBackBufferWidth = 600;\r
+ lbGui = new lobbyGUI();\r
base.Initialize();\r
}\r
\r
{\r
// Create a new SpriteBatch, which can be used to draw textures.\r
spriteBatch = new SpriteBatch(GraphicsDevice);\r
- background = Content.Load<Texture2D>("background");\r
- spotLight = Content.Load<Texture2D>("spotlight");\r
- cs = Content.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
- // TODO: use this.Content to load your game content here\r
+ lbGui.LoadContent(Content, graphics);\r
+ \r
}\r
\r
/// <summary>\r
this.Exit();\r
\r
// TODO: Add your update logic here\r
- UpdateSpotLight(gameTime);\r
+ lbGui.Update(gameTime);\r
+ \r
base.Update(gameTime);\r
}\r
\r
{\r
GraphicsDevice.Clear(Color.CornflowerBlue);\r
spriteBatch.Begin(SpriteBlendMode.AlphaBlend);\r
- // TODO: Add your drawing code here\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
\r
+ lbGui.Draw(spriteBatch);\r
+ \r
spriteBatch.End();\r
base.Draw(gameTime);\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
}\r
--- /dev/null
+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