예제 #1
0
        /// <summary>
        /// Constructs a SoundEngineSlider object based on the parms
        /// </summary>
        /// <param name="parms">SoundEngineSliderParams object</param>
        public SoundEngineSlider(SoundEngineSliderParams parms) : base(parms)
        {
            this.soundEngine = parms.SoundEngine;
            CheckBoxParams checkBoxParams = new CheckBoxParams {
                Checked     = parms.Checked,
                Content     = parms.Content,
                Font        = parms.Font,
                LightColour = parms.LightColour,
                Position    = parms.CheckBoxPosition,
                Text        = parms.CheckBoxText
            };

            this.checkBox = new CheckBox(checkBoxParams);
        }
예제 #2
0
        public OptionsMenu(ContentManager content) : base(content, "OptionsMenu", new Vector2(Constants.RESOLUTION_X / 2, 100f))
        {
            this.effectParms = new PulseEffectParams {
                ScaleBy     = 1f,
                ScaleDownTo = .9f,
                ScaleUpTo   = 1.1f
            };

            float x                     = Constants.RESOLUTION_X / 10;
            float leftSideX             = Constants.RESOLUTION_X / 2 - 25f;
            float rightSideX            = leftSideX + 250f;
            float bindingsStartPaddingX = 125f;

            this.playerOneSection = new OptionsSection(content, new Vector2(x, 325f), x + bindingsStartPaddingX, "One", ConfigurationManager.getInstance().PlayerOnesControls);
            this.playerTwoSection = new OptionsSection(content, new Vector2(x * 6, 325f), x * 6 + bindingsStartPaddingX, "Two", ConfigurationManager.getInstance().PlayerTwosControls);

            SpriteFont font = LoadingUtils.load <SpriteFont>(content, "SpriteFont1");

            Vector2 position = new Vector2(leftSideX, 200f);
            SoundEngineSliderParams soundEngineParams = new SoundEngineSliderParams {
                Position         = position,
                BallColour       = Constants.TEXT_COLOUR,
                BarColour        = Constants.TEXT_COLOUR,
                Content          = content,
                CurrentValue     = SoundManager.getInstance().MusicEngine.Volume,
                Font             = font,
                LightColour      = Constants.TEXT_COLOUR,
                SoundEngine      = SoundManager.getInstance().MusicEngine,
                CheckBoxPosition = new Vector2(position.X + 250f, position.Y),
                Checked          = SoundManager.getInstance().MusicEngine.Muted,
                CheckBoxText     = "Muted",
            };

            this.musicSlider = new SoundEngineSlider(soundEngineParams);


            Text2DParams textParms = new Text2DParams {
                Font        = font,
                LightColour = Constants.TEXT_COLOUR,
                Position    = new Vector2(position.X - 300f, position.Y),
                WrittenText = "Music",
                Origin      = new Vector2(16f)
            };

            this.musicSliderText = new Text2D(textParms);


            soundEngineParams.Position         = new Vector2(position.X, position.Y + SPACE);
            soundEngineParams.CheckBoxPosition = new Vector2(soundEngineParams.CheckBoxPosition.X, position.Y + SPACE);
            soundEngineParams.SoundEngine      = SoundManager.getInstance().SFXEngine;
            soundEngineParams.CurrentValue     = SoundManager.getInstance().SFXEngine.Volume;
            soundEngineParams.Checked          = SoundManager.getInstance().SFXEngine.Muted;
            this.sfxSlider = new SoundEngineSlider(soundEngineParams);

            textParms.Position    = new Vector2(position.X - 300f, position.Y + SPACE);
            textParms.WrittenText = "SFX";
            this.sfxSliderText    = new Text2D(textParms);
            this.buttons          = new List <TexturedEffectButton>();
            Vector2 origin = new Vector2(90f, 64f);

            position = new Vector2(position.X, position.Y + 275f);
            TexturedEffectButtonParams buttonParms = new TexturedEffectButtonParams {
                Position = position,
                Origin   = origin,
                Scale    = new Vector2(1f),
                Effects  = new List <BaseEffect> {
                    new PulseEffect(this.effectParms)
                },
                PickableArea  = getRect(origin, position),
                ResetDelegate = delegate(StaticDrawable2D button) {
                    button.Scale = new Vector2(1f);
                }
            };

            for (int i = 0; i < this.BUTTON_NAMES.Length; i++)
            {
                buttonParms.Texture      = LoadingUtils.load <Texture2D>(content, BUTTON_NAMES[i]);
                buttonParms.Position     = new Vector2(buttonParms.Position.X, buttonParms.Position.Y + SPACE * 1.3f);
                buttonParms.PickableArea = getRect(origin, buttonParms.Position);
                this.buttons.Add(new TexturedEffectButton(buttonParms));
            }

#if DEBUG
            this.debugTexture = LoadingUtils.load <Texture2D>(content, "Chip");
            StaticDrawable2DParams centerParms = new StaticDrawable2DParams {
                Position    = new Vector2(Constants.RESOLUTION_X / 2, 0),
                Scale       = new Vector2(1f, Constants.RESOLUTION_Y),
                Texture     = this.debugTexture,
                LightColour = Color.Green
            };
            this.center = new StaticDrawable2D(centerParms);
#endif
        }