示例#1
0
        public static TexturedEffectButton createButton(ContentManager content, Vector2 position, String name)
        {
            const float       SPACE       = 65f;
            PulseEffectParams effectParms = new PulseEffectParams {
                ScaleBy     = 1f,
                ScaleDownTo = .9f,
                ScaleUpTo   = 1.1f
            };

            Vector2 origin = new Vector2(128f, 64f);
            Vector2 scale  = new Vector2(1f, .5f);
            TexturedEffectButtonParams buttonParms = new TexturedEffectButtonParams {
                Position = position,
                Origin   = origin,
                Scale    = scale,
                Effects  = new List <BaseEffect> {
                    new PulseEffect(effectParms)
                },
                PickableArea  = CollisionGenerationUtils.getButtonRectangle(origin, position),
                ResetDelegate = delegate(StaticDrawable2D button) {
                    button.Scale = scale;
                }
            };

            buttonParms.Texture      = LoadingUtils.load <Texture2D>(content, name);
            buttonParms.Position     = new Vector2(buttonParms.Position.X, buttonParms.Position.Y + SPACE * 1.3f);
            buttonParms.PickableArea = CollisionGenerationUtils.getButtonRectangle(origin, buttonParms.Position);
            return(new TexturedEffectButton(buttonParms));
        }
示例#2
0
 /// <summary>
 /// Building of a textured button
 /// </summary>
 /// <param name="parms">TexturedButtonParams object containing the data required to build the TexturedButton</param>
 public TexturedEffectButton(TexturedEffectButtonParams parms)
     : base(parms)
 {
     base.setRenderingRectByTexture(base.texture);
     this.ID           = parms.ID;
     this.effects      = parms.Effects;
     this.reset        = parms.ResetDelegate;
     this.pickableArea = parms.PickableArea;
 }
示例#3
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
        }