示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MenuButton"/> class.
 /// </summary>
 /// <param name="relativePosition">The centre position of the menu item, relative to it's owner/parent.</param>
 /// <param name="tile">The button's background sprite.</param>
 /// <param name="icon">The icon to display on the button.</param>
 /// <param name="text">The text to display on the button.</param>
 /// <param name="name">The name of the button.</param>
 public MenuButton(Vector2 relativePosition, Sprite tile, Sprite icon, RenderableText text, string name)
     : base(relativePosition, name, new Vector2(tile.Width, tile.Height))
 {
     this.textIcon = null;
     this.tile = new MenuImage(Vector2.Zero, tile);
     this.icon = new MenuImage(Vector2.Zero, icon);
     Vector2 relativeTextPosition = new Vector2(0.0f, tile.Height * 0.36f);
     this.text = new MenuText(relativeTextPosition, text);
 }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MenuButton"/> class.
        /// </summary>
        /// <param name="relativePosition">The centre position of the menu item, relative to it's owner/parent.</param>
        /// <param name="tile">The button's background sprite.</param>
        /// <param name="icon">The icon to display on the button.</param>
        /// <param name="textIcon">The text to display at the centre of the button.</param>
        /// <param name="text">The text to display on the button.</param>
        /// <param name="name">The name of the button.</param>
        public MenuButton(Vector2 relativePosition, Sprite tile, Sprite icon, RenderableText textIcon, RenderableText text, string name)
            : base(relativePosition, name, new Vector2(tile.Width, tile.Height))
        {
            this.textIcon = new MenuText(Vector2.Zero, textIcon);
            this.tile     = new MenuImage(Vector2.Zero, tile);
            this.icon     = new MenuImage(Vector2.Zero, icon);
            Vector2 relativeTextPosition = new Vector2(0.0f, tile.Height * 0.36f);

            this.text = new MenuText(relativeTextPosition, text);
        }
示例#3
0
        /// <summary>
        /// Creates a name prompt menu.
        /// </summary>
        /// <param name="contentManager">The content manager to use to load resources.</param>
        /// <param name="spriteBatch">The sprite batch to attach to menu items.</param>
        /// <param name="position">The position of the menu.</param>
        /// <param name="playerName">The stored player's name.</param>
        /// <returns>The new menu created.</returns>
        public static Menu CreateNamePromptMenu(ContentManager contentManager, SpriteBatch spriteBatch, Vector2 position, string playerName)
        {
            Menu namePromptMenu = new Menu(position, 2, 3);
            MenuButton button = null;

            Sprite buttonTile = new Sprite();
            RenderableText textIcon = new RenderableText();
            RenderableText text = new RenderableText();
            buttonTile.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.MediumButtonTile);
            float tileGap = 16.0f;

            Vector2 relativePosition = new Vector2(-tileGap - buttonTile.Width, 0.0f);

            for (int count = 0; count < 3; count++)
            {
                buttonTile = new Sprite();
                buttonTile.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.MediumButtonTile);
                textIcon = new RenderableText();
                textIcon.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontLarge, playerName[count].ToString().ToUpperInvariant());
                text = new RenderableText();
                text.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, playerName[count].ToString().ToLowerInvariant());
                text.Colour = Color.Black;
                button = new MenuButton(relativePosition, buttonTile, textIcon, text, count.ToString());
                namePromptMenu.AddItem(button);
                relativePosition.X += tileGap + buttonTile.Width;
            }

            relativePosition = new Vector2(0.0f, buttonTile.Height + tileGap);
            Sprite largePlayIcon = new Sprite();
            largePlayIcon.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.MediumPlayIcon);
            RenderableText continueText = new RenderableText();
            continueText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, MenuConstants.DoneButtonName.ToLowerInvariant());
            button = new MenuButton(relativePosition, buttonTile, largePlayIcon, continueText, MenuConstants.DoneButtonName);
            namePromptMenu.AddItem(button);

            relativePosition = new Vector2(-buttonTile.Width - tileGap, -buttonTile.Height - tileGap);
            float offset = (buttonTile.Width + tileGap) / 2.0f;
            for (int col = 0; col < 5; col++)
            {
                buttonTile = new Sprite();
                buttonTile.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.MediumButtonTile);
                MenuImage background = new MenuImage(relativePosition, buttonTile);
                namePromptMenu.AddItem(background);
                relativePosition.X += offset;
            }

            relativePosition = new Vector2(0.0f, -1.55f * (buttonTile.Height - tileGap));
            RenderableText hello = new RenderableText();
            hello.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontMedium, MenuConstants.HelloText);
            MenuText helloText = new MenuText(relativePosition, hello);
            namePromptMenu.AddItem(helloText);

            RenderableText enterName = new RenderableText();
            enterName.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, MenuConstants.EnterNameText);
            relativePosition.Y += enterName.Height * 1.2f;
            MenuText enterNameText = new MenuText(relativePosition, enterName);
            namePromptMenu.AddItem(enterNameText);

            relativePosition.Y += enterName.Height * 1.2f;
            RenderableText selectLetter = new RenderableText();
            selectLetter.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, MenuConstants.SelectLetterText);
            MenuText selectLetterText = new MenuText(relativePosition, selectLetter);
            namePromptMenu.AddItem(selectLetterText);

            relativePosition.Y += enterName.Height * 1.2f;
            RenderableText pressDone = new RenderableText();
            pressDone.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, MenuConstants.PressDoneText);
            MenuText pressDoneText = new MenuText(relativePosition, pressDone);
            namePromptMenu.AddItem(pressDoneText);

            return namePromptMenu;
        }
示例#4
0
        /// <summary>
        /// Creates a level complete menu.
        /// </summary>
        /// <param name="contentManager">The content manager to use to load resources.</param>
        /// <param name="spriteBatch">The sprite batch to attach to menu items.</param>
        /// <param name="position">The position of the menu.</param>
        /// <returns>The new menu created.</returns>
        public static Menu CreateLevelCompleteMenu(ContentManager contentManager, SpriteBatch spriteBatch, Vector2 position)
        {
            Menu levelCompleteMenu = new Menu(position, 1, 3);
            MenuButton button = null;
            MenuText text = null;
            Sprite largeButtonTile = new Sprite();
            largeButtonTile.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.LargeButtonTile);
            Vector2 relativePos = Vector2.Zero;
            float tileSpacing = 32.0f;

            relativePos = new Vector2(-largeButtonTile.Width - tileSpacing, largeButtonTile.Height * 0.75f);
            Sprite largePlayIcon = new Sprite();
            largePlayIcon.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.LargePlayIcon);
            RenderableText continueText = new RenderableText();
            continueText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, MenuConstants.ContinueButtonName.ToLowerInvariant());
            button = new MenuButton(relativePos, largeButtonTile, largePlayIcon, continueText, MenuConstants.ContinueButtonName);
            levelCompleteMenu.AddItem(button);

            relativePos.X = 0.0f;
            Sprite largeRetryIcon = new Sprite();
            largeRetryIcon.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.LargeRetryIcon);
            RenderableText retryText = new RenderableText();
            retryText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, MenuConstants.RetryButtonName.ToLowerInvariant());
            button = new MenuButton(relativePos, largeButtonTile, largeRetryIcon, retryText, MenuConstants.RetryButtonName);
            levelCompleteMenu.AddItem(button);

            relativePos.X = largeButtonTile.Width + tileSpacing;
            Sprite largeExitIcon = new Sprite();
            largeExitIcon.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.LargeExitIcon);
            RenderableText exitText = new RenderableText();
            exitText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, MenuConstants.ExitButtonName.ToLowerInvariant());
            button = new MenuButton(relativePos, largeButtonTile, largeExitIcon, exitText, MenuConstants.ExitButtonName);
            levelCompleteMenu.AddItem(button);

            relativePos = new Vector2(-largeButtonTile.Width - tileSpacing, -largeButtonTile.Height * 0.75f);
            for (int row = 0; row < 2; row++)
            {
                for (int col = 0; col < 4; col++)
                {
                    largeButtonTile = new Sprite();
                    largeButtonTile.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.LargeButtonTile);
                    MenuImage background = new MenuImage(relativePos, largeButtonTile);
                    levelCompleteMenu.AddItem(background);
                    relativePos.X += largeButtonTile.Width * 0.745f;
                }

                relativePos.Y += largeButtonTile.Height * 0.375f;
                relativePos.X = -largeButtonTile.Width - tileSpacing;
            }

            relativePos = new Vector2(0.0f, -largeButtonTile.Height * 1.1f);
            RenderableText levelComplete = new RenderableText();
            levelComplete.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontMedium, MenuConstants.LevelCompleteText);
            text = new MenuText(relativePos, levelComplete);
            levelCompleteMenu.AddItem(text);

            relativePos += new Vector2(0.0f, levelComplete.Height * 1.25f);
            RenderableText highScoreText = new RenderableText();
            highScoreText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, MenuConstants.LevelCompleteText);
            text = new MenuText(relativePos, highScoreText, true);
            levelCompleteMenu.AddItem(text);

            relativePos += new Vector2(0.0f, levelComplete.Height * 1.5f);
            RenderableText scoreText = new RenderableText();
            scoreText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontMedium, MenuConstants.ScoreText);
            text = new MenuText(relativePos, scoreText);
            levelCompleteMenu.AddItem(text);

            relativePos += new Vector2(0.0f, levelComplete.Height * 1.25f);
            RenderableText score = new RenderableText();
            score.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, MenuConstants.ScoreDefaultText);
            text = new MenuText(relativePos, score, true);
            levelCompleteMenu.AddItem(text);

            relativePos += new Vector2(0.0f, levelComplete.Height * 1.5f);
            RenderableText ratingText = new RenderableText();
            ratingText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontMedium, MenuConstants.RatingText);
            text = new MenuText(relativePos, ratingText);
            levelCompleteMenu.AddItem(text);

            relativePos += new Vector2(0.0f, levelComplete.Height * 1.25f);
            RenderableText rating = new RenderableText();
            rating.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, MenuConstants.GetRating(0));
            text = new MenuText(relativePos, rating, true);
            levelCompleteMenu.AddItem(text);

            return levelCompleteMenu;
        }
示例#5
0
        /// <summary>
        /// Creates a leaderboard menu.
        /// </summary>
        /// <param name="contentManager">The content manager to use to load resources.</param>
        /// <param name="spriteBatch">The sprite batch to attach to menu items.</param>
        /// <param name="position">The position of the menu.</param>
        /// <returns>The new menu created.</returns>
        public static Menu CreateLeaderboardMenu(ContentManager contentManager, SpriteBatch spriteBatch, Vector2 position)
        {
            Menu leaderboardMenu = new Menu(position, 1, 1);
            MenuButton button = null;
            MenuText text = null;
            Sprite largeButtonTile = new Sprite();
            largeButtonTile.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.LargeButtonTile);
            Vector2 relativePos = Vector2.Zero;
            float tileOffset = 32.0f;

            relativePos = new Vector2((-largeButtonTile.Width - tileOffset) * 1.5f, (-largeButtonTile.Height - tileOffset) * 0.5f);
            Sprite largeBackIcon = new Sprite();
            largeBackIcon.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.LargeBackIcon);
            RenderableText backText = new RenderableText();
            backText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, MenuConstants.BackButtonName.ToLowerInvariant());
            button = new MenuButton(relativePos, largeButtonTile, largeBackIcon, backText, MenuConstants.BackButtonName);
            leaderboardMenu.AddItem(button);

            relativePos = new Vector2((-largeButtonTile.Width) * 0.5f, (-largeButtonTile.Height - tileOffset) * 0.5f);
            for (int row = 0; row < 2; row++)
            {
                for (int col = 0; col < 2; col++)
                {
                    largeButtonTile = new Sprite();
                    largeButtonTile.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.LargeButtonTile);
                    MenuImage background = new MenuImage(relativePos, largeButtonTile);
                    leaderboardMenu.AddItem(background);
                    relativePos.X += largeButtonTile.Width;
                }

                relativePos.Y += largeButtonTile.Height;
                relativePos.X = (-largeButtonTile.Width) * 0.5f;
            }

            relativePos = new Vector2(0.0f, -largeButtonTile.Height * 0.825f);
            for (int count = 0; count < 10; count++)
            {
                RenderableText placeHolderText = new RenderableText();
                placeHolderText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontMedium, string.Empty);
                text = new MenuText(relativePos, placeHolderText, true);
                leaderboardMenu.AddItem(text);
                relativePos.Y += tileOffset * 1.5f;
            }

            return leaderboardMenu;
        }
示例#6
0
        /// <summary>
        /// Creates an about menu.
        /// </summary>
        /// <param name="contentManager">The content manager to use to load resources.</param>
        /// <param name="spriteBatch">The sprite batch to attach to menu items.</param>
        /// <param name="position">The position of the menu.</param>
        /// <returns>The new menu created.</returns>
        public static Menu CreateAboutMenu(ContentManager contentManager, SpriteBatch spriteBatch, Vector2 position)
        {
            Menu aboutMenu = new Menu(position, 1, 1);
            MenuButton button = null;
            MenuText text = null;
            RenderableText creditsText = new RenderableText();
            Sprite largeButtonTile = new Sprite();
            largeButtonTile.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.LargeButtonTile);
            Vector2 relativePos = Vector2.Zero;
            float tileOffset = 32.0f;

            relativePos = new Vector2((-largeButtonTile.Width - tileOffset) * 1.5f, (-largeButtonTile.Height - tileOffset) * 0.5f);
            Sprite largeBackIcon = new Sprite();
            largeBackIcon.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.LargeBackIcon);
            RenderableText backText = new RenderableText();
            backText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, MenuConstants.BackButtonName.ToLowerInvariant());
            button = new MenuButton(relativePos, largeButtonTile, largeBackIcon, backText, MenuConstants.BackButtonName);
            aboutMenu.AddItem(button);

            relativePos = new Vector2((-largeButtonTile.Width) * 0.5f, (-largeButtonTile.Height - tileOffset) * 0.5f);
            for (int row = 0; row < 2; row++)
            {
                for (int col = 0; col < 2; col++)
                {
                    largeButtonTile = new Sprite();
                    largeButtonTile.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.LargeButtonTile);
                    MenuImage background = new MenuImage(relativePos, largeButtonTile);
                    aboutMenu.AddItem(background);
                    relativePos.X += largeButtonTile.Width;
                }

                relativePos.Y += largeButtonTile.Height;
                relativePos.X = (-largeButtonTile.Width) * 0.5f;
            }

            relativePos = new Vector2(0.0f, -largeButtonTile.Height * 0.875f);
            float smallGap = tileOffset * 1.2f;
            float largeGap = tileOffset * 2.2f;

            creditsText = new RenderableText();
            creditsText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontMedium, MenuConstants.DesignArtworkText);
            text = new MenuText(relativePos, creditsText, true);
            aboutMenu.AddItem(text);
            relativePos.Y += smallGap;

            creditsText = new RenderableText();
            creditsText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontMedium, MenuConstants.ProgrammingSfxText);
            text = new MenuText(relativePos, creditsText, true);
            aboutMenu.AddItem(text);
            relativePos.Y += smallGap;

            creditsText = new RenderableText();
            creditsText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontMedium, MenuConstants.KeithText);
            text = new MenuText(relativePos, creditsText, true);
            aboutMenu.AddItem(text);
            relativePos.Y += largeGap;

            creditsText = new RenderableText();
            creditsText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontMedium, MenuConstants.MusicText);
            text = new MenuText(relativePos, creditsText, true);
            aboutMenu.AddItem(text);
            relativePos.Y += smallGap;

            creditsText = new RenderableText();
            creditsText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontMedium, MenuConstants.MusicSourceText);
            text = new MenuText(relativePos, creditsText, true);
            aboutMenu.AddItem(text);
            relativePos.Y += largeGap;

            creditsText = new RenderableText();
            creditsText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontMedium, MenuConstants.ModelText);
            text = new MenuText(relativePos, creditsText, true);
            aboutMenu.AddItem(text);
            relativePos.Y += smallGap;

            creditsText = new RenderableText();
            creditsText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontMedium, MenuConstants.ModelSourceText);
            text = new MenuText(relativePos, creditsText, true);
            aboutMenu.AddItem(text);
            relativePos.Y += largeGap;

            creditsText = new RenderableText();
            creditsText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontMedium, MenuConstants.ThanksText);
            text = new MenuText(relativePos, creditsText, true);
            aboutMenu.AddItem(text);
            relativePos.Y += smallGap;

            creditsText = new RenderableText();
            creditsText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontMedium, MenuConstants.TestersText);
            text = new MenuText(relativePos, creditsText, true);
            aboutMenu.AddItem(text);
            relativePos.Y += smallGap;

            creditsText = new RenderableText();
            creditsText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontMedium, MenuConstants.LecturersText);
            text = new MenuText(relativePos, creditsText, true);
            aboutMenu.AddItem(text);
            return aboutMenu;
        }