This is a link between the pressing of some button on the controller and performing some action through a delegate.
        public MainMenu(Vector2 position, MenuAction[] actions, float spacing, int scoreBoardIndex)
            : base(position, actions)
        {
            MenuEntry play = new MenuEntry(
                "Play",
                new MenuAction[]
                {
                    new MenuAction(ActionType.Select, new PlayGameDelegate(scoreBoardIndex))
                },
                position);

            MenuEntry quit = new MenuEntry(
                "Quit",
                new MenuAction[]
                {
                    new MenuAction(ActionType.Select, new GoToTitleDelegate())
                },
                position + new Vector2(0, 3 * spacing));

            play.UpperMenu = quit;
            play.LowerMenu = quit;

            quit.UpperMenu = play;
            quit.LowerMenu = play;

            this.Add(play);
            this.Add(quit);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MenuEntry"/> class.
 /// </summary>
 /// <param name="text">The text to display.</param>
 /// <param name="actions">The this.actions associated with this menu entry. For example,
 /// one action might be pressing "A" to select the entry. Adding
 /// an action of Left, Right, Up, or Down will overwrite the
 /// menu entry navigation.</param>
 /// <param name="position">The this.position of the image.</param>
 public MenuEntry(string text, MenuAction[] actions, Vector2 position)
 {
     this.text = text;
     this.actions = actions;
     this.layerDepth = 1;
     this.position = position;
     this.origin = FontStatic.Get("defaultFont").MeasureString(text) / 2f;
 }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PauseMenu"/> class.
        /// </summary>
        /// <param name="position">The position.</param>
        /// <param name="actions">The actions.</param>
        /// <param name="spacing">The spacing.</param>
        public PauseMenu(Vector2 position, MenuAction[] actions, float spacing)
            : base(position, actions)
        {
            MenuEntry resume = new MenuEntry(
                "Resume",
                new MenuAction[]
                {
                    new MenuAction(ActionType.Select, new QuitPauseScreenDelegate())
                },
                position);

            VolumeControlDisplayEntry music = new VolumeControlDisplayEntry(
                "Music Volume",
                string.Empty,
                new MenuAction[] { },
                position + new Vector2(0, spacing),
                new Vector2(0, 300),
                0.9f,
                0.9f,
                true,
                false);

            VolumeControlDisplayEntry sound = new VolumeControlDisplayEntry(
                "Sound Volume",
                string.Empty,
                new MenuAction[] { },
                position + new Vector2(0, 2 * spacing),
                new Vector2(0, 300),
                0.9f,
                0.9f,
                false,
                false);

            MenuEntry quit = new MenuEntry(
                "Exit",
                new MenuAction[]
                {
                    new MenuAction(ActionType.Select, new GoToTitleDelegate())
                },
                position + new Vector2(0, 3 * spacing));

            resume.UpperMenu = quit;
            resume.LowerMenu = music;

            music.UpperMenu = resume;
            music.LowerMenu = sound;

            sound.UpperMenu = music;
            sound.LowerMenu = quit;

            quit.UpperMenu = sound;
            quit.LowerMenu = resume;

            this.Add(resume);
            this.Add(music);
            this.Add(sound);
            this.Add(quit);
        }
        public LoadOutMenu(Vector2 position, MenuAction[] actions, int count, LoadOutScreen parent)
            : base(position, actions)
        {
            MenuEntry gun = new MenuEntry(
                "Gun",
                new MenuAction[]
                {
                    new MenuAction(ActionType.Select, new LoadOutDelegate(count, "Gun", parent))
                },
                position);

            MenuEntry axe = new MenuEntry(
                "Melee",
                new MenuAction[]
                {
                    new MenuAction(ActionType.Select, new LoadOutDelegate(count, "Melee", parent))
                },
                position + new Vector2(0, 80));

            MenuEntry shield = new MenuEntry(
                "Shield",
                new MenuAction[]
                {
                    new MenuAction(ActionType.Select, new LoadOutDelegate(count, "Shield", parent))
                },
                position + new Vector2(0,160));

            gun.LowerMenu = axe;
            axe.UpperMenu = gun;
            axe.LowerMenu = shield;
            shield.UpperMenu = axe;

            this.Add(gun);
            this.Add(axe);
            this.Add(shield);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BoxArtMenu"/> class.
        /// </summary>
        /// <param name="position">The position.</param>
        /// <param name="actions">The actions.</param>
        /// <param name="spacing">The spacing.</param>
        public BoxArtMenu(Vector2 position, MenuAction[] actions, float spacing)
            : base(position, actions)
        {
            this.spacing = spacing;

            VolumeControlDisplayEntry music = new VolumeControlDisplayEntry(
                "Music Volume",
                "Press Left and Right to set the music\nvolume for the game.",
                new MenuAction[] { },
                position,
                new Vector2(1342, 400),
                1f,
                0.99f,
                true,
                true);

            VolumeControlDisplayEntry sound = new VolumeControlDisplayEntry(
                "Sound Volume",
                "Press Left and Right to set the sound\nvolume for the game.",
                new MenuAction[] { },
                position + new Vector2(0, spacing),
                new Vector2(1342, 400),
                1f,
                0.99f,
                false,
                true);

            DescriptionMenuEntry storage = new DescriptionMenuEntry(
                "Storage Device",
                "Press #A to change the Storage Device used\nfor saving scores. No device selection menu\nwill be displayed if you only have one\ndevice connected.",
                new MenuAction[]
                {
                    new MenuAction(ActionType.Select, new ChangeStorageDeviceDelegate())
                },
                position + new Vector2(0, 2 * spacing));

            DescriptionMenuEntry credits = new DescriptionMenuEntry(
                "Credits",
                "Press #A to see the names of the developers.",
                new MenuAction[]
                {
                    new MenuAction(ActionType.Select, new ShowCreditsDelegate())
                },
                position + new Vector2(0, 3 * spacing));

            DescriptionMenuEntry quit = new DescriptionMenuEntry(
                "Exit",
                "Press #A to exit the game.",
                new MenuAction[]
                {
                    new MenuAction(ActionType.Select, new QuitGameDeleage())
                },
                position + new Vector2(0, 4 * spacing));

            // Do not "loop around".
            music.LowerMenu = sound;

            sound.UpperMenu = music;
            sound.LowerMenu = storage;

            storage.UpperMenu = sound;
            storage.LowerMenu = credits;

            credits.UpperMenu = storage;
            credits.LowerMenu = quit;

            quit.UpperMenu = credits;

            this.Add(music);
            this.Add(sound);
            this.Add(storage);
            this.Add(credits);
            this.Add(quit);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="VolumeControlDisplayEntry"/> class.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="description">The description.</param>
        /// <param name="actions">The actions.</param>
        /// <param name="position">The position.</param>
        /// <param name="numberDisplayPosition">The number display position.</param>
        /// <param name="scale">The scale of the largest number.</param>
        /// <param name="numberLayerDepth">The number layer depth.</param>
        /// <param name="musicVolume">Is this for music volume? Else, sound volume.</param>
        /// <param name="ignoreOffsetPosition">if set to <c>true</c> [ignore offset position].</param>
        public VolumeControlDisplayEntry(
            string text,
            string description,
            MenuAction[] actions,
            Vector2 position,
            Vector2 numberDisplayPosition,
            float scale,
            float numberLayerDepth,
            bool musicVolume,
            bool ignoreOffsetPosition)
            : base(text, description, actions, position)
        {
            this.displayPosition = numberDisplayPosition;
            this.scale = scale;
            this.numberLayerDepth = numberLayerDepth;
            this.musicVolume = musicVolume;
            this.ignoreOffsetPosition = ignoreOffsetPosition;
            this.previouslyHighlighed = false;
            this.positions = new List<tVector2>();
            this.scales = new List<tfloat>();
            for (int i = 0; i <= 10; i++)
            {
                this.positions.Add(new tVector2(numberDisplayPosition.X, numberDisplayPosition.Y));
                this.scales.Add(new tfloat(0));
            }

            this.origins = new List<Vector2>();
            for (int i = 0; i <= 10; i++)
            {
                this.origins.Add(FontStatic.Get("defaultFont").MeasureString(i.ToString()) / 2f);
            }
        }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DescriptionMenuEntry"/> class.
 /// </summary>
 /// <param name="text">The text.</param>
 /// <param name="descripton">The descripton.</param>
 /// <param name="actions">The actions.</param>
 /// <param name="position">The position.</param>
 public DescriptionMenuEntry(string text, string descripton, MenuAction[] actions, Vector2 position)
     : base(text, actions, position)
 {
     this.Description = descripton;
     this.layerDepth = 0.96f;
 }