2 using System.Collections.Generic;
5 using Microsoft.Xna.Framework.Content;
6 using Microsoft.Xna.Framework.Input;
7 using Microsoft.Xna.Framework;
8 using Microsoft.Xna.Framework.Graphics;
19 Texture2D selectGameScreen;
21 Vector2 backgroundPos;
23 Vector2 spotLightCenter;
27 Vector2 spotLightVelocity;
35 Texture2D deselectBox;
36 Texture2D emptySelectBox;
43 Vector2 createGamePos;
44 string createGameText;
48 Vector2 returnToMainPos;
49 string returnToMainText;
51 KeyboardState previousKeyboardState;
52 KeyboardState currentKeyboardState;
54 private enum lobbyState
62 lobbyState currentState;
66 currentState = lobbyState.Welcome;
69 public void LoadContent(ContentManager contentManager, GraphicsDeviceManager graphics)
71 background = contentManager.Load<Texture2D>("background");
72 spotLight = contentManager.Load<Texture2D>("spotlight");
73 cs = contentManager.Load<Texture2D>("cs");
74 selectGameScreen = contentManager.Load<Texture2D>("selectGameScreen");
75 backgroundPos = new Vector2(0f, 0f);
76 spotLightPos = new Vector2(100f, graphics.GraphicsDevice.Viewport.Height - 98);
77 spotLightCenter = new Vector2(800f, 800f);
78 spotLightVelocity = new Vector2(-100, 33);
79 csPos = new Vector2(10f, graphics.GraphicsDevice.Viewport.Height - 98);
81 zero = new Vector2(0, 0);
83 MaxX = graphics.GraphicsDevice.Viewport.Width;
85 MaxY = graphics.GraphicsDevice.Viewport.Height;
90 checkedBox = contentManager.Load<Texture2D>("checkedBox");
91 deselectBox = contentManager.Load<Texture2D>("deselectBox");
92 emptySelectBox = contentManager.Load<Texture2D>("emptySelectBox");
93 menuItem = contentManager.Load<Texture2D>("menuItem");
98 menuFont = contentManager.Load<SpriteFont>("menuFont");
99 createGamePos = new Vector2(100f, MaxY / 3);
100 createGameText = "Create Game";
101 selected = createGameText;
103 findGamePos = new Vector2(100f, (MaxY / 3) + 60);
104 findGameText = "Find Game";
106 returnToMainPos = new Vector2(MaxX / 2, MaxY - 120);
107 returnToMainText = "press [ X ] to return to main menu";
112 public void UnloadContent()
117 public long Update(GameTime gameTime)
119 UpdateSpotLight(gameTime);
120 currentKeyboardState = Keyboard.GetState();
122 switch (currentState)
124 case lobbyState.Welcome:
125 if (selected == createGameText)
127 if (currentKeyboardState.IsKeyDown(Keys.Enter) && previousKeyboardState.IsKeyUp(Keys.Enter))
128 currentState = lobbyState.CreateGame;
129 if (currentKeyboardState.IsKeyDown(Keys.Down))
130 selected = findGameText;
134 if (currentKeyboardState.IsKeyDown(Keys.Enter) && previousKeyboardState.IsKeyUp(Keys.Enter))
135 currentState = lobbyState.FindGame;
136 if (currentKeyboardState.IsKeyDown(Keys.Up))
137 selected = createGameText;
140 case lobbyState.CreateGame:
141 if (currentKeyboardState.IsKeyDown(Keys.X) && previousKeyboardState.IsKeyUp(Keys.X))
143 currentState = lobbyState.Welcome;
146 if (currentKeyboardState.IsKeyDown(Keys.R) && previousKeyboardState.IsKeyUp(Keys.R))
149 case lobbyState.FindGame:
150 if (currentKeyboardState.IsKeyDown(Keys.X) && previousKeyboardState.IsKeyUp(Keys.X))
152 currentState = lobbyState.Welcome;
157 case lobbyState.Connected:
158 if (currentKeyboardState.IsKeyDown(Keys.X) && previousKeyboardState.IsKeyUp(Keys.X))
159 currentState = lobbyState.Welcome;
160 if (currentKeyboardState.IsKeyDown(Keys.R) && previousKeyboardState.IsKeyUp(Keys.R))
165 previousKeyboardState = Keyboard.GetState();
171 /// Draws the lobby GUI. Has different states for difference menu configurations
173 public long Draw(SpriteBatch spriteBatch)
175 spriteBatch.Draw(background, backgroundPos, null, Color.White, 0, zero, scale, SpriteEffects.None, 0);
176 spriteBatch.Draw(cs, csPos, null, Color.White, 0, zero, 0.5f, SpriteEffects.None, 0);
177 spriteBatch.Draw(spotLight, spotLightPos, null, Color.White, 0, spotLightCenter, 1f, SpriteEffects.None, 0);
178 switch (currentState)
180 case lobbyState.Welcome:
181 spriteBatch.DrawString(menuFont, "press [ Home ] to login", new Vector2(350, 20), Color.LightGray, 0f, zero, .6f, SpriteEffects.None, 0.5f);
182 if (selected == createGameText)
183 spriteBatch.DrawString(menuFont, createGameText, createGamePos, Color.Red, 0, zero, 1f, SpriteEffects.None, 0.5f);
185 spriteBatch.DrawString(menuFont, createGameText, createGamePos, Color.Gray, 0, zero, 1f,SpriteEffects.None, 0.5f);
186 if (selected == findGameText)
187 spriteBatch.DrawString(menuFont, findGameText, findGamePos, Color.Red, 0, zero, 1f, SpriteEffects.None, 0.5f);
189 spriteBatch.DrawString(menuFont, findGameText, findGamePos, Color.Gray, 0, zero, 1f, SpriteEffects.None, 0.5f);
192 case lobbyState.CreateGame:
193 DrawPlayerList(spriteBatch);
196 case lobbyState.FindGame:
197 spriteBatch.Draw(selectGameScreen, backgroundPos, null, Color.White, 0, zero, scale, SpriteEffects.None, 0);
198 //spriteBatch.DrawString(menuFont, "Select Game", new Vector2(100, 100), Color.Gray, 0, zero, 1f, SpriteEffects.None, 0.5f);
200 //spriteBatch.DrawString(menuFont, returnToMainText, returnToMainPos, Color.Gray, 0, new Vector2(180 , 0), .6f, SpriteEffects.None, 0.5f);
202 case lobbyState.Connected:
203 DrawPlayerList(spriteBatch);
210 private void UpdateSpotLight(GameTime gameTime)
212 spotLightPos = new Vector2(spotLightPos.X + spotLightVelocity.X * (float)gameTime.ElapsedGameTime.TotalSeconds,
213 spotLightPos.Y + spotLightVelocity.Y * (float)gameTime.ElapsedGameTime.TotalSeconds);
215 if (spotLightPos.X > MaxX || spotLightPos.X < MinX) //right or left wall
217 spotLightVelocity = new Vector2(spotLightVelocity.X * -1, spotLightVelocity.Y);
219 else if (spotLightPos.Y > MaxY || spotLightPos.Y < MinY) //top or bottom wall
221 spotLightVelocity = new Vector2(spotLightVelocity.X, spotLightVelocity.Y * -1);
226 private void DrawPlayerList(SpriteBatch spriteBatch)
229 Vector2 topOfList = new Vector2(MaxX / 8, MaxY / 4);
230 spriteBatch.DrawString(menuFont, "Current Players", new Vector2(topOfList.X + 15, topOfList.Y - 25), Color.White);
233 spriteBatch.Draw(menuItem, topOfList, null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
234 spriteBatch.DrawString(menuFont, "****Player 1****", new Vector2(topOfList.X + 10, topOfList.Y + 10), Color.White, 0f, zero, .75f, SpriteEffects.None, 1f);
235 spriteBatch.DrawString(menuFont, "Ready", new Vector2(topOfList.X + 5, topOfList.Y + 45), Color.DarkGray, 0f, zero, .6f, SpriteEffects.None, 1f);
237 spriteBatch.Draw(emptySelectBox, new Vector2(topOfList.X - 32, topOfList.Y + 35), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
239 spriteBatch.Draw(checkedBox, new Vector2(topOfList.X - 32, topOfList.Y + 30), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
241 spriteBatch.DrawString(menuFont, "Chat with", new Vector2(topOfList.X + 152, topOfList.Y + 45), Color.DarkGray, 0f, zero, .6f, SpriteEffects.None, 1f);
242 Boolean chatwith = false; // change to reflect info from network, move to update and create one for each player
244 spriteBatch.Draw(deselectBox, new Vector2(topOfList.X +218, topOfList.Y + 35), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
246 spriteBatch.Draw(checkedBox, new Vector2(topOfList.X + 218, topOfList.Y + 30), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
249 spriteBatch.Draw(menuItem, new Vector2(topOfList.X, topOfList.Y + 65), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
250 spriteBatch.DrawString(menuFont, "****Player 1****", new Vector2(topOfList.X + 10, topOfList.Y + 75), Color.White, 0f, zero, .75f, SpriteEffects.None, 1f);
251 spriteBatch.DrawString(menuFont, "Ready", new Vector2(topOfList.X + 5, topOfList.Y + 110), Color.DarkGray, 0f, zero, .6f, SpriteEffects.None, 1f);
253 spriteBatch.Draw(emptySelectBox, new Vector2(topOfList.X - 32, topOfList.Y + 100), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
255 spriteBatch.Draw(checkedBox, new Vector2(topOfList.X - 32, topOfList.Y + 95), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
257 spriteBatch.DrawString(menuFont, "Chat with", new Vector2(topOfList.X + 152, topOfList.Y + 110), Color.DarkGray, 0f, zero, .6f, SpriteEffects.None, 1f);
258 // change to reflect info from network
260 spriteBatch.Draw(deselectBox, new Vector2(topOfList.X + 218, topOfList.Y + 100), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
262 spriteBatch.Draw(checkedBox, new Vector2(topOfList.X + 218, topOfList.Y + 95), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
265 spriteBatch.Draw(menuItem, new Vector2(topOfList.X, topOfList.Y + 130), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
266 spriteBatch.DrawString(menuFont, "****Player 1****", new Vector2(topOfList.X + 10, topOfList.Y + 140), Color.White, 0f, zero, .75f, SpriteEffects.None, 1f);
267 spriteBatch.DrawString(menuFont, "Ready", new Vector2(topOfList.X + 5, topOfList.Y + 175), Color.DarkGray, 0f, zero, .6f, SpriteEffects.None, 1f);
269 spriteBatch.Draw(emptySelectBox, new Vector2(topOfList.X - 32, topOfList.Y + 165), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
271 spriteBatch.Draw(checkedBox, new Vector2(topOfList.X - 32, topOfList.Y + 160), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
273 spriteBatch.DrawString(menuFont, "Chat with", new Vector2(topOfList.X + 152, topOfList.Y + 175), Color.DarkGray, 0f, zero, .6f, SpriteEffects.None, 1f);
276 spriteBatch.Draw(deselectBox, new Vector2(topOfList.X + 218, topOfList.Y + 165), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
278 spriteBatch.Draw(checkedBox, new Vector2(topOfList.X + 218, topOfList.Y + 160), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
281 spriteBatch.Draw(menuItem, new Vector2(topOfList.X, topOfList.Y + 195), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
282 spriteBatch.DrawString(menuFont, "****Player 1****", new Vector2(topOfList.X + 10, topOfList.Y + 205), Color.White, 0f, zero, .75f, SpriteEffects.None, 1f);
283 spriteBatch.DrawString(menuFont, "Ready", new Vector2(topOfList.X + 5, topOfList.Y + 240), Color.DarkGray, 0f, zero, .6f, SpriteEffects.None, 1f);
285 spriteBatch.Draw(emptySelectBox, new Vector2(topOfList.X - 32, topOfList.Y + 230), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
287 spriteBatch.Draw(checkedBox, new Vector2(topOfList.X - 32, topOfList.Y + 225), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
289 spriteBatch.DrawString(menuFont, "Chat with", new Vector2(topOfList.X + 152, topOfList.Y + 240), Color.DarkGray, 0f, zero, .6f, SpriteEffects.None, 1f);
291 spriteBatch.Draw(deselectBox, new Vector2(topOfList.X + 218, topOfList.Y + 230), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);
293 spriteBatch.Draw(checkedBox, new Vector2(topOfList.X + 218, topOfList.Y + 225), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);