Example #1
0
        protected override void Draw(GameTime time)
        {
            GraphicsDevice.Clear(Color.Black);

            if (State == GameState.AtMenu)
            {
                sprites.Begin();

                for (int i = 0; i < ScreenBounds.X / 100; i++)
                {
                    Utility.DrawDottedCircle(sprites, Color.Gray, ScreenBounds / 2, i * 100, 16);
                }

                for (int x = 0; x < Math.Ceiling(ScreenBounds.X / 1024); x++)
                {
                    for (int y = 0; y < Math.Ceiling(ScreenBounds.Y / 1024); y++)
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            sprites.Draw(GameContent.Texture("environment\\background\\stars" + (i + 1)), new Vector2(x * 1024, y * 1024), Color.White);
                        }
                    }
                }

                sprites.End();
            }
            else if (State == GameState.Connecting)
            {
                ConnectingScreen.Draw(this, sprites, time);
            }
            else if (State == GameState.InGame)
            {
                Backdrop.Draw(sprites, MainCamera);

                if (NetworkHelper.LocalPlayer != null)
                {
                    MainCamera.Position = NetworkHelper.LocalPlayer.RenderPosition;
                    //Camera.Position = new Vector2((int)Math.Round(MathHelper.Lerp(Camera.Position.X, NetworkHelper.LocalPlayer.RenderPosition.X, 0.05f)), (int)Math.Round(MathHelper.Lerp(Camera.Position.Y, NetworkHelper.LocalPlayer.RenderPosition.Y, 0.5f)));
                }
                else
                {
                    MainCamera.Position = Vector2.Zero;
                }

                sprites.Begin(SpriteSortMode.Deferred, null, SamplerState.LinearClamp, null, null, null, MainCamera.GetTransformation());

                Particles.Draw(sprites);
                DrawSystem();
                Entities.EntityManager.Draw(sprites);

                sprites.End();

                HUD.Draw(sprites, this);
            }

            Interface.InterfaceManager.Draw(sprites);

            base.Draw(time);
        }
Example #2
0
        public static void DrawCircle(SpriteBatch sprites, Color color, Vector2 pos, int radius)
        {
            pos = pos.Round();

            for (float i = 0; i < Math.PI * 2; i += 1.0f / radius)
            {
                sprites.Draw(GameContent.Texture("pixel"), pos + new Vector2((float)Math.Sin(i) * radius, (float)Math.Cos(i) * radius), color);
            }
        }
Example #3
0
        public static void DrawLine(SpriteBatch sprites, Color color, Vector2 start, Vector2 end)
        {
            start = start.Round();
            end   = end.Round();

            Vector2 line  = end - start;
            float   angle = (float)Math.Atan2(line.Y, line.X);

            sprites.Draw(GameContent.Texture("pixel"), new Rectangle((int)start.X, (int)start.Y, (int)line.Length(), 1), null, color, angle, new Vector2(0, 0), SpriteEffects.None, 0);
        }
Example #4
0
 public static void Draw(SpriteBatch sprites)
 {
     foreach (Particle particle in particles)
     {
         if (particle.Life > 0) // I don't even know anymore
         {
             sprites.Draw(GameContent.Texture("pixel"), particle.Position, particle.Color);
         }
     }
 }
Example #5
0
        public static void DrawDottedCircle(SpriteBatch sprites, Color color, Vector2 pos, int radius, int sparsity)
        {
            pos = pos.Round();

            for (float i = 0; i < (Math.PI * 2); i += (1.0f / radius) * sparsity)
            {
                if (i + (1.0f / radius) * sparsity < (Math.PI * 2))
                {
                    sprites.Draw(GameContent.Texture("pixel"), pos + new Vector2((float)Math.Sin(i) * radius, (float)Math.Cos(i) * radius), color);
                }
            }
        }
Example #6
0
        public static void DrawCircleOptimized(SpriteBatch sprites, Camera camera, Color color, Vector2 pos, int radius)
        {
            pos = pos.Round();

            for (float i = 0; i < Math.PI * 2; i += 1.0f / radius)
            {
                Vector2   pixelPos = pos + new Vector2((float)Math.Sin(i) * radius, (float)Math.Cos(i) * radius);
                Rectangle frustum  = new Rectangle((int)(camera.Position.X - camera.Size.X / 2), (int)(camera.Position.Y - camera.Size.Y / 2), (int)camera.Size.X, (int)camera.Size.Y);

                if (frustum.Contains(new Point((int)pixelPos.X, (int)pixelPos.Y)))
                {
                    sprites.Draw(GameContent.Texture("pixel"), pixelPos, color);
                }
            }
        }
Example #7
0
        protected override void LoadContent()
        {
            MainCamera.Size = ScreenBounds;

            Window.AllowUserResizing  = true;
            Window.ClientSizeChanged += new EventHandler <EventArgs>((sender, e) =>
            {
                float snap   = 10.0f;
                ScreenBounds = new Vector2((float)Math.Round(Window.ClientBounds.Width / snap) * snap, (float)Math.Round(Window.ClientBounds.Height / snap) * snap);
                Window.Title = "Aphelion - X:" + ScreenBounds.X + ", Y:" + ScreenBounds.Y;

                graphics.PreferredBackBufferWidth  = (int)ScreenBounds.X;
                graphics.PreferredBackBufferHeight = (int)ScreenBounds.Y;
                graphics.ApplyChanges();

                // TO DO: Decide if I should turn this into a switch statement
                if (State == GameState.AtMenu)
                {
                    Interface.InterfaceManager.RemoveAllWithTag("Title Menu");
                    Interface.InterfaceManager.RemoveAllWithTag("Prompt");

                    CreateTitleMenu();
                }
                else
                {
                    Interface.TextButton debugButton = (Interface.TextButton)Interface.InterfaceManager.GetAllElementsWithTag("Debug Button")[0];
                    debugButton.Position             = new Vector2(8, ScreenBounds.Y - 8 - debugButton.CalculateDimensions().Y);
                }

                MainCamera.Size = ScreenBounds;
            });

            sprites = new SpriteBatch(GraphicsDevice);
            GameContent.SetContentManager(Content);

            TextRenderer.SetSpriteBatch(sprites);
            TextRenderer.SetFont(GameContent.Texture(@"interface\fonts\default"));

            CreateTitleMenu();
        }
        public static void Draw(Aphelion aphelion, SpriteBatch sprites, GameTime time)
        {
            sprites.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, RasterizerState.CullNone);

            sprites.Draw(GameContent.Texture("pixel"), new Rectangle(0, 0, (int)aphelion.ScreenBounds.X, (int)aphelion.ScreenBounds.Y), Color.Black);

            CurrentColor = Color.Lerp(CurrentColor, DestColor, 0.05f);

            TextRenderer.SaveState();
            TextRenderer.SetScale(2);
            TextRenderer.SetColor(Color.FromNonPremultiplied(CurrentColor.R, CurrentColor.G, CurrentColor.B, 155 - (int)(Math.Cos(time.TotalGameTime.TotalSeconds) * 100)));

            Vector2 textSize = TextRenderer.MeasureString(Text);

            TextRenderer.DrawString(Text, aphelion.ScreenBounds / 2 - textSize / 2);
            TextRenderer.RestoreState();

            for (int i = 0; i < 4; i++)
            {
                Utility.DrawCircle(sprites, Color.FromNonPremultiplied(CurrentColor.R, CurrentColor.G, CurrentColor.B, 155 - (int)(Math.Cos(time.TotalGameTime.TotalSeconds + i) * 100)), aphelion.ScreenBounds / 2, (int)textSize.X / 2 + 64 + (int)(Math.Cos(time.TotalGameTime.TotalSeconds + i) * 32));
            }

            sprites.End();
        }
Example #9
0
        private static void DrawRadar(SpriteBatch sprites, Aphelion aphelion) // TO DO: Give the radar it's own file (Radar.cs)
        {
            int     ratio       = (int)Math.Pow(2, 9);
            Vector2 radarOrigin = aphelion.ScreenBounds - new Vector2(128, 128) - new Vector2(16, 16);

            Utility.DrawDottedCircle(sprites, Color.White, radarOrigin, 128, 16);

            #region Sun & Planets

            int     sunRadius = 6958;
            Vector2 sunPos    = Vector2.Zero;

            int     mercuryRadius   = 24;
            int     mercuryDistance = 8368;
            Vector2 mercuryPos      = new Vector2(sunRadius + mercuryDistance, 0);

            int     venusRadius   = 60;
            int     venusDistance = 8368;
            Vector2 venusPos      = new Vector2(mercuryPos.X + venusDistance, 0);

            Vector2 center = radarOrigin - new Vector2(2, 3);
            TextRenderer.SaveState();
            TextRenderer.SetScale(1);
            TextRenderer.SetColor(Color.Red);
            Utility.DrawCircle(sprites, Color.Red, radarOrigin, sunRadius / ratio);
            Utility.DrawCircle(sprites, Color.Orange, radarOrigin, sunRadius / ratio - 2);
            TextRenderer.DrawString("S", center);
            TextRenderer.SetColor(Color.Gray);
            TextRenderer.DrawString("M", center + mercuryPos / ratio);
            TextRenderer.SetColor(Color.DarkOrange);
            TextRenderer.DrawString("V", center + venusPos / ratio);
            TextRenderer.RestoreState();

            #endregion

            if (NetworkHelper.LocalPlayer != null)
            {
                Vector2 localPlayerPos = radarOrigin + NetworkHelper.LocalPlayer.Position / ratio;

                sprites.Draw(GameContent.Texture("pixel"), new Rectangle((int)localPlayerPos.X - 1, (int)localPlayerPos.Y - 1, 3, 3), Color.White);
            }

            foreach (Player player in NetworkHelper.Players)
            {
                Vector2 playerPos = radarOrigin + player.Position / ratio;

                sprites.Draw(GameContent.Texture("pixel"), new Rectangle((int)playerPos.X - 1, (int)playerPos.Y - 1, 3, 3), Color.LawnGreen);
            }

            // TargetPos System

            MouseState mouseState = Mouse.GetState();
            Vector2    mousePos   = new Vector2(mouseState.X, mouseState.Y);

            if (Vector2.Distance(radarOrigin, mousePos) <= 128)
            {
                aphelion.IsMouseVisible = false;

                Utility.DrawLine(sprites, Color.White, mousePos + new Vector2(0, 4), mousePos + new Vector2(0, 4 + 16));
                Utility.DrawLine(sprites, Color.White, mousePos - new Vector2(0, 4), mousePos - new Vector2(0, 4 + 16));
                Utility.DrawLine(sprites, Color.White, mousePos + new Vector2(4, 0), mousePos + new Vector2(4 + 16, 0));
                Utility.DrawLine(sprites, Color.White, mousePos - new Vector2(4, 0), mousePos - new Vector2(4 + 16, 0));

                if (mouseState.LeftButton == ButtonState.Pressed /* && lastMouseState.LeftButton == ButtonState.Released*/)
                {
                    targetPos  = ((aphelion.ScreenBounds - new Vector2(128, 128) - new Vector2(16, 16)) - new Vector2(mouseState.X, mouseState.Y)) * -ratio;
                    drawTarget = true;
                }
                else if (mouseState.RightButton == ButtonState.Pressed && lastMouseState.RightButton == ButtonState.Released)
                {
                    drawTarget = false;
                }
            }
            else
            {
                aphelion.IsMouseVisible = true;
            }

            lastMouseState = mouseState;

            if (targetPos != null && drawTarget)
            {
                Vector2 targetDrawPos = radarOrigin + targetPos / ratio;

                Utility.DrawLine(sprites, Color.White, targetDrawPos + new Vector2(0, 2), targetDrawPos + new Vector2(0, 5));
                Utility.DrawLine(sprites, Color.White, targetDrawPos - new Vector2(0, 2), targetDrawPos - new Vector2(0, 5));
                Utility.DrawLine(sprites, Color.White, targetDrawPos + new Vector2(2, 0), targetDrawPos + new Vector2(5, 0));
                Utility.DrawLine(sprites, Color.White, targetDrawPos - new Vector2(2, 0), targetDrawPos - new Vector2(5, 0));

                if (NetworkHelper.LocalPlayer != null)
                {
                    Vector2 localPlayerPos = radarOrigin + NetworkHelper.LocalPlayer.Position / ratio;

                    if (Vector2.Distance(NetworkHelper.LocalPlayer.Position, targetPos) > 64)
                    {
                        Vector2 tangent = (targetDrawPos - localPlayerPos); // TO DO: Figure out if this is actually what a tangent is. I'm only in Algebra 2 ¯\_(ツ)_/¯
                        tangent.Normalize();
                        Utility.DrawLine(sprites, Color.White, targetDrawPos - tangent * 5, localPlayerPos + tangent * 3);
                    }

                    // SHADY CODE
                    sprites.End();

                    sprites.Begin(SpriteSortMode.Deferred, null, SamplerState.LinearClamp, null, null, null, aphelion.MainCamera.GetTransformation());

                    if (Vector2.Distance(NetworkHelper.LocalPlayer.Position, targetPos) > 64)
                    {
                        Vector2 tangent2 = (targetPos - NetworkHelper.LocalPlayer.Position);
                        tangent2.Normalize();
                        Utility.DrawLine(sprites, Color.White, NetworkHelper.LocalPlayer.Position + tangent2 * 25, targetPos - tangent2 * 30);
                    }

                    Utility.DrawLine(sprites, Color.White, targetPos + new Vector2(0, 4), targetPos + new Vector2(0, 4 + 16));
                    Utility.DrawLine(sprites, Color.White, targetPos - new Vector2(0, 4), targetPos - new Vector2(0, 4 + 16));
                    Utility.DrawLine(sprites, Color.White, targetPos + new Vector2(4, 0), targetPos + new Vector2(4 + 16, 0));
                    Utility.DrawLine(sprites, Color.White, targetPos - new Vector2(4, 0), targetPos - new Vector2(4 + 16, 0));

                    sprites.End();

                    sprites.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null);
                    // END SHADY CODE
                }
            }
        }
Example #10
0
        public void CreateTitleMenu()
        {
            int    titlePadding = Utility.ScaleY(36, this);
            int    panelPadding = Utility.ScaleY(9, this);
            int    topPadding   = Utility.ScaleY(64, this);
            int    padding      = Utility.ScaleY(18, this);
            int    titleScale   = Utility.ScaleY(15, this);
            int    labelScale   = Math.Max(Utility.ScaleY(3, this), 2);
            string openPrompt   = null;

            Action <string> SetPrompt = new Action <string>((prompt) =>
            {
                Interface.InterfaceManager.RemoveAllWithTag("Prompt");
                openPrompt = prompt;
            });

            Interface.Panel titleMenuPanel = new Interface.Panel();
            titleMenuPanel.Tag         = "Title Menu";
            titleMenuPanel.AutoSize    = true;
            titleMenuPanel.BorderScale = 2;
            Interface.InterfaceManager.Add(titleMenuPanel);

            Interface.Label titleLabel = new Interface.Label();
            titleLabel.Tag      = "Title Menu";
            titleLabel.Text     = "Aphelion";
            titleLabel.Position = new Vector2(padding, padding);
            titleLabel.Scale    = titleScale;
            titleMenuPanel.Add(titleLabel);

            Interface.TextButton manageYourProfileButton = new Interface.TextButton();
            manageYourProfileButton.Tag        = "Title Menu";
            manageYourProfileButton.Text       = "Manage your profile";
            manageYourProfileButton.Position   = new Vector2(titleLabel.Position.X, titlePadding + titleLabel.Position.Y + titleLabel.CalculateDimensions().Y);
            manageYourProfileButton.Scale      = labelScale;
            manageYourProfileButton.HoverMode  = Interface.TextButtonHoverMode.PointAt;
            manageYourProfileButton.OnHover   += (sender, e) => { GameContent.Sound("titlemenu_buttonhover").Play(0.5f, 1.0f, 0.0f); };
            manageYourProfileButton.OnRelease += (sender, e) => { GameContent.Sound("titlemenu_buttonclick").Play(0.5f, 1.0f, 0.0f); };
            manageYourProfileButton.OnRelease += (sender, e) =>
            {
                if (openPrompt != "Profile")
                {
                    SetPrompt("Profile");

                    Interface.Panel profilePanel = new Interface.Panel();
                    profilePanel.Tag         = "Prompt";
                    profilePanel.AutoSize    = true;
                    profilePanel.Position    = new Vector2(titleMenuPanel.Position.X, titleMenuPanel.Position.Y + titleMenuPanel.CalculateDimensions().Y + panelPadding + titleMenuPanel.BorderScale);
                    profilePanel.BorderScale = titleMenuPanel.BorderScale;
                    Interface.InterfaceManager.Add(profilePanel);

                    Interface.Label nameLabel = new Interface.Label();
                    nameLabel.Tag      = "Prompt";
                    nameLabel.Text     = "Name";
                    nameLabel.Position = new Vector2(padding, padding);
                    nameLabel.Scale    = labelScale;
                    profilePanel.Add(nameLabel);

                    Interface.TextBox nameTextbox = new Interface.TextBox();
                    nameTextbox.Tag         = "Prompt";
                    nameTextbox.MaxLength   = 15;
                    nameTextbox.Position    = new Vector2(padding, padding + nameLabel.Position.Y + nameLabel.CalculateDimensions().Y);
                    nameTextbox.BorderScale = 2;
                    nameTextbox.Scale       = labelScale;
                    nameTextbox.Text        = Settings.GetValueAsString("Profile.Name", "Dylan");
                    profilePanel.Add(nameTextbox);

                    Interface.Label colorLabel = new Interface.Label();
                    colorLabel.Tag      = "Prompt";
                    colorLabel.Text     = "Color";
                    colorLabel.Position = new Vector2(padding + nameTextbox.Position.X + nameTextbox.CalculateDimensions().X, padding);
                    colorLabel.Scale    = labelScale;
                    profilePanel.Add(colorLabel);

                    //Interface.TextButton colorHelpButton = new Interface.TextButton();
                    //colorHelpButton.Tag = "Prompt";
                    //colorHelpButton.Text = "?";
                    //colorHelpButton.Position = new Vector2(colorLabel.Position.X + colorLabel.CalculateDimensions().X + 4, colorLabel.Position.Y);
                    //colorHelpButton.Scale = labelScale;
                    //profilePanel.Add(colorHelpButton);

                    Interface.TextBox redTextbox = new Interface.TextBox();
                    redTextbox.Tag         = "Prompt";
                    redTextbox.Text        = Settings.GetValueAsString("Profile.Red", "255");
                    redTextbox.Mode        = Interface.TextBoxInputMode.Numerical;
                    redTextbox.MaxLength   = 3;
                    redTextbox.Position    = new Vector2(padding + nameLabel.Position.X + nameTextbox.CalculateDimensions().X, padding + nameLabel.Position.Y + nameLabel.CalculateDimensions().Y);
                    redTextbox.BorderScale = 2;
                    redTextbox.Scale       = labelScale;
                    redTextbox.BorderColor = Color.FromNonPremultiplied(255, 0, 0, 255);
                    profilePanel.Add(redTextbox);

                    Interface.TextBox greenTextbox = new Interface.TextBox();
                    greenTextbox.Tag         = "Prompt";
                    greenTextbox.Text        = Settings.GetValueAsString("Profile.Green", "255");
                    greenTextbox.Mode        = Interface.TextBoxInputMode.Numerical;
                    greenTextbox.MaxLength   = 3;
                    greenTextbox.Position    = new Vector2(padding + redTextbox.Position.X + redTextbox.CalculateDimensions().X, padding + nameLabel.Position.Y + nameLabel.CalculateDimensions().Y);
                    greenTextbox.BorderScale = 2;
                    greenTextbox.Scale       = labelScale;
                    greenTextbox.BorderColor = Color.FromNonPremultiplied(0, 255, 0, 255);
                    profilePanel.Add(greenTextbox);

                    Interface.TextBox blueTextbox = new Interface.TextBox();
                    blueTextbox.Tag         = "Prompt";
                    blueTextbox.Text        = Settings.GetValueAsString("Profile.Blue", "255");
                    blueTextbox.Mode        = Interface.TextBoxInputMode.Numerical;
                    blueTextbox.MaxLength   = 3;
                    blueTextbox.Position    = new Vector2(padding + greenTextbox.Position.X + greenTextbox.CalculateDimensions().X, padding + nameLabel.Position.Y + nameLabel.CalculateDimensions().Y);
                    blueTextbox.BorderScale = 2;
                    blueTextbox.Scale       = labelScale;
                    blueTextbox.BorderColor = Color.FromNonPremultiplied(0, 0, 255, 255);
                    profilePanel.Add(blueTextbox);

                    Interface.TextButton confirmButton = new Interface.TextButton();
                    confirmButton.Tag        = "Title Menu";
                    confirmButton.Text       = "Confirm";
                    confirmButton.Scale      = labelScale;
                    confirmButton.Position   = new Vector2(blueTextbox.Position.X + blueTextbox.CalculateDimensions().X + (int)Math.Round(padding * 1.5f), blueTextbox.Position.Y + confirmButton.Scale);
                    confirmButton.OnHover   += (sender2, e2) => { GameContent.Sound("titlemenu_buttonhover").Play(0.5f, 1.0f, 0.0f); };
                    confirmButton.OnRelease += (sender2, e2) => { GameContent.Sound("titlemenu_buttonclick").Play(0.5f, 1.0f, 0.0f); };
                    confirmButton.OnRelease += (sender2, e2) =>
                    {
                        Settings.SetValue <string>("Profile.Name", nameTextbox.Text);
                        Settings.SetValue <int>("Profile.Red", int.Parse(redTextbox.Text));
                        Settings.SetValue <int>("Profile.Green", int.Parse(greenTextbox.Text));
                        Settings.SetValue <int>("Profile.Blue", int.Parse(blueTextbox.Text));

                        SetPrompt(null);
                    };
                    profilePanel.Add(confirmButton);
                }
            };
            titleMenuPanel.Add(manageYourProfileButton);

            Interface.TextButton connectToServerButton = new Interface.TextButton();
            connectToServerButton.Tag        = "Title Menu";
            connectToServerButton.Text       = "Connect to a server";
            connectToServerButton.Position   = new Vector2(titleLabel.Position.X, padding + manageYourProfileButton.Position.Y + manageYourProfileButton.CalculateDimensions().Y);
            connectToServerButton.Scale      = labelScale;
            connectToServerButton.HoverMode  = Interface.TextButtonHoverMode.PointAt;
            connectToServerButton.OnHover   += (sender, e) => { GameContent.Sound("titlemenu_buttonhover").Play(0.5f, 1.0f, 0.0f); };
            connectToServerButton.OnRelease += (sender, e) => { GameContent.Sound("titlemenu_buttonclick").Play(0.5f, 1.0f, 0.0f); };
            connectToServerButton.OnRelease += (sender, e) =>
            {
                if (openPrompt != "Connect")
                {
                    SetPrompt("Connect");

                    Interface.Panel connectPanel = new Interface.Panel();
                    connectPanel.Tag         = "Prompt";
                    connectPanel.AutoSize    = true;
                    connectPanel.Position    = new Vector2(titleMenuPanel.Position.X, titleMenuPanel.Position.Y + titleMenuPanel.CalculateDimensions().Y + panelPadding + titleMenuPanel.BorderScale);
                    connectPanel.BorderScale = titleMenuPanel.BorderScale;
                    Interface.InterfaceManager.Add(connectPanel);

                    Interface.Label ipAddressLabel = new Interface.Label();
                    ipAddressLabel.Tag      = "Prompt";
                    ipAddressLabel.Text     = "IP Address";
                    ipAddressLabel.Position = new Vector2(padding, padding);
                    ipAddressLabel.Scale    = labelScale;
                    connectPanel.Add(ipAddressLabel);

                    Interface.TextBox ipAddressTextbox = new Interface.TextBox();
                    ipAddressTextbox.Tag         = "Prompt";
                    ipAddressTextbox.Text        = Settings.GetValueAsString("LastIP", "127.0.0.1");
                    ipAddressTextbox.Mode        = Interface.TextBoxInputMode.Numerical;
                    ipAddressTextbox.MaxLength   = 15;
                    ipAddressTextbox.Position    = new Vector2(padding, padding + ipAddressLabel.Position.Y + ipAddressLabel.CalculateDimensions().Y);
                    ipAddressTextbox.BorderScale = 2;
                    ipAddressTextbox.Scale       = labelScale;
                    connectPanel.Add(ipAddressTextbox);

                    Interface.Label portLabel = new Interface.Label();
                    portLabel.Tag      = "Prompt";
                    portLabel.Text     = "Port";
                    portLabel.Position = new Vector2(padding + ipAddressTextbox.Position.X + ipAddressTextbox.CalculateDimensions().X, padding);
                    portLabel.Scale    = labelScale;
                    connectPanel.Add(portLabel);

                    Interface.TextBox portTextbox = new Interface.TextBox();
                    portTextbox.Tag         = "Prompt";
                    portTextbox.Text        = Settings.GetValueAsString("LastPort", "25656");
                    portTextbox.Mode        = Interface.TextBoxInputMode.Numerical;
                    portTextbox.MaxLength   = 6;
                    portTextbox.Position    = new Vector2(padding + ipAddressLabel.Position.X + ipAddressTextbox.CalculateDimensions().X, padding + ipAddressLabel.Position.Y + ipAddressLabel.CalculateDimensions().Y);
                    portTextbox.BorderScale = 2;
                    portTextbox.Scale       = labelScale;
                    connectPanel.Add(portTextbox);

                    Interface.TextButton connectButton = new Interface.TextButton();
                    connectButton.Tag        = "Title Menu";
                    connectButton.Text       = "Connect";
                    connectButton.Scale      = labelScale;
                    connectButton.Position   = new Vector2(portTextbox.Position.X + portTextbox.CalculateDimensions().X + (int)Math.Round(padding * 1.5f), portTextbox.Position.Y + connectButton.Scale);
                    connectButton.OnHover   += (sender2, e2) => { GameContent.Sound("titlemenu_buttonhover").Play(0.5f, 1.0f, 0.0f); };
                    connectButton.OnRelease += (sender2, e2) => { GameContent.Sound("titlemenu_buttonclick").Play(0.5f, 1.0f, 0.0f); };
                    connectButton.OnRelease += (sender2, e2) =>
                    {
                        State = GameState.Connecting;
                        ConnectingScreen.Text         = "CONNECTING";
                        ConnectingScreen.CurrentColor = Color.White;
                        ConnectingScreen.DestColor    = Color.White;

                        Interface.InterfaceManager.RemoveAllWithTag("Title Menu");
                        Interface.InterfaceManager.RemoveAllWithTag("Prompt");

                        Timer.Create("FakeConnectionLatency", 3500, 1, () =>
                        {
                            Settings.SetValue <string>("LastIP", ipAddressTextbox.Text);
                            Settings.SetValue <int>("LastPort", int.Parse(portTextbox.Text));

                            Timer.Create("ConnectionTimeout", 6500, 1, () =>
                            {
                                if (NetworkHelper.Client.ConnectionStatus != Lidgren.Network.NetConnectionStatus.Connected)
                                {
                                    ConnectingScreen.Text      = "COULD NOT\n CONNECT";
                                    ConnectingScreen.DestColor = Color.Red;
                                    NetworkHelper.Disconnect();

                                    Timer.Create("ConnectionTimeoutBackToMenu", 3500, 1, () =>
                                    {
                                        State = GameState.AtMenu;
                                        CreateTitleMenu();
                                    });
                                }
                            });

                            NetworkHelper.Connect(ipAddressTextbox.Text, int.Parse(portTextbox.Text));
                        });
                    };
                    connectPanel.Add(connectButton);
                }
            };
            titleMenuPanel.Add(connectToServerButton);

            Interface.TextButton hostNewServerButton = new Interface.TextButton();
            hostNewServerButton.Tag        = "Title Menu";
            hostNewServerButton.Text       = "Host a new server";
            hostNewServerButton.Position   = new Vector2(titleLabel.Position.X, padding + connectToServerButton.Position.Y + connectToServerButton.CalculateDimensions().Y);
            hostNewServerButton.Scale      = labelScale;
            hostNewServerButton.HoverMode  = Interface.TextButtonHoverMode.PointAt;
            hostNewServerButton.OnHover   += (sender, e) => { GameContent.Sound("titlemenu_buttonhover").Play(0.5f, 1.0f, 0.0f); };
            hostNewServerButton.OnRelease += (sender, e) => { GameContent.Sound("titlemenu_buttonclick").Play(0.5f, 1.0f, 0.0f); };
            hostNewServerButton.OnRelease += (sender, e) =>
            {
                if (openPrompt != "Host")
                {
                    SetPrompt("Host");

                    Interface.Panel hostPanel = new Interface.Panel();
                    hostPanel.Tag         = "Prompt";
                    hostPanel.AutoSize    = true;
                    hostPanel.Position    = new Vector2(titleMenuPanel.Position.X, titleMenuPanel.Position.Y + titleMenuPanel.CalculateDimensions().Y + panelPadding + titleMenuPanel.BorderScale);
                    hostPanel.BorderScale = titleMenuPanel.BorderScale;
                    Interface.InterfaceManager.Add(hostPanel);

                    Interface.Label serverFileLabel = new Interface.Label();
                    serverFileLabel.Tag      = "Prompt";
                    serverFileLabel.Text     = "Server";
                    serverFileLabel.Position = new Vector2(padding, padding);
                    serverFileLabel.Scale    = labelScale;
                    hostPanel.Add(serverFileLabel);

                    Interface.TextBox serverFileTextBox = new Interface.TextBox();
                    serverFileTextBox.Tag         = "Prompt";
                    serverFileTextBox.Text        = "None selected.";
                    serverFileTextBox.MaxLength   = 23;
                    serverFileTextBox.Position    = new Vector2(padding, padding + serverFileLabel.Position.Y + serverFileLabel.CalculateDimensions().Y);
                    serverFileTextBox.BorderScale = 2;
                    serverFileTextBox.Scale       = labelScale;
                    serverFileTextBox.Color       = Color.Gray;
                    serverFileTextBox.Enabled     = false;
                    hostPanel.Add(serverFileTextBox);

                    Interface.TextButton serverFileBrowseButton = new Interface.TextButton();
                    serverFileBrowseButton.Tag        = "Prompt";
                    serverFileBrowseButton.Text       = "Browse";
                    serverFileBrowseButton.Scale      = 1;
                    serverFileBrowseButton.Position   = new Vector2(serverFileLabel.Position.X + serverFileLabel.CalculateDimensions().X + 4, serverFileLabel.Position.Y + serverFileLabel.CalculateDimensions().Y - serverFileBrowseButton.CalculateDimensions().Y);
                    serverFileBrowseButton.OnRelease += (sender2, e2) =>
                    {
                        OpenFileDialog fileDialog = new OpenFileDialog();
                        fileDialog.FileOk += (sender3, e3) =>
                        {
                            if (fileDialog.FileName.Length > 23)
                            {
                                serverFileTextBox.Text = "..." + fileDialog.FileName.Substring(fileDialog.FileName.Length - 20);
                            }
                            else
                            {
                                serverFileTextBox.Text = fileDialog.FileName;
                            }
                        };
                        fileDialog.ShowDialog();
                    };
                    hostPanel.Add(serverFileBrowseButton);

                    Interface.Label portLabel = new Interface.Label();
                    portLabel.Tag      = "Prompt";
                    portLabel.Text     = "Port";
                    portLabel.Position = new Vector2(padding + serverFileTextBox.Position.X + serverFileTextBox.CalculateDimensions().X, padding);
                    portLabel.Scale    = labelScale;
                    hostPanel.Add(portLabel);

                    Interface.TextBox portTextBox = new Interface.TextBox();
                    portTextBox.Tag         = "Prompt";
                    portTextBox.Text        = "25656";
                    portTextBox.Mode        = Interface.TextBoxInputMode.Numerical;
                    portTextBox.MaxLength   = 5;
                    portTextBox.Position    = new Vector2(padding + serverFileLabel.Position.X + serverFileTextBox.CalculateDimensions().X, padding + serverFileLabel.Position.Y + serverFileLabel.CalculateDimensions().Y);
                    portTextBox.BorderScale = 2;
                    portTextBox.Scale       = labelScale;
                    hostPanel.Add(portTextBox);

                    Interface.TextButton confirmButton = new Interface.TextButton();
                    confirmButton.Tag        = "Title Menu";
                    confirmButton.Text       = "Confirm";
                    confirmButton.Scale      = labelScale;
                    confirmButton.Position   = new Vector2(portTextBox.Position.X + portTextBox.CalculateDimensions().X + (int)Math.Round(padding * 1.5f), portTextBox.Position.Y + confirmButton.Scale);
                    confirmButton.OnHover   += (sender2, e2) => { GameContent.Sound("titlemenu_buttonhover").Play(0.5f, 1.0f, 0.0f); };
                    confirmButton.OnRelease += (sender2, e2) => { GameContent.Sound("titlemenu_buttonclick").Play(0.5f, 1.0f, 0.0f); };
                    confirmButton.OnRelease += (sender2, e2) =>
                    {
                        Interface.Label startingLabel = new Interface.Label();
                        startingLabel.Tag      = "Prompt";
                        startingLabel.Text     = "Starting server";
                        startingLabel.Position = new Vector2(hostPanel.Position.X, hostPanel.Position.Y + hostPanel.CalculateDimensions().Y + panelPadding + hostPanel.BorderScale);
                        startingLabel.Scale    = labelScale;
                        Interface.InterfaceManager.Add(startingLabel);

                        Timer.Create(null, 250, 3, () =>
                        {
                            startingLabel.Text += '.';
                        });

                        Timer.Create(null, 1000, 1, () =>
                        {
                            SetPrompt(null);

                            Process.Start("AphelionServer.exe", portTextBox.Text);

                            Timer.Create("RefocusFromServer", 100, 1, () =>
                            {
                                SwitchToThisWindow(Window.Handle, true);
                            });
                        });
                    };
                    hostPanel.Add(confirmButton);
                }
            };
            titleMenuPanel.Add(hostNewServerButton);

            Interface.TextButton instructionsButton = new Interface.TextButton();
            instructionsButton.Tag        = "Title Menu";
            instructionsButton.Text       = "Instructions";
            instructionsButton.Position   = new Vector2(titleLabel.Position.X, padding + hostNewServerButton.Position.Y + hostNewServerButton.CalculateDimensions().Y);
            instructionsButton.Scale      = labelScale;
            instructionsButton.HoverMode  = Interface.TextButtonHoverMode.PointAt;
            instructionsButton.OnHover   += (sender, e) => { GameContent.Sound("titlemenu_buttonhover").Play(0.5f, 1.0f, 0.0f); };
            instructionsButton.OnRelease += (sender, e) => { GameContent.Sound("titlemenu_buttonclick").Play(0.5f, 1.0f, 0.0f); };
            instructionsButton.OnRelease += (sender, e) =>
            {
                if (openPrompt != "Instructions")
                {
                    SetPrompt("Instructions");

                    Interface.Label openingLabel = new Interface.Label();
                    openingLabel.Tag      = "Prompt";
                    openingLabel.Text     = "Opening instructions";
                    openingLabel.Position = new Vector2(titleMenuPanel.Position.X, titleMenuPanel.Position.Y + titleMenuPanel.CalculateDimensions().Y + panelPadding + titleMenuPanel.BorderScale);
                    openingLabel.Scale    = labelScale;
                    Interface.InterfaceManager.Add(openingLabel);

                    Timer.Create(null, 250, 3, () =>
                    {
                        openingLabel.Text += '.';
                    });

                    Timer.Create(null, 1000, 1, () =>
                    {
                        SetPrompt(null);

                        using (RegistryKey registryKey = Registry.ClassesRoot.OpenSubKey(@"HTTP\Shell\Open\Command", false))
                        {
                            Process.Start(((string)registryKey.GetValue(null, null)).Split('"')[1], String.Format("file:///{0}/Instructions.html", Uri.EscapeUriString(Environment.CurrentDirectory.Replace('\\', '/'))));
                        }
                    });
                }
            };
            titleMenuPanel.Add(instructionsButton);

            Interface.TextButton optionsButton = new Interface.TextButton();
            optionsButton.Tag        = "Title Menu";
            optionsButton.Text       = "Options";
            optionsButton.Position   = new Vector2(titleLabel.Position.X, padding + instructionsButton.Position.Y + instructionsButton.CalculateDimensions().Y);
            optionsButton.Scale      = labelScale;
            optionsButton.HoverMode  = Interface.TextButtonHoverMode.PointAt;
            optionsButton.OnHover   += (sender, e) => { GameContent.Sound("titlemenu_buttonhover").Play(0.5f, 1.0f, 0.0f); };
            optionsButton.OnRelease += (sender, e) => { GameContent.Sound("titlemenu_buttonclick").Play(0.5f, 1.0f, 0.0f); };
            optionsButton.OnRelease += (sender, e) =>
            {
                if (openPrompt != "Options")
                {
                    SetPrompt("Options");

                    Interface.Panel optionsPanel = new Interface.Panel();
                    optionsPanel.Tag         = "Prompt";
                    optionsPanel.AutoSize    = true;
                    optionsPanel.Position    = new Vector2(titleMenuPanel.Position.X, titleMenuPanel.Position.Y + titleMenuPanel.CalculateDimensions().Y + panelPadding + titleMenuPanel.BorderScale);
                    optionsPanel.BorderScale = titleMenuPanel.BorderScale;
                    Interface.InterfaceManager.Add(optionsPanel);

                    Action <string, Type, object> AddOption = (name, type, defaultValue) =>
                    {
                        // TO DO ASAP: Finish this
                    };
                }
            };
            titleMenuPanel.Add(optionsButton);

            Interface.TextButton exitGameButton = new Interface.TextButton();
            exitGameButton.Tag        = "Title Menu";
            exitGameButton.Text       = "Exit Game";
            exitGameButton.Position   = new Vector2(titleLabel.Position.X, padding + optionsButton.Position.Y + optionsButton.CalculateDimensions().Y);
            exitGameButton.Scale      = labelScale;
            exitGameButton.HoverMode  = Interface.TextButtonHoverMode.PointAt;
            exitGameButton.OnHover   += (sender, e) => { GameContent.Sound("titlemenu_buttonhover").Play(0.5f, 1.0f, 0.0f); };
            exitGameButton.OnRelease += (sender, e) => { GameContent.Sound("titlemenu_buttonclick").Play(0.5f, 1.0f, 0.0f); };
            exitGameButton.OnRelease += (sender, e) =>
            {
                if (openPrompt != "Exit")
                {
                    SetPrompt("Exit");

                    Interface.Panel exitPanel = new Interface.Panel();
                    exitPanel.Tag         = "Prompt";
                    exitPanel.AutoSize    = true;
                    exitPanel.Position    = new Vector2(titleMenuPanel.Position.X, titleMenuPanel.Position.Y + titleMenuPanel.CalculateDimensions().Y + panelPadding + titleMenuPanel.BorderScale);
                    exitPanel.BorderScale = titleMenuPanel.BorderScale;
                    Interface.InterfaceManager.Add(exitPanel);

                    Interface.Label confirmLabel = new Interface.Label();
                    confirmLabel.Tag      = "Prompt";
                    confirmLabel.Text     = "Are you sure?";
                    confirmLabel.Position = new Vector2(padding, padding);
                    confirmLabel.Scale    = labelScale;
                    exitPanel.Add(confirmLabel);

                    Interface.TextButton yesButton = new Interface.TextButton();
                    yesButton.Tag        = "Prompt";
                    yesButton.Text       = "Yes";
                    yesButton.Position   = new Vector2(confirmLabel.Position.X, confirmLabel.Position.Y + padding + confirmLabel.CalculateDimensions().Y);
                    yesButton.Scale      = labelScale;
                    yesButton.OnHover   += (sender2, e2) => { GameContent.Sound("titlemenu_buttonhover").Play(0.5f, 1.0f, 0.0f); };
                    yesButton.OnRelease += (sender2, e2) => { GameContent.Sound("titlemenu_buttonclick").Play(0.5f, 1.0f, 0.0f); Exit(); };
                    exitPanel.Add(yesButton);

                    Interface.TextButton noButton = new Interface.TextButton();
                    noButton.Tag        = "Prompt";
                    noButton.Text       = "No";
                    noButton.Position   = new Vector2(yesButton.Position.X + yesButton.CalculateDimensions().X + topPadding, yesButton.Position.Y);
                    noButton.Scale      = labelScale;
                    noButton.OnHover   += (sender2, e2) => { GameContent.Sound("titlemenu_buttonhover").Play(0.5f, 1.0f, 0.0f); };
                    noButton.OnRelease += (sender2, e2) =>
                    {
                        GameContent.Sound("titlemenu_buttonclick").Play(0.5f, 1.0f, 0.0f);
                        SetPrompt(null);
                    };
                    exitPanel.Add(noButton);
                }
            };
            titleMenuPanel.Add(exitGameButton);

            titleMenuPanel.Position = new Vector2(ScreenBounds.X / 2 - titleMenuPanel.CalculateDimensions().X / 2, topPadding);

            Interface.Label debugInfoLabel = new Interface.Label();
            debugInfoLabel.Tag      = "Title Menu";
            debugInfoLabel.Text     = "APHELION (WIP) - DO NOT DISTRIBUTE";
            debugInfoLabel.Position = new Vector2(16 - 7, ScreenBounds.Y - debugInfoLabel.CalculateDimensions().Y - 8);
            Interface.InterfaceManager.Add(debugInfoLabel);
        }