public AnimationScreen(SpriteBatch b) : base(b, Color.DarkRed) { Name = "AnimatedScreen"; //SpriteSheet: Allows for animation with a single sprite sheet //FrameCollection: A collection of frames animated = new SpriteSheet(Vector2.Zero, b, FrameCollection.FromSpriteSheet(GLibXNASampleGame.Instance.Content.Load <Texture2D>("TestSpritesheet"), new Rectangle(99, 11, 45, 44), new Rectangle(150, 9, 45, 46), new Rectangle(198, 9, 45, 45), new Rectangle(252, 8, 45, 44), new Rectangle(303, 9, 45, 46), new Rectangle(351, 7, 45, 46), new Rectangle(396, 8, 45, 46), new Rectangle(444, 9, 45, 46), new Rectangle(495, 8, 45, 45), new Rectangle(552, 7, 45, 45))); animated.UseCenterAsOrigin = true; animated.Position = animated.GetCenterPosition(b.GraphicsDevice.Viewport); //FrameTime: The amount of time to spend on each frame animated.Frames.SetTimeAll(TimeSpan.FromMilliseconds(50)); //FrameChanged: An event fired upon frame change animated.FrameChanged += new EventHandler(animated_FrameChanged); AdditionalSprites.Add(new HitboxVisualizer(animated, b)); Sprites.Add(animated); }
public MultiplayerScreen(SpriteBatch sb) : base(sb, Color.Chocolate * 0.9f) { ClearColor.A = 255; Name = "MultiPlayer"; GLibXNASampleGame.Instance.SessionManagement.SessionsFound += new EventHandler <Glib.XNA.NetworkLib.NetworkSessionsFoundEventArgs>(SessionManagement_SessionsFound); GLibXNASampleGame.Instance.SessionManagement.SessionJoined += new EventHandler <Glib.XNA.NetworkLib.NetworkSessionJoinedEventArgs>(SessionManagement_SessionJoined); //See MainMenu for TextSprite sample comments title = new TextSprite(sb, GLibXNASampleGame.Instance.Content.Load <SpriteFont>("Title"), "Networking Sample", Color.Gold); title.Position = new Vector2(title.GetCenterPosition(Graphics.Viewport).X, 15); AdditionalSprites.Add(title); hostSession = new TextSprite(sb, new Vector2(0, title.Y + title.Height + 5), GLibXNASampleGame.Instance.Content.Load <SpriteFont>("MenuItem"), "Host Session", Color.MediumSpringGreen); hostSession.X = hostSession.GetCenterPosition(Graphics.Viewport).X; hostSession.IsHoverable = true; hostSession.HoverColor = Color.SpringGreen; hostSession.Pressed += new EventHandler(hostSession_Pressed); AdditionalSprites.Add(hostSession); joinSession = new TextSprite(sb, new Vector2(0, hostSession.Y + hostSession.Height + 5), GLibXNASampleGame.Instance.Content.Load <SpriteFont>("MenuItem"), "Join Session", Color.MediumSpringGreen); joinSession.X = joinSession.GetCenterPosition(Graphics.Viewport).X; joinSession.IsHoverable = true; joinSession.HoverColor = Color.SpringGreen; joinSession.Pressed += new EventHandler(joinSession_Pressed); AdditionalSprites.Add(joinSession); }
/// <summary> /// Creates and initializes the video player sample screen. /// </summary> /// <param name="spriteBatch">The <see cref="SpriteBatch"/> to render to.</param> public VideoPlayerScreen(SpriteBatch spriteBatch) : base(spriteBatch, Color.DarkGray) { Name = "VideoPlayer"; //Reduces the ARGB values, then resets alpha to 255 ClearColor *= 1f / 6f; ClearColor.A = 255; //See MainMenu for TextSprite sample comments title = new TextSprite(spriteBatch, GLibXNASampleGame.Instance.Content.Load <SpriteFont>("Title"), "VideoPlayer Sample", Color.PaleGoldenrod); title.Position = new Vector2(title.GetCenterPosition(spriteBatch.GraphicsDevice.Viewport).X, 15); AdditionalSprites.Add(title); escapeReturnDesc = new TextSprite(spriteBatch, GLibXNASampleGame.Instance.Content.Load <SpriteFont>("Details"), "Press escape\nto return to\nthe main menu", Color.PaleGoldenrod); escapeReturnDesc.Position = new Vector2(3); AdditionalSprites.Add(escapeReturnDesc); //This event is fired when a key is pressed KeyboardManager.KeyDown += new SingleKeyEventHandler(KeyboardManager_KeyDown); creditTextSprite = new TextSprite(spriteBatch, GLibXNASampleGame.Instance.Content.Load <SpriteFont>("Details"), "Video obtained from nps.gov/cany/planyourvisit/rivervideos.htm", Color.Goldenrod); creditTextSprite.Color.A = 32; creditTextSprite.Position = new Vector2(creditTextSprite.GetCenterPosition(spriteBatch.GraphicsDevice.Viewport).X, spriteBatch.GraphicsDevice.Viewport.Height - creditTextSprite.Height - 5); AdditionalSprites.Add(creditTextSprite); //VideoSprite: Like a sprite, but displays a video video = new VideoSprite(GLibXNASampleGame.Instance.Content.Load <Video>("VideoSample"), Vector2.Zero, spriteBatch); video.Video.Stop(); video.Position = video.GetCenterPosition(spriteBatch.GraphicsDevice.Viewport); Sprites.Add(video); }
public LoadingScreen(SpriteBatch sb) : base(sb, Color.DarkOliveGreen) { Name = "Loading"; loadingText = new TextSprite(sb, GLibXNASampleGame.Instance.Content.Load <SpriteFont>("Subtitle"), "Loading...", Color.Cornsilk); loadingText.Position = loadingText.GetCenterPosition(Graphics.Viewport); AdditionalSprites.Add(loadingText); }
public override void InitScreen(ScreenType screenType) { Texture2D image = GameContent.GameAssets.Images.NonPlayingObjects.Planet; Texture2D EMP = GameContent.GameAssets.Images.SecondaryWeapon[SecondaryWeaponType.EMP, TextureDisplayType.ShopDisplay]; Texture2D RayGun = GameContent.GameAssets.Images.SecondaryWeapon[SecondaryWeaponType.ShrinkRay, TextureDisplayType.ShopDisplay]; Texture2D Bomb = GameContent.GameAssets.Images.SecondaryWeapon[SecondaryWeaponType.SpaceMine, TextureDisplayType.ShopDisplay]; SpaceBucksAmount = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, GameContent.GameAssets.Fonts.NormalText, string.Format("You have {0} credits", StateManager.SpaceBucks), Color.White); SpaceBucksAmount.Position = new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width / 2 - SpaceBucksAmount.Width, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .1f); AdditionalSprites.Add(SpaceBucksAmount); SpriteFont font = GameContent.GameAssets.Fonts.NormalText; //EMP EMP weapon1 = new EMP(EMP, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * 0.6f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * 0.1f), Sprites.SpriteBatch); TextSprite text1 = new TextSprite(Sprites.SpriteBatch, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * 0.01f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * 0.1f), font, "\n\nAn electro magnetic pulse. \nThis device disables all \nnearby enemy ships \nwithin your ship's range. \n\ncost: 1000 credits", Color.White); weapon1.Scale = new Vector2(0.5f, 0.5f); itemsShown.Add(weapon1); //Ray Gun ShrinkRay weapon2 = new ShrinkRay(RayGun, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * 0.60f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * 0.2f), Sprites.SpriteBatch); weapon2.Scale = new Vector2(0.5f, 0.5f); itemsShown.Add(weapon2); //Space Mine SpaceMine weapon3 = new SpaceMine(Bomb, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * 0.69f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * 0.3f), Sprites.SpriteBatch); weapon3.Scale = new Vector2(2f, 2f); itemsShown.Add(weapon3); TextSprite text2 = new TextSprite(Sprites.SpriteBatch, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * 0.01f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * 0.1f), font, "\n\nThis weapon causes the targeted enemy\n to shrink losing 33% of their health. \nThis does not affect bosses.\n\ncost: 2000 credits", Color.White); TextSprite text3 = new TextSprite(Sprites.SpriteBatch, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * 0.01f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * 0.1f), font, "\n\nYou place this mine anywhere in space \nand when an enemy crashes into it the mine \nexplodes \n\ncost: 500 credits.", Color.White); items.Add(new KeyValuePair <Sprite, TextSprite>(weapon2, text2)); items.Add(new KeyValuePair <Sprite, TextSprite>(weapon3, text3)); ChangeItem += new EventHandler(WeaponSelectScreen_ChangeItem); items.Add(new KeyValuePair <Sprite, TextSprite>(weapon1, text1)); base.InitScreen(screenType); acceptLabel.Text = "Buy"; //In clicked code this.nextButtonClicked += new EventHandler(WeaponSelectScreen_nextButtonClicked); }
public GameLobbyScreen(SpriteBatch sb) : base(sb, Color.Gainsboro * 0.75f) { ClearColor.A = 255; Name = "NetworkLobby"; title = new TextSprite(sb, GLibXNASampleGame.Instance.Content.Load <SpriteFont>("Title"), "Lobby", Color.ForestGreen); title.X = title.GetCenterPosition(Graphics.Viewport).X; title.Y = 15; AdditionalSprites.Add(title); gamerList = new TextSprite(sb, GLibXNASampleGame.Instance.Content.Load <SpriteFont>("MenuItem"), "", Color.IndianRed); gamerList.Position = gamerList.GetCenterPosition(Graphics.Viewport); AdditionalSprites.Add(gamerList); KeyboardManager.KeyDown += new SingleKeyEventHandler(KeyboardManager_KeyDown); }
public override void InitScreen(ScreenType screenType) { base.InitScreen(screenType); //Add background to this screen this.BackgroundSprite = HorizontalMenuBGSprite.CurrentBG; Texture2D button = GameContent.GameAssets.Images.Controls.Button; SpriteFont font = GameContent.GameAssets.Fonts.NormalText; StateManager.Options.ScreenResolutionChanged += new EventHandler(Options_ScreenResolutionChanged); //Move Controls (aka Controls) ControlButton = new Sprite(button, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .06f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .1f), Sprites.SpriteBatch); #if WINDOWS ControlButton.MouseEnter += new EventHandler(ControlButton_MouseEnter); ControlButton.MouseLeave += new EventHandler(ControlButton_MouseLeave); #endif ControlLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, font, ("Controls")); ControlLabel.Position = new Vector2(ControlButton.Position.X + (ControlButton.Width / 2 - ControlLabel.Width / 2), ControlButton.Position.Y + (ControlButton.Height / 2 - ControlLabel.Height / 2)); ControlLabel.Color = Color.White; ControlLabel.IsManuallySelectable = true; ControlLabel.IsHoverable = true; ControlLabel.HoverColor = Color.MediumAquamarine; ControlLabel.NonHoverColor = Color.White; //GFX Sprite GraphicsButton = new Sprite(button, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .06f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .35f), Sprites.SpriteBatch); #if WINDOWS GraphicsButton.MouseEnter += new EventHandler(GraphicsButton_MouseEnter); GraphicsButton.MouseLeave += new EventHandler(GraphicsButton_MouseLeave); #endif GFXLabel = new TextSprite(Sprites.SpriteBatch, font, String.Format("GFX: {0}", StateManager.GraphicsManager.IsFullScreen ? "Full" : "Standard")); GFXLabel.Position = new Vector2((GraphicsButton.X + GraphicsButton.Width / 2) - GFXLabel.Width / 2, (GraphicsButton.Y + GraphicsButton.Height / 2) - GFXLabel.Height / 2); GFXLabel.Color = Color.White; GFXLabel.IsManuallySelectable = true; GFXLabel.IsHoverable = true; GFXLabel.HoverColor = Color.MediumAquamarine; GFXLabel.NonHoverColor = Color.White; //SFX Sprite SFXButton = new Sprite(button, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .5f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .10f), Sprites.SpriteBatch); #if WINDOWS SFXButton.MouseEnter += new EventHandler(SFXButton_MouseEnter); SFXButton.MouseLeave += new EventHandler(SFXButton_MouseLeave); #endif SFXLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, font, "SFX: " + (StateManager.Options.SFXEnabled ? "On" : "Off")); SFXLabel.Position = new Vector2((SFXButton.X + SFXButton.Width / 2) - SFXLabel.Width / 2, (SFXButton.Y + SFXButton.Height / 2) - SFXLabel.Height / 2); SFXLabel.Color = Color.White; SFXLabel.IsHoverable = true; SFXLabel.IsManuallySelectable = true; SFXLabel.HoverColor = Color.MediumAquamarine; SFXLabel.NonHoverColor = Color.White; //Back button Sprite BackButton = new Sprite(button, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .06f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .60f), Sprites.SpriteBatch); BackLabel = new TextSprite(Sprites.SpriteBatch, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .139f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .62f), GameContent.GameAssets.Fonts.NormalText, "Back"); BackLabel.Color = Color.White; #if WINDOWS BackButton.MouseEnter += new EventHandler(BackButton_MouseEnter); BackButton.MouseLeave += new EventHandler(BackButton_MouseLeave); #endif //Music (volume; currently on/off) Sprite MusicButton = new Sprite(button, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .5f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .35f), Sprites.SpriteBatch); MusicButton.Color = Color.White; #if WINDOWS MusicButton.MouseEnter += new EventHandler(MusicButton_MouseEnter); MusicButton.MouseLeave += new EventHandler(MusicButton_MouseLeave); #endif MusicVolumeLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, font, "Music: " + (StateManager.Options.MusicEnabled ? "On" : "Off")); MusicVolumeLabel.Position = new Vector2((MusicButton.X + MusicButton.Width / 2) - MusicVolumeLabel.Width / 2, (MusicButton.Y + MusicButton.Height / 2) - MusicVolumeLabel.Height / 2); MusicVolumeLabel.Color = Color.White; MusicVolumeLabel.IsHoverable = true; MusicVolumeLabel.IsManuallySelectable = true; MusicVolumeLabel.HoverColor = Color.MediumAquamarine; MusicVolumeLabel.NonHoverColor = Color.White; //Add all buttons Sprites.Add(ControlButton); Sprites.Add(GraphicsButton); Sprites.Add(SFXButton); Sprites.Add(BackButton); Sprites.Add(MusicButton); //Add all text sprites AdditionalSprites.Add(ControlLabel); AdditionalSprites.Add(GFXLabel); AdditionalSprites.Add(SFXLabel); AdditionalSprites.Add(BackLabel); AdditionalSprites.Add(MusicVolumeLabel); #if XBOX AllButtons = new GamePadButtonEnumerator(new TextSprite[, ] { { ControlLabel, SFXLabel }, { GFXLabel, MusicVolumeLabel }, { BackLabel, null } }, InputType.LeftJoystick); AllButtons.ButtonPress += new EventHandler(AllButtons_ButtonPress); ControlLabel.IsSelected = true; #endif StateManager.Options.ScreenResolutionChanged += new EventHandler(Options_ScreenResolutionChanged); }
/// <summary> /// Creates and initializes the main menu. /// </summary> /// <param name="sb">The <see cref="SpriteBatch"/> to render to.</param> public MainMenu(SpriteBatch sb) : base(sb, Color.Lime) { Name = "MainMenu"; //TextureFactory: Creates textures at runtime TextureFactory factory = new TextureFactory(sb.GraphicsDevice); //Sprite: A simple bitmap image, with convenient methods and properties //Yet it has so many possibilities... //Here it is used as a mouse cursor //Star image courtesy of Wikimedia user Felipe Micaroni Lalli //Image obtained from http://commons.wikimedia.org/wiki/File:Star_Ouro.svg mouseCursor = new Sprite(GLibXNASampleGame.Instance.Content.Load <Texture2D>("Star"), Vector2.Zero, sb); mouseCursor.Scale = new Vector2(.1f); mouseCursor.UseCenterAsOrigin = true; //OverlayImage overlays the second image onto the first (not in place) Texture2D imageOverlay = factory.CreateSquare(15, Color.DarkGray * 0.65F); TextureFactory.OverlayImage(imageOverlay, factory.CreateSquare(11, Color.Black * 0.75F), new Point(2, 2)); TextureFactory.OverlayImage(imageOverlay, factory.CreateSquare(7, Color.DarkOrange * 0.85F), new Point(4, 4)); TextureFactory.OverlayImage(imageOverlay, factory.CreateSquare(3, Color.DarkRed * 0.95F), new Point(6, 6)); fadingImage = new Sprite(imageOverlay, Vector2.Zero, sb); fadingImage.Position = new Vector2(15, 25); //The CreateFade method creates an array of textures, each one closer to the final texture than the last //It is used for fades Texture2D finalFadeImage = factory.CreateRectangle(fadingImage.Texture.Width, fadingImage.Texture.Height, Color.Red); TextureFactory.OverlayImage(finalFadeImage, factory.CreateHollowRectangle(fadingImage.Texture.Width - 4, fadingImage.Texture.Height - 4, Color.DarkRed), new Point(2, 2)); fades = TextureFactory.CreateFade(fadingImage.Texture, finalFadeImage, 300); mouseBoundingBox = new Sprite(factory.CreateHollowCircle((mouseCursor.Width / 2).Round(), Color.Navy), mouseCursor.Position, sb) { UseCenterAsOrigin = true }; //TextSprite: Displays text //Can be used for titles, descriptions, etc title = new TextSprite(sb, GLibXNASampleGame.Instance.Content.Load <SpriteFont>("Title"), "GlenLibrary XNA"); //Extension method: GetCenterPosition: Returns the position required to center the object on the specified viewport title.Position = new Vector2(title.GetCenterPosition(sb.GraphicsDevice.Viewport).X, 15); //Fancy color constructor: Uses a Vector4 with RGBA values expressed as floats from 0 to 1, basically dark gray shadow with 128 alpha title.Shadow = new TextShadow(title, new Vector2(-2, 2), new Color(new Vector4(Color.DarkGray.ToVector3(), 0.5f))); AdditionalSprites.Add(title); desc = new TextSprite(sb, GLibXNASampleGame.Instance.Content.Load <SpriteFont>("Subtitle"), "A general purpose XNA library", Color.Chocolate); desc.Color *= 0.75f; desc.Color.A = 255; desc.X = desc.GetCenterPosition(Graphics.Viewport).X; desc.Y = title.Y + title.Height + 5; AdditionalSprites.Add(desc); //Add items to the buttons dictionary buttons.Add("Video Player", "VideoPlayer"); buttons.Add("Multiplayer", "MultiPlayer"); buttons.Add("Animated Sprite", "AnimatedScreen"); #region Generation of buttons systematically float yCoord = desc.Y + desc.Height + 10; foreach (var element in buttons) { Sprite buttonSprite = new Sprite(GLibXNASampleGame.Instance.TextureCreator.CreateSquare(1, Color.Red), Vector2.Zero, sb); TextSprite button = new TextSprite(sb, GLibXNASampleGame.Instance.Content.Load <SpriteFont>("MenuItem"), element.Key); //Allows hovering (and therefore clicking) on a sprite button.IsHoverable = true; // These are the colors that are displayed at the various hovering states button.HoverColor = Color.DarkCyan; button.NonHoverColor = Color.Black; // "Pressed" event handler lambda expression button.Pressed += (src, args) => GLibXNASampleGame.Instance.SetScreen(buttons[((TextSprite)src).Text]); // Setting width and height on a Sprite scales it buttonSprite.Width = button.Width + 6; buttonSprite.Height = button.Height + 4; buttonSprite.Position = new Vector2(buttonSprite.GetCenterPosition(sb.GraphicsDevice.Viewport).X, yCoord); // ParentSprite: Allows for a "button" behind a clickable TextSprite (or not clickable), all collision and position logic done with this sprite button.ParentSprite = buttonSprite; // Round to look better button.Scale.X = button.Scale.X.Round(); button.Scale.Y = button.Scale.Y.Round(); button.X = button.X.Round(); button.Y = button.Y.Round(); Sprites.Add(buttonSprite); AdditionalSprites.Add(button); yCoord += buttonSprite.Height; yCoord += 7.5f; yCoord = yCoord.Round(); } #endregion // ProgressBar: A dynamically generated progress bar, could be used to represent asset loading progress // Here it is just used for effects :-) progressBar = new ProgressBar(Vector2.Zero, _filledColors[0], _emptyColors[0], sb); //HeightScale: The progress bar shall be 7 pixels high progressBar.HeightScale = 7; progressBar.Denominator = Graphics.Viewport.Width - 20; progressBar.Value = 0; progressBar.X = progressBar.GetCenterPosition(sb.GraphicsDevice.Viewport).X; progressBar.Y = Graphics.Viewport.Height - progressBar.Height - 5; Sprites.Add(progressBar); caption = new TextSprite(sb, GLibXNASampleGame.Instance.Content.Load <SpriteFont>("Details"), "A caption!"); caption.X = caption.GetCenterPosition(Graphics.Viewport).X; caption.Y = progressBar.Y - caption.Height - 2; caption.Visible = false; AdditionalSprites.Add(caption); // Random Particle Generator: A particle generator that uses a Random instance to set properties of the generated particles RandomParticleGenerator particlegen = new RandomParticleGenerator(sb, GLibXNASampleGame.Instance.Content.Load <Texture2D>("Star")); particlegen.MinimumParticleColorChangeRate = 0.925f; particlegen.MinimumTimeToLive = TimeSpan.FromMilliseconds(400); particlegen.MaximumTimeToLive = TimeSpan.FromMilliseconds(780); particlegen.ParticlesToGenerate = 1; particlegen.ScaleFactor = 15; // TimeToLiveSettings: When to make a particle expire, binary flaggable enumerator particlegen.TTLSettings = TimeToLiveSettings.AlphaLess100 | TimeToLiveSettings.StrictTTL; // Particle engine: Generates particles using the specified particle generator mouseParticleGen = new ParticleEngine(particlegen); mouseParticleGen.FramesPerGeneration = 3; mouseParticleGen.Tracked = mouseCursor; AdditionalSprites.Add(mouseParticleGen); AdditionalSprites.Add(mouseCursor); AdditionalSprites.Add(mouseBoundingBox); Sprites.Add(fadingImage); }
public override void InitScreen(ScreenType screenType) { base.InitScreen(screenType); Texture2D buttonImage = GameContent.GameAssets.Images.Controls.Button; SpriteFont SegoeUIMono = GameContent.GameAssets.Fonts.NormalText; acceptButton = new Sprite(buttonImage, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .7f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .8f), Sprites.SpriteBatch); acceptLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, SegoeUIMono, "Play"); acceptLabel.Position = new Vector2((acceptButton.X + acceptButton.Width / 2) - acceptLabel.Width / 2, (acceptButton.Y + acceptButton.Height / 2) - acceptLabel.Height / 2); acceptLabel.Color = Color.White; acceptLabel.IsHoverable = true; acceptLabel.IsManuallySelectable = true; acceptLabel.NonHoverColor = Color.White; acceptLabel.HoverColor = Color.MediumAquamarine; #if WINDOWS acceptButton.MouseEnter += new EventHandler(playButton_MouseEnter); acceptButton.MouseLeave += new EventHandler(playButton_MouseLeave); #endif Sprites.Add(acceptButton); AdditionalSprites.Add(acceptLabel); Sprite backButton = new Sprite(buttonImage, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .06f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .8f), Sprites.SpriteBatch); backLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, SegoeUIMono, "Back"); backLabel.Position = new Vector2((backButton.X + backButton.Width / 2) - backLabel.Width / 2, (backButton.Y + backButton.Height / 2) - backLabel.Height / 2); backLabel.Color = Color.White; backLabel.IsHoverable = true; backLabel.IsManuallySelectable = true; backLabel.NonHoverColor = Color.White; backLabel.HoverColor = Color.MediumAquamarine; #if WINDOWS backButton.MouseEnter += new EventHandler(backButton_MouseEnter); backButton.MouseLeave += new EventHandler(backButton_MouseLeave); #endif Sprites.Add(backButton); AdditionalSprites.Add(backLabel); Sprite leftButton = new Sprite(buttonImage, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .5f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .5f), Sprites.SpriteBatch); leftButton.Scale = new Vector2(0.5f, 1); leftLabel = new TextSprite(Sprites.SpriteBatch, new Vector2(5, 5), SegoeUIMono, "<<<"); leftLabel.Position = new Vector2((leftButton.X + leftButton.Width / 2) - leftLabel.Width / 2, (leftButton.Y + leftButton.Height / 2) - leftLabel.Height / 2); leftLabel.Color = Color.White; leftLabel.IsHoverable = true; leftLabel.IsManuallySelectable = true; leftLabel.NonHoverColor = Color.White; leftLabel.HoverColor = Color.MediumAquamarine; #if WINDOWS leftButton.MouseEnter += new EventHandler(leftButton_MouseEnter); leftButton.MouseLeave += new EventHandler(leftButton_MouseLeave); #endif Sprites.Add(leftButton); AdditionalSprites.Add(leftLabel); Sprite rightButton = new Sprite(buttonImage, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .9f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .5f), Sprites.SpriteBatch); rightButton.Scale = new Vector2(0.5f, 1); rightLabel = new TextSprite(Sprites.SpriteBatch, new Vector2(5, 5), SegoeUIMono, ">>>"); rightLabel.Position = new Vector2((rightButton.X + rightButton.Width / 2) - rightLabel.Width / 2, (rightButton.Y + rightButton.Height / 2) - rightLabel.Height / 2); rightLabel.Color = Color.White; rightLabel.IsHoverable = true; rightLabel.IsManuallySelectable = true; rightLabel.NonHoverColor = Color.White; rightLabel.HoverColor = Color.MediumAquamarine; #if WINDOWS rightButton.MouseEnter += new EventHandler(rightButton_MouseEnter); rightButton.MouseLeave += new EventHandler(rightButton_MouseLeave); #endif Sprites.Add(rightButton); AdditionalSprites.Add(rightLabel); nameLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, SegoeUIMono, "Name Of Item"); //right side of left button //left of right button //right side of left button nameLabel.Position = new Vector2(((leftButton.X + leftButton.Texture.Width * leftButton.Scale.X) + (rightButton.X - (leftButton.X + leftButton.Texture.Width * leftButton.Scale.X)) / 2) - nameLabel.Width * .5f, (leftButton.Y + leftButton.Texture.Height / 2) - nameLabel.Height / 2); nameLabel.Color = Color.White; AdditionalSprites.Add(nameLabel); for (int i = 0; i < items.Count; i++) { if (i != 0) { items[i].Key.Color = Color.Transparent; items[i].Value.Color = Color.Transparent; } Sprites.Add(items[i].Key); AdditionalSprites.Add(items[i].Value); } if (ChangeItem != null) { ChangeItem(this, new EventArgs()); } }
public override void InitScreen(ScreenType screenType) { base.InitScreen(screenType); Texture2D button = GameContent.GameAssets.Images.Controls.Button; StateManager.Options.ScreenResolutionChanged += new EventHandler(Options_ScreenResolutionChanged); PauseLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, GameContent.GameAssets.Fonts.BoldText, "Paused"); PauseLabel.Position = new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width / 2 - PauseLabel.Width / 2, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .1f); PauseLabel.Color = Color.White; AdditionalSprites.Add(PauseLabel); ResumeButton = new Sprite(button, Vector2.Zero, Sprites.SpriteBatch); ResumeButton.Position = new Vector2(ResumeButton.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .2f); #if WINDOWS ResumeButton.MouseEnter += new EventHandler(ResumeButton_MouseEnter); ResumeButton.MouseLeave += new EventHandler(ResumeButton_MouseLeave); #endif Sprites.Add(ResumeButton); ExitButton = new Sprite(button, new Vector2(ResumeButton.X, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .8f), Sprites.SpriteBatch); #if WINDOWS ExitButton.MouseEnter += new EventHandler(BackButton_MouseEnter); ExitButton.MouseLeave += new EventHandler(BackButton_MouseLeave); #endif Sprites.Add(ExitButton); ResumeLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, GameContent.GameAssets.Fonts.NormalText, "Resume"); ResumeLabel.Position = new Vector2(ResumeLabel.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X, ResumeButton.Y + (ResumeButton.Height / 2 - ResumeLabel.Height / 2)); ResumeLabel.Color = Color.White; ResumeLabel.IsHoverable = true; ResumeLabel.IsManuallySelectable = true; ResumeLabel.HoverColor = Color.MediumAquamarine; ResumeLabel.NonHoverColor = Color.White; AdditionalSprites.Add(ResumeLabel); ExitLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, GameContent.GameAssets.Fonts.NormalText, "Exit"); ExitLabel.Position = new Vector2(ExitLabel.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X, ExitButton.Y + (ExitButton.Height / 2 - ExitLabel.Height / 2)); ExitLabel.Color = Color.White; ExitLabel.IsHoverable = true; ExitLabel.IsManuallySelectable = true; ExitLabel.HoverColor = Color.MediumAquamarine; ExitLabel.NonHoverColor = Color.White; AdditionalSprites.Add(ExitLabel); ShopButton = new Sprite(button, Vector2.Zero, Sprites.SpriteBatch); ShopButton.Position = new Vector2(ResumeButton.X, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .53f); #if WINDOWS ShopButton.MouseEnter += new EventHandler(ShopButton_MouseEnter); ShopButton.MouseLeave += new EventHandler(ShopButton_MouseLeave); #endif Sprites.Add(ShopButton); ShopLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, GameContent.GameAssets.Fonts.NormalText, "Shop"); ShopLabel.Position = new Vector2(ShopLabel.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X, ShopButton.Y + (ShopButton.Height / 2 - ShopLabel.Height / 2)); ShopLabel.Color = Color.White; ShopLabel.IsHoverable = true; ShopLabel.IsManuallySelectable = true; ShopLabel.HoverColor = Color.MediumAquamarine; ShopLabel.NonHoverColor = Color.White; AdditionalSprites.Add(ShopLabel); OptionButton = new Sprite(button, Vector2.Zero, Sprites.SpriteBatch); OptionButton.Position = new Vector2(ResumeButton.X, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .37f); #if WINDOWS OptionButton.MouseEnter += new EventHandler(OptionButton_MouseEnter); OptionButton.MouseLeave += new EventHandler(OptionButton_MouseLeave); #endif Sprites.Add(OptionButton); OptionsLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, GameContent.GameAssets.Fonts.NormalText, "Options"); OptionsLabel.Position = new Vector2(OptionsLabel.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X, OptionButton.Y + (OptionButton.Height / 2 - OptionsLabel.Height / 2)); OptionsLabel.Color = Color.White; OptionsLabel.IsHoverable = true; OptionsLabel.IsManuallySelectable = true; OptionsLabel.HoverColor = Color.MediumAquamarine; OptionsLabel.NonHoverColor = Color.White; AdditionalSprites.Add(OptionsLabel); }
public override void InitScreen(ScreenType screenType) { base.InitScreen(screenType); //Adding a background this.BackgroundSprite = HorizontalMenuBGSprite.CurrentBG; Texture2D button = GameContent.GameAssets.Images.Controls.Button; SpriteFont font = GameContent.GameAssets.Fonts.NormalText; #if XBOX MoveLabel = new TextSprite(Sprites.SpriteBatch, font, ("Move: Right Joystick")); MoveLabel.Position = new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .06f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .1f); MoveLabel.Color = Color.White; #endif #if WINDOWS MoveLabel = new TextSprite(Sprites.SpriteBatch, font, String.Format("Move:{0}", StateManager.Options.LeftButtonEnabled ? "Arrow Keys" : "WASD")); MoveButton = new Sprite(button, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .06f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .1f), Sprites.SpriteBatch); MoveLabel.Position = new Vector2((MoveButton.X + MoveButton.Width / 2) - MoveLabel.Width / 2, (MoveButton.Y + MoveButton.Height / 2) - MoveLabel.Height / 2); MoveLabel.Color = Color.White; MoveLabel.IsManuallySelectable = true; MoveLabel.IsHoverable = true; MoveLabel.HoverColor = Color.MediumAquamarine; MoveLabel.NonHoverColor = Color.White; MoveButton.MouseEnter += new EventHandler(MoveButton_MouseEnter); MoveButton.MouseLeave += new EventHandler(MoveButton_MouseLeave); #endif #if XBOX FireLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, font, ("Fire: RTrigger")); FireLabel.Position = new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .06f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .35f); FireLabel.Color = Color.White; #endif #if WINDOWS FireLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, font, String.Format("Fire:{0}", StateManager.Options.ArrowKeysEnabled ? "LClick" : "Space")); FireButton = new Sprite(button, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .06f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .35f), Sprites.SpriteBatch); FireLabel.Position = new Vector2(FireButton.Position.X + (FireButton.Width / 2 - FireLabel.Width / 2), FireButton.Position.Y + (FireButton.Height / 2 - FireLabel.Height / 2)); FireLabel.Color = Color.White; FireLabel.IsManuallySelectable = true; FireLabel.IsHoverable = true; FireLabel.HoverColor = Color.MediumAquamarine; FireLabel.NonHoverColor = Color.White; FireButton.MouseEnter += new EventHandler(FireButton_MouseEnter); FireButton.MouseLeave += new EventHandler(FireButton_MouseLeave); #endif #if WINDOWS SecondWeapLabel = new TextSprite(Sprites.SpriteBatch, font, ("Use Secondary Weapon: RClick")); SecondWeapLabel.Position = new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .4f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .1f); SecondWeapLabel.Color = Color.White; #endif #if XBOX SecondWeapLabel = new TextSprite(Sprites.SpriteBatch, font, ("Use Secondary Weapon: LTrigger")); SecondWeapLabel.Position = new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .4f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .10f); SecondWeapLabel.Color = Color.White; #endif #if WINDOWS SwitchSecondWeapLabel = new TextSprite(Sprites.SpriteBatch, font, ("Switch Secondary Weapons: Scroll Wheel")); SwitchSecondWeapLabel.Position = new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .4f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .35f); SwitchSecondWeapLabel.Color = Color.White; #endif #if XBOX SwitchSecondWeapLabel = new TextSprite(Sprites.SpriteBatch, font, ("Switch Secondary Weapons: \n Left and Right Bumpers")); SwitchSecondWeapLabel.Position = new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .4f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .35f); SwitchSecondWeapLabel.Color = Color.White; #endif #if WINDOWS DeployDronesLabel = new TextSprite(Sprites.SpriteBatch, font, ("Deploy Fighter Carrier Drones: LShift")); DeployDronesLabel.Position = new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .4f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .6f); DeployDronesLabel.Color = Color.White; #endif #if XBOX DeployDronesLabel = new TextSprite(Sprites.SpriteBatch, font, ("Deploy Fighter Carrier Drones: A Button")); DeployDronesLabel.Position = new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .4f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .60f); DeployDronesLabel.Color = Color.White; #endif BackButton = new Sprite(button, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .06f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .60f), Sprites.SpriteBatch); BackLabel = new TextSprite(Sprites.SpriteBatch, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .139f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .62f), GameContent.GameAssets.Fonts.NormalText, "Back"); BackLabel.Position = new Vector2((BackButton.X + BackButton.Width / 2) - BackLabel.Width / 2, (BackButton.Y + BackButton.Height / 2) - BackLabel.Height / 2); BackLabel.Color = Color.White; BackLabel.IsManuallySelectable = true; BackLabel.IsHoverable = true; BackLabel.HoverColor = Color.MediumAquamarine; BackLabel.NonHoverColor = Color.White; #if WINDOWS BackButton.MouseEnter += new EventHandler(BackButton_MouseEnter); BackButton.MouseLeave += new EventHandler(BackButton_MouseLeave); #endif //Add all buttons #if WINDOWS Sprites.Add(MoveButton); Sprites.Add(FireButton); #endif Sprites.Add(BackButton); //Add all text sprites AdditionalSprites.Add(BackLabel); AdditionalSprites.Add(MoveLabel); AdditionalSprites.Add(FireLabel); AdditionalSprites.Add(SecondWeapLabel); AdditionalSprites.Add(SwitchSecondWeapLabel); AdditionalSprites.Add(DeployDronesLabel); StateManager.Options.ScreenResolutionChanged += new EventHandler(Options_ScreenResolutionChanged); }
public override void InitScreen(ScreenType screnType) { base.InitScreen(screnType); _gameSong = GameContent.GameAssets.Music[ScreenMusic.Level1]; StateManager.Options.MusicStateChanged += new EventHandler(Options_MusicStateChanged); StateManager.ScreenStateChanged += new EventHandler(delegate(object src, EventArgs arg) { if (Visible) { if (StateManager.Options.MusicEnabled) { if (MediaPlayer.State == MediaState.Paused) { MediaPlayer.Resume(); } else { MediaPlayer.Play(_gameSong); } } else { MediaPlayer.Stop(); } } }); Texture2D planetTexture = GameContent.GameAssets.Images.NonPlayingObjects.Planet; Texture2D altPlanetTexture = GameContent.GameAssets.Images.NonPlayingObjects.AltPlanet; Texture2D buttonImage = GameContent.GameAssets.Images.Controls.Button; SpriteFont SegoeUIMono = GameContent.GameAssets.Fonts.NormalText; StateManager.Options.ScreenResolutionChanged += new EventHandler(Options_ScreenResolutionChanged); this.BackgroundSprite = HorizontalMenuBGSprite.CurrentBG; TitleSprite = new Sprite(GameContent.GameAssets.Images.Controls.Title, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .05f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .07f), Sprites.SpriteBatch); Sprites.Add(TitleSprite); planet = new Sprite(altPlanetTexture, Vector2.Zero, Sprites.SpriteBatch); planet.Position = new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * 0.6f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .1515f); planet.Scale = new Vector2(.7f); Sprites.Add(planet); planettwo = new Sprite(planetTexture, Vector2.Zero, Sprites.SpriteBatch); planettwo.Position = new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * 0.8f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .75f); planettwo.Scale = new Vector2(1f); Sprites.Add(planettwo); SinglePlayerButton = new Sprite(buttonImage, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .06f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .21f), Sprites.SpriteBatch); Sprites.Add(SinglePlayerButton); SinglePlayerLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, SegoeUIMono, "Singleplayer"); SinglePlayerLabel.IsHoverable = true; SinglePlayerLabel.NonHoverColor = Color.White; SinglePlayerLabel.HoverColor = Color.MediumAquamarine; SinglePlayerLabel.ParentSprite = SinglePlayerButton; AdditionalSprites.Add(SinglePlayerLabel); MultiPlayerButton = new Sprite(buttonImage, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .06f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .405f), Sprites.SpriteBatch); Sprites.Add(MultiPlayerButton); MultiPlayerLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, SegoeUIMono, "Multiplayer"); MultiPlayerLabel.IsHoverable = true; MultiPlayerLabel.NonHoverColor = Color.White; MultiPlayerLabel.HoverColor = Color.MediumAquamarine; MultiPlayerLabel.ParentSprite = MultiPlayerButton; AdditionalSprites.Add(MultiPlayerLabel); BackButton = new Sprite(buttonImage, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .06f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .60f), Sprites.SpriteBatch); Sprites.Add(BackButton); BackLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, SegoeUIMono, "Exit"); BackLabel.IsHoverable = true; BackLabel.ParentSprite = BackButton; BackLabel.NonHoverColor = Color.White; BackLabel.HoverColor = Color.MediumAquamarine; AdditionalSprites.Add(BackLabel); OptionsButton = new Sprite(buttonImage, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .362f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .21f), Sprites.SpriteBatch); Sprites.Add(OptionsButton); OptionsLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, SegoeUIMono, "Options"); OptionsLabel.ParentSprite = OptionsButton; OptionsLabel.IsHoverable = true; OptionsLabel.NonHoverColor = Color.White; OptionsLabel.HoverColor = Color.MediumAquamarine; AdditionalSprites.Add(OptionsLabel); CreditsButton = new Sprite(buttonImage, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .362f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .405f), Sprites.SpriteBatch); Sprites.Add(CreditsButton); CreditsLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, SegoeUIMono, "Credits"); CreditsLabel.IsHoverable = true; CreditsLabel.ParentSprite = CreditsButton; CreditsLabel.NonHoverColor = Color.White; CreditsLabel.HoverColor = Color.MediumAquamarine; AdditionalSprites.Add(CreditsLabel); #if XBOX AllButtons = new GamePadButtonEnumerator(new TextSprite[, ] { { SinglePlayerLabel, OptionsLabel }, { MultiPlayerLabel, CreditsLabel }, { BackLabel, null } }, InputType.LeftJoystick); AllButtons.ButtonPress += new EventHandler(AllButtons_ButtonPress); SinglePlayerLabel.IsSelected = true; #elif WINDOWS BackLabel.Clicked += new EventHandler(delegate(object src, EventArgs e) { if (elapsedButtonDelay > totalButtonDelay) { StateManager.Exit(); } }); CreditsLabel.Clicked += new EventHandler(delegate(object src, EventArgs e) { if (elapsedButtonDelay > totalButtonDelay) { StateManager.ScreenState = ScreenType.Credits; } }); OptionsLabel.Clicked += new EventHandler(delegate(object src, EventArgs e) { if (elapsedButtonDelay > totalButtonDelay) { StateManager.ScreenState = ScreenType.Options; } }); SinglePlayerLabel.Clicked += new EventHandler(delegate(object src, EventArgs e) { if (elapsedButtonDelay > totalButtonDelay) { StateManager.ScreenState = ScreenType.ShipSelect; } }); #endif }
public override void InitScreen(ScreenType screenName) { base.InitScreen(screenName); StateManager.Options.ScreenResolutionChanged += new EventHandler(Options_ScreenResolutionChanged); Texture2D buttonImage = GameContent.GameAssets.Images.Controls.Button; SpriteFont SegoeUIMono = GameContent.GameAssets.Fonts.NormalText; BackgroundSprite = HorizontalMenuBGSprite.CurrentBG; Sprite upgradeEquipmentButton = new Sprite(buttonImage, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .1f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .4f), Sprites.SpriteBatch); upgradeEquipmentLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, SegoeUIMono, "Equipment"); upgradeEquipmentLabel.Position = new Vector2((upgradeEquipmentButton.X + upgradeEquipmentButton.Width / 2) - upgradeEquipmentLabel.Width / 2, (upgradeEquipmentButton.Y + upgradeEquipmentButton.Height / 2) - upgradeEquipmentLabel.Height / 2); upgradeEquipmentLabel.Color = Color.White; upgradeEquipmentLabel.IsHoverable = true; upgradeEquipmentLabel.IsManuallySelectable = true; upgradeEquipmentLabel.NonHoverColor = Color.White; upgradeEquipmentLabel.HoverColor = Color.MediumAquamarine; #if WINDOWS upgradeEquipmentButton.MouseEnter += new EventHandler(upgradeEButton_MouseEnter); upgradeEquipmentButton.MouseLeave += new EventHandler(upgradeEButton_MouseLeave); #endif Sprites.Add(upgradeEquipmentButton); AdditionalSprites.Add(upgradeEquipmentLabel); Sprite shipButton = new Sprite(buttonImage, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .400f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .4f), Sprites.SpriteBatch); shipLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, SegoeUIMono, "Ship"); shipLabel.Position = new Vector2((shipButton.X + shipButton.Width / 2) - shipLabel.Width / 2, (shipButton.Y + shipButton.Height / 2) - shipLabel.Height / 2); shipLabel.Color = Color.White; shipLabel.IsHoverable = true; shipLabel.IsManuallySelectable = true; shipLabel.NonHoverColor = Color.White; shipLabel.HoverColor = Color.MediumAquamarine; #if WINDOWS shipButton.MouseEnter += new EventHandler(shipButton_MouseEnter); shipButton.MouseLeave += new EventHandler(shipButton_MouseLeave); #endif Sprites.Add(shipButton); AdditionalSprites.Add(shipLabel); Sprite weaponsButton = new Sprite(buttonImage, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .7f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .4f), Sprites.SpriteBatch); weaponsLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, SegoeUIMono, "Weapons"); weaponsLabel.Position = new Vector2((weaponsButton.X + weaponsButton.Width / 2) - weaponsLabel.Width / 2, (weaponsButton.Y + weaponsButton.Height / 2) - weaponsLabel.Height / 2); weaponsLabel.Color = Color.White; weaponsLabel.IsHoverable = true; weaponsLabel.IsManuallySelectable = true; weaponsLabel.NonHoverColor = Color.White; weaponsLabel.HoverColor = Color.MediumAquamarine; #if WINDOWS weaponsButton.MouseEnter += new EventHandler(weaponsButton_MouseEnter); weaponsButton.MouseLeave += new EventHandler(weaponsButton_MouseLeave); #endif Sprites.Add(weaponsButton); AdditionalSprites.Add(weaponsLabel); Sprite backButton = new Sprite(buttonImage, new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .4f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .65f), Sprites.SpriteBatch); backLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, SegoeUIMono, "Back"); backLabel.Position = new Vector2((backButton.X + backButton.Width / 2) - backLabel.Width / 2, (backButton.Y + backButton.Height / 2) - backLabel.Height / 2); backLabel.Color = Color.White; backLabel.IsHoverable = true; backLabel.IsManuallySelectable = true; backLabel.NonHoverColor = Color.White; backLabel.HoverColor = Color.MediumAquamarine; #if WINDOWS backButton.MouseEnter += new EventHandler(backButton_MouseEnter); backButton.MouseLeave += new EventHandler(backButton_MouseLeave); #endif Sprites.Add(backButton); AdditionalSprites.Add(backLabel); }
public override void InitScreen(ScreenType screenName) { base.InitScreen(screenName); Viewport viewPort = Sprites.SpriteBatch.GraphicsDevice.Viewport; this.BackgroundSprite = HorizontalMenuBGSprite.CurrentBG; Texture2D planetTexture = GameContent.GameAssets.Images.NonPlayingObjects.Planet; Texture2D buttonTexture = GameContent.GameAssets.Images.Controls.Button; SpriteFont SegoeUIMono = GameContent.GameAssets.Fonts.NormalText; Texture2D altPlanetTexture = GameContent.GameAssets.Images.NonPlayingObjects.AltPlanet; planet = new Sprite(planetTexture, Vector2.Zero, Sprites.SpriteBatch); planet.Scale = new Vector2(.7f); planet.Position = new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * 0.1f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .16f); Sprites.Add(planet); planettwo = new Sprite(altPlanetTexture, Vector2.Zero, Sprites.SpriteBatch); planettwo.Scale = new Vector2(1f); planettwo.Position = new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * 0.8f, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .75f); Sprites.Add(planettwo); //title image TitleImage = new Sprite(GameContent.GameAssets.Images.Controls.Title, Vector2.Zero, Sprites.SpriteBatch); TitleImage.Position = new Vector2(viewPort.Width / 2 - TitleImage.Texture.Width / 2, viewPort.Height * 0.2f); Sprites.Add(TitleImage); PlayButton = new Sprite(buttonTexture, new Vector2(viewPort.Width * 0.375f, viewPort.Height * 0.4f), Sprites.SpriteBatch); Sprites.Add(PlayButton); PlayLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, SegoeUIMono, "Play"); PlayLabel.IsHoverable = true; PlayLabel.NonHoverColor = Color.White; PlayLabel.HoverColor = Color.MediumAquamarine; AdditionalSprites.Add(PlayLabel); ExitButton = new Sprite(buttonTexture, new Vector2(PlayButton.X, PlayButton.Y + (PlayButton.Height * 1.6f)), Sprites.SpriteBatch); Sprites.Add(ExitButton); ExitLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, SegoeUIMono, "Exit"); ExitLabel.IsHoverable = true; ExitLabel.NonHoverColor = Color.White; ExitLabel.HoverColor = Color.MediumAquamarine; AdditionalSprites.Add(ExitLabel); ExitLabel.ParentSprite = ExitButton; PlayLabel.ParentSprite = PlayButton; #if WINDOWS ExitLabel.Clicked += new EventHandler(ExitLabel_Clicked); PlayLabel.Clicked += new EventHandler(PlayLabel_Clicked); #elif XBOX ButtonManagement = new GamePadButtonEnumerator(new TextSprite[, ] { { PlayLabel }, { ExitLabel } }, InputType.LeftJoystick); ButtonManagement.ButtonPress += new EventHandler(ButtonManagement_ButtonPress); #endif }