Пример #1
0
        /// <summary>
        /// Creates a level select 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="screenWidth">The width of the rendering window.</param>
        /// <param name="gameSettings">The game settings.</param>
        /// <returns>The new menu created.</returns>
        public static Menu CreateLevelSelectMenu(ContentManager contentManager, SpriteBatch spriteBatch, Vector2 position, float screenWidth, GameSettings gameSettings)
        {
            int pages = (GameSettings.TotalLevels + 1) / 8;
            pages += (GameSettings.TotalLevels + 1) % 8 == 0 ? 0 : 1;
            Menu levelSelectMenu = new Menu(position, 2, 4, pages, screenWidth);
            Sprite largeButtonTile = new Sprite();
            largeButtonTile.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.LargeButtonTile);

            float gapBetweenTiles = 32.0f;
            Vector2 firstTileRelativePos = new Vector2((-largeButtonTile.Width * 1.5f) + (-gapBetweenTiles * 1.5f), (-largeButtonTile.Height - gapBetweenTiles) * 0.5f);
            Vector2 tileOffset = new Vector2(largeButtonTile.Width + gapBetweenTiles, largeButtonTile.Height + gapBetweenTiles);

            float screenCount = 0.0f;
            int total = 0;
            int tilesPerScreen = 8;
            int columns = 4;
            int rowOffset = 0;
            int colOffset = 0;

            while (total < GameSettings.TotalLevels + 1)
            {
                MenuButton button = null;
                Vector2 relativePos = new Vector2(screenCount * screenWidth, 0.0f) + firstTileRelativePos + new Vector2(tileOffset.X * colOffset, tileOffset.Y * rowOffset);
                if (total == 0)
                {
                    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);
                    levelSelectMenu.AddItem(button);
                }
                else
                {
                    RenderableText text = new RenderableText();
                    RenderableText largeText = new RenderableText();
                    string name = ConvertToWords.ConvertIntToWords(total);
                    text.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, name);
                    largeText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontLarge, total.ToString());
                    button = new MenuButton(relativePos, largeButtonTile, largeText, text, total.ToString());
                    levelSelectMenu.AddItem(button);
                }

                colOffset++;
                total++;
                if (total % tilesPerScreen == 0)
                {
                    rowOffset = 0;
                    colOffset = 0;
                    screenCount++;
                }
                else if (total % columns == 0)
                {
                    rowOffset++;
                    colOffset = 0;
                }
            }

            levelSelectMenu.SelectablesActive = gameSettings.LevelsUnlocked + 1;
            return levelSelectMenu;
        }
Пример #2
0
        /// <summary>
        /// Creates an options 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="settings">The game settings.</param>
        /// <returns>The new menu created.</returns>
        public static Menu CreateOptionsMenu(ContentManager contentManager, SpriteBatch spriteBatch, Vector2 position, GameSettings settings)
        {
            Menu optionsMenu = new Menu(position, 2, 3);
            MenuButton button = null;
            RenderableText buttonText = null;
            RenderableText buttonIconText = null;
            Sprite largeButtonTile = new Sprite();
            largeButtonTile.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.LargeButtonTile);
            float tileOffset = 32.0f;

            Vector2 relativePos = new Vector2(-(largeButtonTile.Width + tileOffset), -0.5f * (largeButtonTile.Height + tileOffset));

            // Music toggle
            Sprite largeMusicIcon = new Sprite();
            largeMusicIcon.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.LargeMusicIcon);
            buttonIconText = new RenderableText();
            buttonIconText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontLarge, settings.MusicEnabled ? " " : "X");
            buttonText = new RenderableText();
            buttonText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, MenuConstants.MusicButtonName.ToLowerInvariant());
            button = new MenuButton(relativePos, largeButtonTile, largeMusicIcon, buttonIconText, buttonText, MenuConstants.MusicButtonName);
            optionsMenu.AddItem(button);

            // SFX toggle
            relativePos.X += largeButtonTile.Width + tileOffset;
            Sprite largeSoundEffectsIcon = new Sprite();
            largeSoundEffectsIcon.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.LargeSoundEffectsIcon);
            buttonIconText = new RenderableText();
            buttonIconText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontLarge, settings.SoundEffectsEnabled ? " " : "X");
            buttonText = new RenderableText();
            buttonText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, MenuConstants.SoundEffectsButtonName.ToLowerInvariant());
            button = new MenuButton(relativePos, largeButtonTile, largeSoundEffectsIcon, buttonIconText, buttonText, MenuConstants.SoundEffectsButtonName);
            optionsMenu.AddItem(button);

            // Upload toggle
            relativePos.X += largeButtonTile.Width + tileOffset;
            Sprite largeUploadIcon = new Sprite();
            largeUploadIcon.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.LargeGlobalIcon);
            buttonIconText = new RenderableText();
            buttonIconText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontLarge, settings.UploadHighScores ? " " : "X");
            buttonText = new RenderableText();
            buttonText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, MenuConstants.UploadButtonName.ToLowerInvariant());
            button = new MenuButton(relativePos, largeButtonTile, largeUploadIcon, buttonIconText, buttonText, MenuConstants.UploadButtonName);
            optionsMenu.AddItem(button);

            // Reset Notifications
            relativePos = new Vector2(-(largeButtonTile.Width + tileOffset), 0.5f * (largeButtonTile.Height + tileOffset));
            buttonIconText = new RenderableText();
            buttonIconText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontLarge, "!");
            buttonText = new RenderableText();
            buttonText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, MenuConstants.NotificationButtonName.ToLowerInvariant());
            button = new MenuButton(relativePos, largeButtonTile, buttonIconText, buttonText, MenuConstants.NotificationButtonName);
            optionsMenu.AddItem(button);

            // Set Name
            relativePos.X += largeButtonTile.Width + tileOffset;
            buttonIconText = new RenderableText();
            buttonIconText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFontLarge, "A");
            buttonText = new RenderableText();
            buttonText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, MenuConstants.NameButtonName.ToLowerInvariant());
            button = new MenuButton(relativePos, largeButtonTile, buttonIconText, buttonText, MenuConstants.NameButtonName);
            optionsMenu.AddItem(button);

            // Done button
            relativePos.X += largeButtonTile.Width + tileOffset;
            Sprite largeDoneIcon = new Sprite();
            largeDoneIcon.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.LargePlayIcon);
            buttonText = new RenderableText();
            buttonText.InitializeAndLoad(spriteBatch, contentManager, ContentLocations.SegoeUIFont, MenuConstants.DoneButtonName.ToLowerInvariant());
            button = new MenuButton(relativePos, largeButtonTile, largeDoneIcon, buttonText, MenuConstants.DoneButtonName);
            optionsMenu.AddItem(button);

            return optionsMenu;
        }
Пример #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            this.spriteBatch = new SpriteBatch(this.GraphicsDevice);
            this.gameSettings = GameSettings.Load();
            this.notificationManager = NotificationManager.Initialize(this.Content, this.spriteBatch, this.screenDimensions);
            AudioManager.InitializeAndLoad(this.Content);
            PositionInformer.Initialize(this.Content, new Vector2(this.screenDimensions.X / 2.0f, this.screenDimensions.Y / 2.5f), new Vector2(this.screenDimensions.X / 6.0f), 75, true);
            this.menuManager.InitializeAndLoad(this.spriteBatch, this.Content, this.gameSettings);
            this.inputManager.InitializeSpeechEngine(this.menuManager.GetAllSelectableNames());
            this.handSprite.InitializeAndLoad(this.spriteBatch, this.Content, ContentLocations.HandIcon);
            this.headsUpDisplay.InitializeAndLoad(this.spriteBatch, this.Content);
            EntitySettingsLoader.LoadEntitySettings(this.Content);
            this.levelManager.LoadContent(this.Content, this.spriteBatch);
            this.levelEditor.LoadContent(this.spriteBatch, this.Content);
            this.levelEditor.LevelsCreated = this.gameSettings.TotalCustomLevels;
            if (SticKart.DisplayColourStream)
            {
                this.colourStreamRenderer = new ColourStreamRenderer(this.Content, this.GraphicsDevice);
                this.colourStreamDisplayArea = new Rectangle(5 * ((int)this.screenDimensions.X / 6), 2 * ((int)this.screenDimensions.Y / 3), (int)this.screenDimensions.X / 6, (int)this.screenDimensions.Y / 3);
            }

            AudioManager.PlayBackgroundMusic(this.gameState == GameState.InGame);
        }