]> Dogcows Code - chaz/carfire/commitdiff
Added in lobby from last project. Refactored to account for name changes. I will...
authorbrady <brady@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Sun, 11 Apr 2010 07:45:43 +0000 (07:45 +0000)
committerbrady <brady@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Sun, 11 Apr 2010 07:45:43 +0000 (07:45 +0000)
git-svn-id: https://bd85.net/svn/cs3505_group@60 92bb83a3-7c8f-8a45-bc97-515c4e399668

12 files changed:
CarFire/CarFire/CarFire/Content/Content.contentproj
CarFire/CarFire/CarFire/Content/InstructionFont.spritefont [new file with mode: 0644]
CarFire/CarFire/CarFire/Content/background.png [new file with mode: 0644]
CarFire/CarFire/CarFire/Content/checkedBox.png [new file with mode: 0644]
CarFire/CarFire/CarFire/Content/cs.png [new file with mode: 0644]
CarFire/CarFire/CarFire/Content/deselectBox.png [new file with mode: 0644]
CarFire/CarFire/CarFire/Content/emptySelectBox.png [new file with mode: 0644]
CarFire/CarFire/CarFire/Content/menuFont.spritefont [new file with mode: 0644]
CarFire/CarFire/CarFire/Content/menuItem.png [new file with mode: 0644]
CarFire/CarFire/CarFire/Content/selectGameScreen.png [new file with mode: 0644]
CarFire/CarFire/CarFire/Content/spotlight.png [new file with mode: 0644]
CarFire/CarFire/CarFire/ScreenManager.cs

index f2f8c3f63e156a38ce89053dd1ff2e6d8c022807..6128e004e121f39ab0a2050ff933595a7bffa44d 100644 (file)
@@ -1,4 +1,4 @@
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">\r
   <PropertyGroup>\r
     <ProjectGuid>c115bbca-d6fd-42af-b2a1-3e895808bc14</ProjectGuid>\r
     <ProjectTypeGuids>{96E2B04D-8817-42c6-938A-82C39BA4D311};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>\r
       <Private>False</Private>\r
     </Reference>\r
   </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="checkedBox.png">\r
+      <Name>checkedBox</Name>\r
+      <Importer>TextureImporter</Importer>\r
+      <Processor>TextureProcessor</Processor>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="deselectBox.png">\r
+      <Name>deselectBox</Name>\r
+      <Importer>TextureImporter</Importer>\r
+      <Processor>TextureProcessor</Processor>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="selectGameScreen.png">\r
+      <Name>selectGameScreen</Name>\r
+      <Importer>TextureImporter</Importer>\r
+      <Processor>TextureProcessor</Processor>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="menuItem.png">\r
+      <Name>menuItem</Name>\r
+      <Importer>TextureImporter</Importer>\r
+      <Processor>TextureProcessor</Processor>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="menuFont.spritefont">\r
+      <Name>menuFont</Name>\r
+      <Importer>FontDescriptionImporter</Importer>\r
+      <Processor>FontDescriptionProcessor</Processor>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="InstructionFont.spritefont">\r
+      <Name>InstructionFont</Name>\r
+      <Importer>FontDescriptionImporter</Importer>\r
+      <Processor>FontDescriptionProcessor</Processor>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="emptySelectBox.png">\r
+      <Name>emptySelectBox</Name>\r
+      <Importer>TextureImporter</Importer>\r
+      <Processor>TextureProcessor</Processor>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="cs.png">\r
+      <Name>cs</Name>\r
+      <Importer>TextureImporter</Importer>\r
+      <Processor>TextureProcessor</Processor>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="background.png">\r
+      <Name>background</Name>\r
+      <Importer>TextureImporter</Importer>\r
+      <Processor>TextureProcessor</Processor>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="spotlight.png">\r
+      <Name>spotlight</Name>\r
+      <Importer>TextureImporter</Importer>\r
+      <Processor>TextureProcessor</Processor>\r
+    </Compile>\r
+  </ItemGroup>\r
   <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\v3.0\Microsoft.Xna.GameStudio.ContentPipeline.targets" />\r
-\r
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
        Other similar extension points exist, see Microsoft.Common.targets.\r
   <Target Name="BeforeBuild">\r
   <Target Name="AfterBuild">\r
   </Target>\r
   -->\r
-\r
-</Project>\r
+</Project>
\ No newline at end of file
diff --git a/CarFire/CarFire/CarFire/Content/InstructionFont.spritefont b/CarFire/CarFire/CarFire/Content/InstructionFont.spritefont
new file mode 100644 (file)
index 0000000..bc2c05b
--- /dev/null
@@ -0,0 +1,60 @@
+<?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>Pescadero</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>14</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>Regular</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>&#32;</Start>\r
+        <End>&#126;</End>\r
+      </CharacterRegion>\r
+    </CharacterRegions>\r
+  </Asset>\r
+</XnaContent>\r
diff --git a/CarFire/CarFire/CarFire/Content/background.png b/CarFire/CarFire/CarFire/Content/background.png
new file mode 100644 (file)
index 0000000..b90a658
Binary files /dev/null and b/CarFire/CarFire/CarFire/Content/background.png differ
diff --git a/CarFire/CarFire/CarFire/Content/checkedBox.png b/CarFire/CarFire/CarFire/Content/checkedBox.png
new file mode 100644 (file)
index 0000000..3462dc3
Binary files /dev/null and b/CarFire/CarFire/CarFire/Content/checkedBox.png differ
diff --git a/CarFire/CarFire/CarFire/Content/cs.png b/CarFire/CarFire/CarFire/Content/cs.png
new file mode 100644 (file)
index 0000000..f7d6ebd
Binary files /dev/null and b/CarFire/CarFire/CarFire/Content/cs.png differ
diff --git a/CarFire/CarFire/CarFire/Content/deselectBox.png b/CarFire/CarFire/CarFire/Content/deselectBox.png
new file mode 100644 (file)
index 0000000..cb4d2d0
Binary files /dev/null and b/CarFire/CarFire/CarFire/Content/deselectBox.png differ
diff --git a/CarFire/CarFire/CarFire/Content/emptySelectBox.png b/CarFire/CarFire/CarFire/Content/emptySelectBox.png
new file mode 100644 (file)
index 0000000..5373a1b
Binary files /dev/null and b/CarFire/CarFire/CarFire/Content/emptySelectBox.png differ
diff --git a/CarFire/CarFire/CarFire/Content/menuFont.spritefont b/CarFire/CarFire/CarFire/Content/menuFont.spritefont
new file mode 100644 (file)
index 0000000..72495a3
--- /dev/null
@@ -0,0 +1,60 @@
+<?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>&#32;</Start>\r
+        <End>&#126;</End>\r
+      </CharacterRegion>\r
+    </CharacterRegions>\r
+  </Asset>\r
+</XnaContent>\r
diff --git a/CarFire/CarFire/CarFire/Content/menuItem.png b/CarFire/CarFire/CarFire/Content/menuItem.png
new file mode 100644 (file)
index 0000000..cf45ebd
Binary files /dev/null and b/CarFire/CarFire/CarFire/Content/menuItem.png differ
diff --git a/CarFire/CarFire/CarFire/Content/selectGameScreen.png b/CarFire/CarFire/CarFire/Content/selectGameScreen.png
new file mode 100644 (file)
index 0000000..af04c0c
Binary files /dev/null and b/CarFire/CarFire/CarFire/Content/selectGameScreen.png differ
diff --git a/CarFire/CarFire/CarFire/Content/spotlight.png b/CarFire/CarFire/CarFire/Content/spotlight.png
new file mode 100644 (file)
index 0000000..d8c3381
Binary files /dev/null and b/CarFire/CarFire/CarFire/Content/spotlight.png differ
index 5c6bf7191348e56e9567579dfc201b6b61be47ea..0c58e77cfd3bcdd75fc1f515623d8ffc4928c021 100644 (file)
 using System.Collections.Generic;\r
 using System.Linq;\r
 using System.Text;\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
-using Microsoft.Xna.Framework.Graphics;\r
 \r
 namespace CarFire\r
 {\r
     class ScreenManager : IScreenManager\r
     {\r
-        #region ILobby Members\r
+        #region local variables\r
+        float scale;\r
+\r
+        Texture2D background;\r
+        Texture2D spotLight;\r
+        Texture2D cs;\r
+        Texture2D selectGameScreen;\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
+        Texture2D checkedBox;\r
+        Texture2D deselectBox;\r
+        Texture2D emptySelectBox;\r
+        Texture2D menuItem;\r
+\r
+        Boolean ready;\r
+\r
+        SpriteFont menuFont;\r
+        string selected;\r
+        Vector2 createGamePos;\r
+        string createGameText;\r
+        Vector2 findGamePos;\r
+        string findGameText;\r
+\r
+        Vector2 returnToMainPos;\r
+        string returnToMainText;\r
+\r
+        KeyboardState previousKeyboardState;\r
+        KeyboardState currentKeyboardState;\r
+\r
+        GamerCollection<NetworkGamer> players;\r
+        LocalNetworkGamer localPlayer;\r
+        AvailableNetworkSessionCollection availableSessions;\r
+        bool allReady;\r
+\r
+        int selectedSessionIndex;\r
+\r
+        bool chatActive;\r
+        String chatMessage;\r
+        Queue<ChatInfo> currentChat;\r
+\r
+        \r
+\r
+        private enum lobbyState\r
+        {\r
+            Welcome,\r
+            CreateGame,\r
+            FindGame,\r
+            FindingGames, // TODO: New state.\r
+            JoiningGame,  // TODO: New state.\r
+            Connected\r
+        }\r
+\r
+        lobbyState currentState;\r
+        #endregion\r
+\r
+        public ScreenManager()\r
+        {\r
+            currentState = lobbyState.Welcome;\r
+            selectedSessionIndex = 0;\r
+            ready = false;\r
+            chatActive = false;\r
+            chatMessage = "";\r
+            currentChat = new Queue<ChatInfo>();\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
+            selectGameScreen = contentManager.Load<Texture2D>("selectGameScreen");\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
+            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
+            \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
+            returnToMainPos = new Vector2(MaxX / 2, MaxY - 120);\r
+            returnToMainText = "press [ X ] to return to main menu";\r
+\r
+            \r
         }\r
 \r
         public void UnloadContent()\r
         {\r
+            \r
+        }\r
+\r
+        /// <summary>\r
+        /// Transition into connected state\r
+        /// </summary>\r
+        void JoinedSession(NetworkSession session, NetworkManager networkManager)\r
+        {\r
+            if (session != null)\r
+            {\r
+                currentState = lobbyState.Connected;\r
+            }\r
+            else\r
+            {\r
+                // TODO: This should do something more than just throw the player back to the welcome screen.\r
+                currentState = lobbyState.Welcome;\r
+                Console.WriteLine("Couldn't create/join the session.");\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Called when Async FindSession returns. Available sessions is then updated\r
+        /// </summary>\r
+        void FoundSessions(AvailableNetworkSessionCollection sessions, NetworkManager networkManager)\r
+        {\r
+            availableSessions = sessions;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Catches exceptions for and Async calls\r
+        /// </summary>\r
+        void AsyncCallbackFailed(Exception exception, NetworkManager networkManager)\r
+        {\r
+            currentState = lobbyState.Welcome;\r
+            Console.WriteLine("Exception as thrown during async call: " + exception.Message);\r
+        }\r
+\r
+        /// <summary>\r
+        /// Adds and new chats to the chat list. If chat list is full, older messages are removed.\r
+        /// </summary>\r
+        private void UpdateChat(GameTime gameTime, NetworkManager networkManager)\r
+        {\r
+            List<ChatInfo> chts = networkManager.ReceiveChats();\r
+            for (int x = 0; x < chts.Count(); x++)\r
+                currentChat.Enqueue(chts[x]);\r
+\r
+            //if number of chat messages has reached max remove older messages as new ones are added\r
+            if (currentChat.Count() > 8)\r
+            {\r
+                for (int x = 0; x < chts.Count(); x++)\r
+                {\r
+                    currentChat.Dequeue();\r
+                }\r
+            }\r
+\r
         }\r
 \r
-        public long Update(GameTime gameTime, NetworkManager networkGame)\r
+        /// <summary>\r
+        /// Main update call for Lobby, what is actually updated is determined by what the current state is.\r
+        /// </summary>\r
+        public long Update(GameTime gameTime, NetworkManager networkManager)\r
         {\r
-            return 0;\r
+            \r
+            UpdateSpotLight(gameTime);\r
+            currentKeyboardState = Keyboard.GetState();\r
+\r
+            if (networkManager.HasActiveSession)\r
+            {\r
+                players = networkManager.NetworkGamers;\r
+            }\r
+\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))\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.Up))\r
+                            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
+                        if (networkManager.HasActiveSession)\r
+                        {\r
+                            players = null;\r
+                            networkManager.LeaveSession();\r
+                        }\r
+                    }\r
+                    if (currentKeyboardState.IsKeyDown(Keys.Y) && previousKeyboardState.IsKeyUp(Keys.Y))\r
+                    {\r
+                        currentState = lobbyState.JoiningGame;\r
+                        networkManager.ErrorDelegate = AsyncCallbackFailed;\r
+                        networkManager.CreateSession(JoinedSession);\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 = null;\r
+                    networkManager.ErrorDelegate = AsyncCallbackFailed;\r
+                    networkManager.FindSessions(FoundSessions);\r
+                    currentState = lobbyState.FindingGames;\r
+                    break;\r
+\r
+                case lobbyState.FindingGames:\r
+                    if (currentKeyboardState.IsKeyDown(Keys.X) && previousKeyboardState.IsKeyUp(Keys.X))\r
+                    {\r
+                        currentState = lobbyState.Welcome;\r
+                        ready = false;\r
+                    }\r
+                    if (availableSessions != null && availableSessions.Count == 0)\r
+                        currentState = lobbyState.FindGame;\r
+                    else if (availableSessions != null && availableSessions.Count > 0)\r
+                    {\r
+                        if (currentKeyboardState.IsKeyDown(Keys.D1) && previousKeyboardState.IsKeyUp(Keys.D1))\r
+                        {\r
+                            networkManager.JoinSession(availableSessions[0], JoinedSession);\r
+                            currentState = lobbyState.JoiningGame;\r
+\r
+                            availableSessions.Dispose();\r
+                            availableSessions = null;\r
+                        }\r
+                        if (currentKeyboardState.IsKeyDown(Keys.D2) && previousKeyboardState.IsKeyUp(Keys.D2))\r
+                        {\r
+                            networkManager.JoinSession(availableSessions[0], JoinedSession);\r
+                            currentState = lobbyState.JoiningGame;\r
+\r
+                            availableSessions.Dispose();\r
+                            availableSessions = null;\r
+                        }\r
+                    }\r
+\r
+                    break;\r
+\r
+                case lobbyState.Connected:\r
+                    if (chatActive)   //If chat is activated by pressing T all inputs go to chat. Enter finishes chat esc returns\r
+                    {\r
+                        if (currentKeyboardState.IsKeyDown(Keys.Escape) && previousKeyboardState.IsKeyUp(Keys.Escape))\r
+                        {\r
+                            chatActive = false;\r
+                            break;\r
+                        }\r
+                        if (currentKeyboardState.IsKeyDown(Keys.Enter) && previousKeyboardState.IsKeyUp(Keys.Enter))\r
+                        {\r
+                            networkManager.SendChat(chatMessage);\r
+                            chatActive = false;\r
+                            break;\r
+                        }\r
+                        Keys[] k = currentKeyboardState.GetPressedKeys();\r
+                        Keys[] kp = previousKeyboardState.GetPressedKeys();\r
+                        List<Keys> newKeys = new List<Keys>();\r
+\r
+                        for (int x = 0; x < k.Count(); x++) //copy new keys into array\r
+                        {\r
+                            if (!kp.Contains(k[x]))\r
+                            {\r
+                                newKeys.Add(k[x]);\r
+                            }\r
+                        }\r
+\r
+                        foreach(Keys ky in newKeys)\r
+                        {\r
+                            if (ky.Equals(Keys.Back))\r
+                                chatMessage = chatMessage.Substring(0, chatMessage.Length-1);\r
+                            else if(ky.Equals(Keys.Space))\r
+                                chatMessage = chatMessage + " ";\r
+                            else\r
+                                chatMessage = chatMessage + ky.ToString();\r
+                        }\r
+                        \r
+                    }\r
+                    else  //normal op mode\r
+                    {\r
+                        UpdateChat(gameTime, networkManager);\r
+                        chatMessage = "";\r
+                        if (currentKeyboardState.IsKeyDown(Keys.T) && previousKeyboardState.IsKeyUp(Keys.T))\r
+                        {\r
+                            chatActive = true;\r
+                        }\r
+                        if (currentKeyboardState.IsKeyDown(Keys.X) && previousKeyboardState.IsKeyUp(Keys.X))\r
+                        {\r
+                            ready = false;\r
+                            currentChat.Clear();\r
+                            if (networkManager.HasActiveSession)\r
+                            {\r
+                                players = null;\r
+                                networkManager.LeaveSession();\r
+                            }\r
+                            currentState = lobbyState.Welcome;\r
+\r
+                        }\r
+                        if (currentKeyboardState.IsKeyDown(Keys.R) && previousKeyboardState.IsKeyUp(Keys.R))\r
+                            networkManager.LocalGamer.IsReady = true;\r
+\r
+                        if (networkManager.HasActiveSession)\r
+                        {\r
+                            localPlayer = networkManager.LocalGamer;\r
+                            players = networkManager.NetworkGamers;\r
+                            if (players != null)\r
+                            {\r
+                                allReady = true;\r
+                                foreach (NetworkGamer p in players)\r
+                                    if (p.IsReady == false)\r
+                                    {\r
+                                        allReady = false;\r
+                                        break;\r
+                                    }\r
+                            }\r
+\r
+                            //allows host to start the game when all players are ready, change count below to different number for testing with less then 4 players\r
+                            if (allReady && players.Count == 4 && localPlayer == players[0])\r
+                            {\r
+                                if (currentKeyboardState.IsKeyDown(Keys.B) && previousKeyboardState.IsKeyUp(Keys.B))\r
+                                {\r
+                                    networkManager.ForceStartGame();\r
+                                }\r
+                            }\r
+                        }\r
+                        else\r
+                            currentState = lobbyState.Welcome;\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
-            return 0;\r
+            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
+                    spriteBatch.DrawString(menuFont, "press [ Home ] to login", new Vector2(350, 20), Color.LightGray, 0f, zero, .6f, SpriteEffects.None, 0.5f);\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
+                \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
+\r
+                case lobbyState.FindingGames:\r
+                    spriteBatch.Draw(selectGameScreen, backgroundPos, null, Color.White, 0, zero, scale, SpriteEffects.None, 0);\r
+                    spriteBatch.DrawString(menuFont, "select game by pressing listed games index", new Vector2(250, 400), Color.Gray, 0f, zero, .7f, 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, sessionIndex+1 + "          " + availableSessions[sessionIndex].HostGamertag, new Vector2(150, 125 + sessionIndex * menuFont.LineSpacing), color, 0f, zero, .7f, SpriteEffects.None, 0.5f);\r
+                            spriteBatch.DrawString(menuFont, availableSessions[sessionIndex].CurrentGamerCount + " / 4",\r
+                                                   new Vector2(450, 125 + sessionIndex * menuFont.LineSpacing), color, 0f, zero, .7f, SpriteEffects.None, 0.5f);\r
+                        }\r
+                    }\r
+                    break;\r
+\r
+                case lobbyState.Connected:\r
+                    DrawPlayerList(spriteBatch);\r
+                    DrawChatInfo(spriteBatch);                    \r
+                    if(allReady && players.Count == 2 && localPlayer == players[0])\r
+                        spriteBatch.DrawString(menuFont, "Press B to begin game!", new Vector2(MaxX / 2, MaxY / 2), Color.White, 0f, zero, .7f, SpriteEffects.None, 0.5f);\r
+                    else if(allReady)\r
+                        spriteBatch.DrawString(menuFont, "The game will begin soon.", new Vector2(MaxX / 2, MaxY / 2), Color.White, 0f, zero, .7f, SpriteEffects.None, 0.5f);\r
+                    else\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
+            return 1;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Updates backgound animation with moving spotlight. Spotlight bounces off walls \r
+        /// </summary>\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
-        #endregion\r
+        /// <summary>\r
+        /// Draws the list of current chat messages received by the local client.\r
+        /// </summary>\r
+        private void DrawChatInfo(SpriteBatch spriteBatch)\r
+        {\r
+            if (currentChat.Count > 0)\r
+            {\r
+                for (int y = 0; y < currentChat.Count; y++)\r
+                {\r
+                    spriteBatch.DrawString(menuFont, currentChat.ElementAt(y).Sender + ": " + currentChat.ElementAt(y).Message\r
+                                            , new Vector2(400, 10 + y*15), Color.Blue, 0f, zero, .6f, SpriteEffects.None, 1f);\r
+                }\r
+\r
+            }\r
+            if(chatActive)\r
+                spriteBatch.DrawString(menuFont, chatMessage, new Vector2(400, 10 + 15*(currentChat.Count + 1)), Color.Green, 0f, zero, .6f, SpriteEffects.None, 1f);\r
+        }\r
+\r
+        /// <summary>\r
+        /// Draws player list objects for the connected state.\r
+        /// </summary>\r
+        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, 80), Color.Gray, 0f, zero, .6f, SpriteEffects.None, 1f);\r
+            spriteBatch.DrawString(menuFont, "enter chat mode", 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, 80), Color.DarkGreen, 0f, zero, .6f, SpriteEffects.None, 1f);\r
+            spriteBatch.DrawString(menuFont, "T", new Vector2(145, 60), Color.DarkGreen, 0f, zero, .6f, SpriteEffects.None, 1f);\r
+\r
+            //Background squares\r
+            spriteBatch.Draw(menuItem, topOfList, null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+            spriteBatch.Draw(menuItem, new Vector2(topOfList.X, topOfList.Y + 65), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+            spriteBatch.Draw(menuItem, new Vector2(topOfList.X, topOfList.Y + 130), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+            spriteBatch.Draw(menuItem, new Vector2(topOfList.X, topOfList.Y + 195), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+\r
+            //Ready Labels\r
+            spriteBatch.DrawString(menuFont, "Ready", new Vector2(topOfList.X + 5, topOfList.Y + 45), Color.DarkGray, 0f, zero, .6f, 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
+            spriteBatch.DrawString(menuFont, "Ready", new Vector2(topOfList.X + 5, topOfList.Y + 175), Color.DarkGray, 0f, zero, .6f, 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
+\r
+            //Ready CheckBoxs\r
+            if (players == null)\r
+            {\r
+                spriteBatch.Draw(emptySelectBox, new Vector2(topOfList.X - 32, topOfList.Y + 35), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+                spriteBatch.Draw(emptySelectBox, new Vector2(topOfList.X - 32, topOfList.Y + 100), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+                spriteBatch.Draw(emptySelectBox, new Vector2(topOfList.X - 32, topOfList.Y + 165), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+                spriteBatch.Draw(emptySelectBox, new Vector2(topOfList.X - 32, topOfList.Y + 230), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+            }\r
+            else\r
+            {\r
+                if (!(players.Count >= 1 && players[0].IsReady))\r
+                    spriteBatch.Draw(emptySelectBox, new Vector2(topOfList.X - 32, topOfList.Y + 35), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+                else\r
+                    spriteBatch.Draw(checkedBox, new Vector2(topOfList.X - 32, topOfList.Y + 30), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+                if (!(players.Count >= 2 && players[1].IsReady))\r
+                    spriteBatch.Draw(emptySelectBox, new Vector2(topOfList.X - 32, topOfList.Y + 100), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+                else\r
+                    spriteBatch.Draw(checkedBox, new Vector2(topOfList.X - 32, topOfList.Y + 95), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+                if (!(players.Count >= 3 && players[2].IsReady))\r
+                    spriteBatch.Draw(emptySelectBox, new Vector2(topOfList.X - 32, topOfList.Y + 165), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+                else\r
+                    spriteBatch.Draw(checkedBox, new Vector2(topOfList.X - 32, topOfList.Y + 160), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+                if (!(players.Count >= 4 && players[3].IsReady))\r
+                    spriteBatch.Draw(emptySelectBox, new Vector2(topOfList.X - 32, topOfList.Y + 230), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+                else\r
+                    spriteBatch.Draw(checkedBox, new Vector2(topOfList.X - 32, topOfList.Y + 225), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+            }\r
+\r
+            //Chat Labels\r
+            spriteBatch.DrawString(menuFont, "Chat with", new Vector2(topOfList.X + 152, topOfList.Y + 45), Color.DarkGray, 0f, zero, .6f, SpriteEffects.None, 1f);\r
+            spriteBatch.DrawString(menuFont, "Chat with", new Vector2(topOfList.X + 152, topOfList.Y + 110), Color.DarkGray, 0f, zero, .6f, SpriteEffects.None, 1f);\r
+            spriteBatch.DrawString(menuFont, "Chat with", new Vector2(topOfList.X + 152, topOfList.Y + 175), Color.DarkGray, 0f, zero, .6f, SpriteEffects.None, 1f);\r
+            spriteBatch.DrawString(menuFont, "Chat with", new Vector2(topOfList.X + 152, topOfList.Y + 240), Color.DarkGray, 0f, zero, .6f, SpriteEffects.None, 1f);\r
+            \r
+            //Chat CheckBoxs\r
+            Boolean chatwith = true;  // change to reflect info from network, move to update and create one for each player\r
+            if (!chatwith)\r
+                spriteBatch.Draw(deselectBox, new Vector2(topOfList.X +218, topOfList.Y + 35), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+            else\r
+                spriteBatch.Draw(checkedBox, new Vector2(topOfList.X + 218, topOfList.Y + 30), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+\r
+            if (!chatwith)\r
+                spriteBatch.Draw(deselectBox, new Vector2(topOfList.X + 218, topOfList.Y + 100), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+            else\r
+                spriteBatch.Draw(checkedBox, new Vector2(topOfList.X + 218, topOfList.Y + 95), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+\r
+            if (!chatwith)\r
+                spriteBatch.Draw(deselectBox, new Vector2(topOfList.X + 218, topOfList.Y + 165), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+            else\r
+                spriteBatch.Draw(checkedBox, new Vector2(topOfList.X + 218, topOfList.Y + 160), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+\r
+            if (!chatwith)\r
+                spriteBatch.Draw(deselectBox, new Vector2(topOfList.X + 218, topOfList.Y + 230), null, Color.White, 0, zero, scale, SpriteEffects.None, 1f);\r
+            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
     }\r
 }\r
This page took 0.054993 seconds and 4 git commands to generate.