Example #1
0
        void Options_ScreenResolutionChanged(object sender, EventArgs e)
        {
            //relocate buttons and labels on the screen!

            PauseLabel.Position = new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width / 2 - PauseLabel.Width / 2, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .1f);

            ResumeButton.Position = new Vector2(ResumeButton.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .2f);
            ExitButton.Position   = new Vector2(ResumeButton.X, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .8f);
            ExitLabel.Position    = new Vector2(ExitLabel.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X, ExitButton.Y + (ExitButton.Height / 2 - ExitLabel.Height / 2));
            ShopButton.Position   = new Vector2(ResumeButton.X, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .53f);
            ResumeLabel.Position  = new Vector2(ResumeLabel.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X, ResumeButton.Y + (ResumeButton.Height / 2 - ResumeLabel.Height / 2));
            OptionButton.Position = new Vector2(ResumeButton.X, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .37f);
            ShopLabel.Position    = new Vector2(ShopLabel.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X, ShopButton.Y + (ShopButton.Height / 2 - ShopLabel.Height / 2));
            OptionsLabel.Position = new Vector2(OptionsLabel.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X, OptionButton.Y + (OptionButton.Height / 2 - OptionsLabel.Height / 2));
        }
        public override void InitScreen(ScreenType screenName)
        {
            StateManager.ScreenStateChanged += new EventHandler(StateManager_ScreenStateChanged);
            StateManager.ScreenResolutionChanged += new EventHandler<ViewportEventArgs>(Options_ScreenResolutionChanged);

            base.InitScreen(screenName);
            BackgroundSprite = GameContent.Assets.Images.NonPlayingObjects.GlobalBackground;
            title = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.BoldText, "You Won!", Color.White);
            title.X = title.GetCenterPosition(Graphics.Viewport).X;
            title.Y = 12.5f;
            AdditionalSprites.Add(title);
            planet = Sprites.AddNewSprite(new Vector2(-3, Graphics.Viewport.Height - GameContent.Assets.Images.NonPlayingObjects.Planet.Height + 11), GameContent.Assets.Images.NonPlayingObjects.Planet);
            msg = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.NormalText, MessageText, Color.White);
            msg.Y = title.Y + title.Font.LineSpacing;
            AdditionalSprites.Add(msg);

            netScreenButton = Sprites.AddNewSprite(Vector2.Zero, GameContent.Assets.Images.Controls.Button);
            netScreenButton.Position = netScreenButton.GetCenterPosition(Graphics.Viewport);
            netScreenLabel = StateManager.CreateButtonTextSprite(false, "Multiplayer", netScreenButton, this);
            netScreenLabel.Pressed += StateManager.ButtonSFXHelper;
            netScreenLabel.Pressed += new EventHandler(netScreenLabel_Pressed);
        }
        public override void InitScreen(ScreenType screenName)
        {
            base.InitScreen(screenName);
            BackgroundSprite = HorizontalMenuBGSprite.CurrentBG;
            title = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.BoldText, "Available " + (StateManager.NetworkData.SessionType == NetworkSessionType.SystemLink ? "LAN" : "LIVE") + " Sectors");
            title.Color = Color.White;
            title.Y = 5;
            title.X = title.GetCenterPosition(Graphics.Viewport).X;

            reloadButton = new Sprite(GameContent.Assets.Images.Controls.Button, new Vector2(0, title.Y + title.Font.LineSpacing + 10), Sprites.SpriteBatch);
            reloadButton.X = reloadButton.GetCenterPosition(Graphics.Viewport).X;

            reload = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.NormalText, "Refresh");
            reload.ParentSprite = reloadButton;
            reload.NonHoverColor = Color.White;
            reload.HoverColor = Color.MediumAquamarine;

            reload.IsHoverable = true;
            reload.Pressed += new EventHandler(reload_Pressed);

            BackButton = new Sprite(GameContent.Assets.Images.Controls.Button, new Vector2(20, Graphics.Viewport.Height), Sprites.SpriteBatch);
            BackButton.Y -= BackButton.Height + 20;
            BackLabel = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.NormalText, "Back", Color.White) { IsHoverable = true, HoverColor = Color.MediumAquamarine, NonHoverColor = Color.White };
            BackLabel.ParentSprite = BackButton;
            BackLabel.Pressed += new EventHandler(BackLabel_Pressed);
            BackLabel.Visible = true;

            Sprites.Add(BackButton);

            AdditionalSprites.Add(title);
            AdditionalSprites.Add(reload);
            Sprites.Add(reloadButton);

            #if XBOX
            AllButtons = new GamePadButtonEnumerator(new TextSprite[,] { { reload }, { BackLabel } }, InputType.LeftJoystick);
            AllButtons.FireTextSpritePressed = true;
            #endif
        }
        public override void InitScreen(ScreenType screenType)
        {
            base.InitScreen(screenType);
            #if WINDOWS
            GameScreen.Paused += new EventHandler(GameScreen_Paused);
            #endif
            Texture2D button = GameContent.Assets.Images.Controls.Button;

            StateManager.Options.ScreenResolutionChanged += new EventHandler<ViewportEventArgs>(Options_ScreenResolutionChanged);

            PauseLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, GameContent.Assets.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);

            LevelLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, GameContent.Assets.Fonts.NormalText, "Points:" + StateManager.SpacePoints + "\nCurrent Level: Level " + StateManager.CurrentLevel.ToInt() + "\n" + StateManager.Lives + " extra lives remaining\nYou have " + StateManager.SpaceBucks + " credits");
            LevelLabel.Position = new Vector2(Sprites.SpriteBatch.GraphicsDevice.Viewport.Width / 2 - LevelLabel.Width / 2, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .50f);
            LevelLabel.Color = Color.White;
            AdditionalSprites.Add(LevelLabel);

            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);
            Sprites.Add(ResumeButton);

            ResumeLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, GameContent.Assets.Fonts.NormalText, "Resume");
            ResumeLabel.ParentSprite = ResumeButton;
            ResumeLabel.Color = Color.White;
            #if WINDOWS
            ResumeLabel.CallKeyboardClickEvent = false;
            #endif
            ResumeLabel.IsHoverable = true;
            ResumeLabel.HoverColor = Color.MediumAquamarine;
            ResumeLabel.NonHoverColor = Color.White;
            AdditionalSprites.Add(ResumeLabel);

            ExitButton = new Sprite(button, new Vector2(ResumeButton.X, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .8f), Sprites.SpriteBatch);
            Sprites.Add(ExitButton);

            ExitLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, GameContent.Assets.Fonts.NormalText, "Exit");
            ExitLabel.Color = Color.White;
            ExitLabel.IsHoverable = true;
            #if WINDOWS
            ExitLabel.CallKeyboardClickEvent = false;
            #endif
            ExitLabel.ParentSprite = ExitButton;
            ExitLabel.HoverColor = Color.MediumAquamarine;
            ExitLabel.NonHoverColor = Color.White;
            AdditionalSprites.Add(ExitLabel);

            OptionButton = new Sprite(button, Vector2.Zero, Sprites.SpriteBatch);
            OptionButton.Position = new Vector2(ResumeButton.X, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .37f);
            Sprites.Add(OptionButton);

            OptionsLabel = new TextSprite(Sprites.SpriteBatch, Vector2.Zero, GameContent.Assets.Fonts.NormalText, "Options");
            OptionsLabel.ParentSprite = OptionButton;
            OptionsLabel.Color = Color.White;
            OptionsLabel.IsHoverable = true;
            #if WINDOWS
            OptionsLabel.CallKeyboardClickEvent = false;
            #endif
            OptionsLabel.HoverColor = Color.MediumAquamarine;
            OptionsLabel.NonHoverColor = Color.White;
            AdditionalSprites.Add(OptionsLabel);
            #if XBOX
            AllButtons = new GamePadButtonEnumerator(new TextSprite[,]
                {
                    {ResumeLabel},
                    {OptionsLabel},
                    {ExitLabel}
                }, InputType.LeftJoystick);
            AllButtons.FireTextSpritePressed = true;
            #endif
            ResumeLabel.Pressed += new EventHandler(ResumeLabel_Pressed);
            ExitLabel.Pressed += new EventHandler(ExitLabel_Pressed);
            OptionsLabel.Pressed += new EventHandler(OptionsLabel_Pressed);
        }
Example #5
0
        /// <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);
        }
Example #6
0
        public override void InitScreen(ScreenType screenType)
        {
            base.InitScreen(screenType);
            MediaPlayer.MediaStateChanged -= musicHandler;
            MediaPlayer.MediaStateChanged += musicHandler;
            BackgroundSprite = new Sprite(GameContent.GameAssets.Images.Backgrounds.Screens[ScreenBackgrounds.Credits], Vector2.Zero, Sprites.SpriteBatch);
            SpriteFont SegoeUIMono = GameContent.GameAssets.Fonts.NormalText;

            _scrollingSpeed = new Vector2(0, -1);

            Texture2D logo = GameContent.GameAssets.Images.Controls.Title;

            gameTitle   = new Sprite(logo, new Vector2(0, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height), Sprites.SpriteBatch);
            gameTitle.X = gameTitle.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X;
            //credits = new TextSprite(Sprites.SpriteBatch, , "\n\n\n\nWeek 1 - Functional Spec, GameState Management\n
            //Week 3 - AI's\n\n\n\n\n\n\n\n\n\n\n\nWeek 4 - Xbox Converson\n\n\n\n\nUnderlying Library written by:\nGlen Husman (glen3b)\nGlib is available on github! \n\n\n\n\n\n\n                Music:\n\nFailing Defense - Kevin MacLeod\n\nAll music obtained from Incompetech.com", Color.White);
            //credits = new TextSprite(Sprites.SpriteBatch, GameContent.GameAssets.Fonts.NormalText, "   Plequarius: Galactic Commanders\n\n\n\n\n\nAll Developement:\nGlen Husman\n\nMinor Assistance:\nAbe", Color.White);

            //credits.Position = new Vector2(credits.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height+imgSprite.Height);

            _creditsSong = GameContent.GameAssets.Music[ScreenMusic.Credits];

            int lastWeekID = 0;

            foreach (KeyValuePair <XmlCredits.Week, XmlCredits.Student> weekStudent in _xmlCredits.Students)
            {
                int weekID = weekStudent.Key.ID;

                if (lastWeekID != weekID)
                {
                    StringBuilder title = new StringBuilder();

                    title.AppendFormat("\n\n\n\nWeek {0} - ", weekID);

                    for (int topicCounter = 0; topicCounter < weekStudent.Key.Topics.Count; topicCounter++)
                    {
                        KeyValuePair <int, string> topic = weekStudent.Key.Topics[topicCounter];
                        title.AppendFormat("{0}{1}", topic.Value, topicCounter == weekStudent.Key.Topics.Count - 1 ? "\n" : ", ");
                    }

                    TextSprite credit = new TextSprite(Sprites.SpriteBatch, _boldCreditsFont, title.ToString());
                    credit.X     = credit.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X;
                    credit.Color = Color.White;

                    if (credits.Count == 0)
                    {
                        credit.Y = gameTitle.Y + gameTitle.Height;
                    }
                    else
                    {
                        credit.Y = credits[credits.Count - 1].Y + credits[credits.Count - 1].Height + (_creditsFont.LineSpacing - _creditsFont.MeasureString("A").Y);
                    }
                    credits.Add(credit);

                    lastWeekID = weekID;
                }

                TextSprite student = new TextSprite(Sprites.SpriteBatch, _creditsFont, String.Format("{0} {1}\n", weekStudent.Value.FirstName, weekStudent.Value.LastName));
                student.X     = student.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X;
                student.Color = Color.White;
                student.Y     = credits[credits.Count - 1].Y + credits[credits.Count - 1].Height + (_creditsFont.LineSpacing - _creditsFont.MeasureString("A").Y);
                credits.Add(student);
            }

            //The IEnumerable cast method
            AdditionalSprites.AddRange(credits.Cast <ISprite>());
            Sprites.Add(gameTitle);

            _elapsedTime = TimeSpan.Zero;
        }
Example #7
0
        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);
        }
Example #8
0
        public override void InitScreen(ScreenType screenType)
        {
            base.InitScreen(screenType);
            BackgroundSprite = new Sprite(GameContent.Assets.Images.Backgrounds.Screens[ScreenBackgrounds.Credits], Vector2.Zero, Sprites.SpriteBatch);
            SpriteFont SegoeUIMono = GameContent.Assets.Fonts.NormalText;
            _scrollingSpeed = new Vector2(0, -1);

            Texture2D logo = GameContent.Assets.Images.Controls.Title;
            gameTitle = new Sprite(logo, new Vector2(0, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height), Sprites.SpriteBatch);
            gameTitle.X = gameTitle.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X;
            //credits = new TextSprite(Sprites.SpriteBatch, , "\n\n\n\nWeek 1 - Functional Spec, GameState Management\n
            //Week 3 - AI's\n\n\n\n\n\n\n\n\n\n\n\nWeek 4 - Xbox Converson\n\n\n\n\nUnderlying Library written by:\nGlen Husman (glen3b)\nGlib is available on github! \n\n\n\n\n\n\n                Music:\n\nFailing Defense - Kevin MacLeod\n\nAll music obtained from Incompetech.com", Color.White);
            //credits = new TextSprite(Sprites.SpriteBatch, GameContent.GameAssets.Fonts.NormalText, "   Plequarius: Galactic Commanders\n\n\n\n\n\nAll Developement:\nGlen Husman\n\nMinor Assistance:\nAbe", Color.White);

            //credits.Position = new Vector2(credits.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height+imgSprite.Height);

            int lastWeekID = 0;
            foreach (KeyValuePair<XmlCredits.Week, XmlCredits.Student> weekStudent in _xmlCredits.Students)
            {
                int weekID = weekStudent.Key.ID;

                if (lastWeekID != weekID)
                {
                    StringBuilder title = new StringBuilder();

                    title.AppendFormat("\n\n\n\nWeek {0} - ", weekID);

                    for (int topicCounter = 0; topicCounter < weekStudent.Key.Topics.Count; topicCounter++)
                    {
                        KeyValuePair<int, string> topic = weekStudent.Key.Topics[topicCounter];
                        title.AppendFormat("{0}{1}", topic.Value, topicCounter == weekStudent.Key.Topics.Count - 1 ? "\n" : ", ");
                    }

                    TextSprite credit = new TextSprite(Sprites.SpriteBatch, _boldCreditsFont, title.ToString());
                    credit.X = credit.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X;
                    credit.Color = Color.White;

                    if (credits.Count == 0)
                    {
                        credit.Y = gameTitle.Y + gameTitle.Height;
                    }
                    else
                    {
                        credit.Y = credits[credits.Count - 1].Y + credits[credits.Count - 1].Height + (_creditsFont.LineSpacing - _creditsFont.MeasureString("A").Y);
                    }
                    credits.Add(credit);

                    lastWeekID = weekID;
                }

                TextSprite student = new TextSprite(Sprites.SpriteBatch, _creditsFont, String.Format("{0} {1}\n", weekStudent.Value.FirstName, weekStudent.Value.LastName));
                student.X = student.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X;
                student.Color = Color.White;
                student.Y = credits[credits.Count - 1].Y + credits[credits.Count - 1].Height + (_creditsFont.LineSpacing - _creditsFont.MeasureString("A").Y);
                credits.Add(student);
            }

            TextSprite helperLabel = new TextSprite(Sprites.SpriteBatch, _boldCreditsFont, "\n\n\n\nHelpers\n", Color.White);
            helperLabel.X = helperLabel.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport).X;
            helperLabel.Y = credits[credits.Count - 1].Y + credits[credits.Count - 1].Height + (_creditsFont.LineSpacing - _creditsFont.MeasureString("A").Y);
            credits.Add(helperLabel);

            foreach (PGCGame.Xml.XmlTypes.XmlCredits.Helper assistant in _xmlCredits.AllHelpers)
            {
                float targetY = credits[credits.Count - 1].Y + credits[credits.Count - 1].Height + (_creditsFont.LineSpacing - _creditsFont.MeasureString("A").Y);
                TextSprite name = new TextSprite(Sprites.SpriteBatch, new Vector2(0, targetY), _boldCreditsFont, assistant.FullName, Color.White);
                TextSprite job = new TextSprite(Sprites.SpriteBatch, new Vector2(0, targetY+name.Font.LineSpacing), _creditsFont, assistant.Job+"\n", Color.White);
                name.X = name.GetCenterPosition(Graphics.Viewport).X;
                job.X = job.GetCenterPosition(Graphics.Viewport).X;
                credits.Add(name);
                credits.Add(job);
            }

            //The IEnumerable cast method
            AdditionalSprites.AddRange(credits.Cast<IDrawableComponent>());
            Sprites.Add(gameTitle);

            _elapsedTime = TimeSpan.Zero;
        }
        public override void InitScreen(ScreenType screenName)
        {
            Sprites.Clear();
            AdditionalSprites.Clear();
            _firstInit = true;
            gamerInfos = null;
            GamerInfos.Clear();
            SelectedShips.Clear();

            base.InitScreen(screenName);

            BackgroundSprite = HorizontalMenuBGSprite.CurrentBG;
            title = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.BoldText, StateManager.NetworkData.SessionMode.ToFriendlyString() + " Lobby", Color.White);
            title.Y = 5;
            title.X = title.GetCenterPosition(Graphics.Viewport).X;
            AdditionalSprites.Add(title);

            StartButton = new Sprite(GameContent.Assets.Images.Controls.Button, new Vector2(0, Graphics.Viewport.Height), Sprites.SpriteBatch);
            StartButton.X = StartButton.GetCenterPosition(Graphics.Viewport).X;
            StartButton.Y -= StartButton.Height + 20;
            StartLabel = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.NormalText, "Start", Color.White) { ParentSprite = StartButton, IsHoverable = true, HoverColor = Color.MediumAquamarine, NonHoverColor = Color.White };
            StartLabel.Pressed += new EventHandler(StartLabel_Pressed);
            StartButton.Visible = false;
            StartLabel.Visible = false;
            Sprites.Add(StartButton);
            AdditionalSprites.Add(StartLabel);

            #if XBOX
            AllButtons = new GamePadButtonEnumerator(new TextSprite[,] { { StartLabel } }, InputType.LeftJoystick);
            AllButtons.FireTextSpritePressed = true;
            #endif
        }
        public override void InitScreen(ScreenType screenName)
        {
            base.InitScreen(screenName);
            BackgroundSprite = HorizontalMenuBGSprite.CurrentBG;
            TitleLabel = new TextSprite(Sprites.SpriteBatch, new Vector2(0, 5), GameContent.Assets.Fonts.BoldText, "Select Match Type", Color.White);
            TitleLabel.X = TitleLabel.GetCenterPosition(Graphics.Viewport).X;
            AdditionalSprites.Add(TitleLabel);

            CoopButton = new Sprite(GameContent.Assets.Images.Controls.Button, new Vector2(0, 10 + TitleLabel.Height), Sprites.SpriteBatch);
            CoopButton.X = CoopButton.GetCenterPosition(Graphics.Viewport).X;

            CoopLabel = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.NormalText, "Co-op", Color.White);
            CoopLabel.HoverColor = Color.MediumAquamarine;
            CoopLabel.NonHoverColor = Color.White;
            CoopLabel.IsHoverable = true;
            CoopLabel.ParentSprite = CoopButton;
            CoopLabel.Pressed += StateManager.ButtonSFXHelper;
            CoopLabel.Pressed += new EventHandler(CoopLabel_Pressed);

            Sprites.Add(CoopButton);
            AdditionalSprites.Add(CoopLabel);

            LMS = new Sprite(GameContent.Assets.Images.Controls.Button, new Vector2(0, 20 + CoopLabel.Height + CoopLabel.Y), Sprites.SpriteBatch);
            LMS.X = CoopButton.GetCenterPosition(Graphics.Viewport).X;

            LMSLabel = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.NormalText, "LMS", Color.White);
            LMSLabel.HoverColor = Color.MediumAquamarine;
            LMSLabel.NonHoverColor = Color.White;
            LMSLabel.IsHoverable = true;
            LMSLabel.ParentSprite = LMS;
            LMSLabel.Pressed += StateManager.ButtonSFXHelper;
            LMSLabel.Pressed += new EventHandler(DeathMatchLabel_Pressed);

            Sprites.Add(LMS);
            AdditionalSprites.Add(LMSLabel);

            TDM = new Sprite(GameContent.Assets.Images.Controls.Button, new Vector2(0, 20 + LMSLabel.Height + LMSLabel.Y), Sprites.SpriteBatch);
            TDM.X = LMS.GetCenterPosition(Graphics.Viewport).X;

            TDMLabel = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.NormalText, "Team Deathmatch", Color.White);
            TDMLabel.HoverColor = Color.MediumAquamarine;
            TDMLabel.NonHoverColor = Color.White;
            TDMLabel.IsHoverable = true;
            TDMLabel.ParentSprite = TDM;
            TDMLabel.Pressed += StateManager.ButtonSFXHelper;
            TDMLabel.Pressed += new EventHandler(TDMLabel_Pressed);

            Sprites.Add(TDM);
            AdditionalSprites.Add(TDMLabel);

            BackButton = new Sprite(GameContent.Assets.Images.Controls.Button, new Vector2(0, 0), Sprites.SpriteBatch);
            BackButton.X = BackButton.GetCenterPosition(Graphics.Viewport).X;
            BackButton.Y = StateManager.GraphicsManager.GraphicsDevice.Viewport.Height - 50 - BackButton.Height;

            BackLabel = new TextSprite(Sprites.SpriteBatch, GameContent.Assets.Fonts.NormalText, "Back", Color.White);
            BackLabel.HoverColor = Color.MediumAquamarine;
            BackLabel.NonHoverColor = Color.White;
            BackLabel.IsHoverable = true;
            BackLabel.ParentSprite = BackButton;
            BackLabel.Pressed += StateManager.ButtonSFXHelper;
            BackLabel.Pressed += new EventHandler(BackLabel_Pressed);

            Sprites.Add(BackButton);
            AdditionalSprites.Add(BackLabel);

            #if XBOX
            AllButtons = new GamePadButtonEnumerator(new TextSprite[,] { { CoopLabel }, { LMSLabel }, { TDMLabel }, { BackLabel } }, InputType.LeftJoystick);
            AllButtons.FireTextSpritePressed = true;
            #endif
        }