public KeyBinding(SpriteFont font, ContentManager content, Vector2 textPosition, Vector2 binderPosition, string text, Keys boundKey) { Text2DParams textParams = new Text2DParams() { Font = font, Position = textPosition, WrittenText = text, LightColour = Constants.TEXT_COLOUR }; this.text = new Text2D(textParams); KeyBindingTextBoxParams binderParams = new KeyBindingTextBoxParams() { Content = content, Font = font, LightColour = Constants.TEXT_COLOUR, Position = binderPosition, Scale = new Vector2(250f, 1f), Text = KeyLists.translate(boundKey), BoundTo = boundKey, TextColour = Constants.TEXT_COLOUR }; this.keyBinder = new KeyBindingTextBox(binderParams); }
public OptionsSection(ContentManager content, Vector2 position, float bindersX, string sectionName, Controls controls) { SpriteFont font = LoadingUtils.load <SpriteFont>(content, "SpriteFont1"); Text2DParams parms = new Text2DParams { Font = font, LightColour = Color.Red, Position = position, WrittenText = "Player " + sectionName + "'s Key Bindings", }; this.heading = new Text2D(parms); Vector2 textPosition = new Vector2(position.X, position.Y + SPACE); Vector2 bindersPosition = new Vector2(bindersX, textPosition.Y); this.bindings = new Dictionary <string, KeyBinding>(); this.bindings.Add(BINDING_NAMES[0], new KeyBinding(font, content, textPosition, bindersPosition, BINDING_NAMES[0], controls.Left)); getPositions(ref textPosition, ref bindersPosition); this.bindings.Add(BINDING_NAMES[1], new KeyBinding(font, content, textPosition, bindersPosition, BINDING_NAMES[1], controls.Up)); getPositions(ref textPosition, ref bindersPosition); this.bindings.Add(BINDING_NAMES[2], new KeyBinding(font, content, textPosition, bindersPosition, BINDING_NAMES[2], controls.Right)); getPositions(ref textPosition, ref bindersPosition); this.bindings.Add(BINDING_NAMES[3], new KeyBinding(font, content, textPosition, bindersPosition, BINDING_NAMES[3], controls.Down)); getPositions(ref textPosition, ref bindersPosition); }
/// <summary> /// Constructs a CheckBox object based on the params /// </summary> /// <param name="parms">CheckBoxParams object</param> public CheckBox(CheckBoxParams parms) : base(parms) { this.Checked = parms.Checked; StaticDrawable2DParams imgParms = new StaticDrawable2DParams { Position = parms.Position, LightColour = parms.LightColour, Scale = parms.Scale, RenderingRectangle = Constants.CHK_BOX_UNCHECKED, Texture = LoadingUtils.load <Texture2D>(parms.Content, Constants.GUI_FILE_NAME), Origin = new Vector2(Constants.CHK_BOX_UNCHECKED.Width / 2, Constants.CHK_BOX_UNCHECKED.Height / 2) }; this.uncheckedBoxImag = new StaticDrawable2D(imgParms); Vector3 min = new Vector3(parms.Position.X - Constants.CHK_BOX_CHECKED.Width / 2, parms.Position.Y - Constants.CHK_BOX_CHECKED.Height / 2, 0f); Vector3 max = new Vector3(parms.Position.X + Constants.CHK_BOX_CHECKED.Width / 2, parms.Position.Y + Constants.CHK_BOX_CHECKED.Height / 2, 0f); this.bbox = new BoundingBox(min, max); imgParms.RenderingRectangle = Constants.CHK_BOX_CHECKED; this.checkedBoxImag = new StaticDrawable2D(imgParms); Text2DParams textParms = new Text2DParams { Position = new Vector2(parms.Position.X + 40f, parms.Position.Y), LightColour = parms.LightColour, WrittenText = parms.Text, Scale = parms.Scale, Font = parms.Font, Origin = new Vector2(Constants.CHK_BOX_UNCHECKED.Width / 2, Constants.CHK_BOX_UNCHECKED.Height / 2) }; this.text = new Text2D(textParms); }
/// <summary> /// Constructs a Slider object based on the params object /// </summary> /// <param name="parms">SliderParams object</param> public Slider(SliderParams parms) : base(parms) { this.CurrentValue = parms.CurrentValue; this.initialX = parms.Position.X; Texture2D texture = LoadingUtils.load <Texture2D>(parms.Content, Constants.GUI_FILE_NAME); StaticDrawable2DParams imgParms = new StaticDrawable2DParams { Position = parms.Position, LightColour = parms.BarColour, Scale = parms.Scale, RenderingRectangle = Constants.SLIDER_BAR, Texture = texture, Origin = new Vector2(Constants.SLIDER_BAR.Width / 2, Constants.SLIDER_BAR.Height / 2) }; this.bar = new StaticDrawable2D(imgParms); imgParms.Scale = parms.BallScale; imgParms.LightColour = parms.BallColour; imgParms.RenderingRectangle = Constants.SLIDER_BALL; imgParms.Origin = new Vector2(Constants.SLIDER_BALL.Width / 2, Constants.SLIDER_BALL.Height / 2); this.ball = new StaticDrawable2D(imgParms); setPosition(); Text2DParams textParms = new Text2DParams { Position = new Vector2(parms.Position.X + 100f, parms.Position.Y), LightColour = parms.LightColour, WrittenText = getValue(), Font = parms.Font, Origin = new Vector2(16f, 16f), }; this.text = new Text2D(textParms); }
public Timer(ContentManager content) { Text2DParams parms = new Text2DParams(); parms.Font = ResourceManager.getInstance().Font; parms.LightColour = ResourceManager.TEXT_COLOUR; parms.Position = new Vector2(682f, 14f); parms.WrittenText = FIRST_PART; this.firstPart = new Text2D(parms); parms.Position = new Vector2(684f, 39f); parms.WrittenText = SECOND_PART; this.secondPart = new Text2D(parms); parms.Position = new Vector2(700f, 87f); parms.WrittenText = THIRD_PART; this.thirdPart = new Text2D(parms); parms.Position = new Vector2(700f, 63f); parms.WrittenText = "0"; parms.LightColour = HIGH_TIME; this.timeText = new Text2D(parms); this.activeTimeColour = HIGH_TIME; //sfxs this.guardsAlertedSfx = LoadingUtils.load <SoundEffect>(content, DETECTED_SFX_NAME); #if WINDOWS #if DEBUG ScriptManager.getInstance().registerObject(this.firstPart, "first"); ScriptManager.getInstance().registerObject(this.secondPart, "second"); ScriptManager.getInstance().registerObject(this.timeText, "time"); ScriptManager.getInstance().registerObject(this.thirdPart, "third"); #endif #endif }
public Player(ContentManager content, SFXEngine sfxEngine, Vector2 position, NukeDelegate nukeDelegate, int ownerID) : base(content, sfxEngine, position, nukeDelegate, ownerID) { Text2DParams textParms = new Text2DParams(); textParms.Font = LoadingUtils.load <SpriteFont>(content, "SpriteFont1"); textParms.Position = new Vector2(10f); textParms.LightColour = Color.Black; this.powerText = new Text2D(textParms); }
public GameDisplay(ContentManager content) { this.content = content; this.timer = new Timer(content); ColouredButtonParams buttonParms = new ColouredButtonParams(); buttonParms.Font = ResourceManager.getInstance().Font; buttonParms.Height = 25; buttonParms.LinesTexture = ResourceManager.getInstance().ButtonLineTexture; buttonParms.MouseOverColour = ResourceManager.MOUSE_OVER_COLOUR; buttonParms.RegularColour = ResourceManager.TEXT_COLOUR; buttonParms.StartX = 700; buttonParms.Width = 75; buttonParms.StartY = 557; // start button buttonParms.Text = "Start"; buttonParms.TextsPosition = new Vector2(711f, buttonParms.StartY - 2f); this.startButton = new ColouredButton(buttonParms); // HUD Text2DParams textParms = new Text2DParams(); textParms.Font = ResourceManager.getInstance().Font; textParms.LightColour = ResourceManager.TEXT_COLOUR; textParms.Position = new Vector2(727f, 150f); this.treasureText = new Text2D(textParms); StaticDrawable2DParams staticParms = new StaticDrawable2DParams(); staticParms = new StaticDrawable2DParams(); staticParms.Position = new Vector2(702f, 148f); staticParms.Texture = LoadingUtils.load <Texture2D>(content, "Treasure1"); this.treasure = new StaticDrawable2D(staticParms); //dust particle emitter BaseParticle2DEmitterParams particleEmitterParams = new BaseParticle2DEmitterParams(); particleEmitterParams.ParticleTexture = LoadingUtils.load <Texture2D>(content, "Dust1"); particleEmitterParams.SpawnDelay = DustParticleEmitter.SPAWN_DELAY; this.dustEmitter = new DustParticleEmitter(particleEmitterParams); // load sound effects this.introSfx = LoadingUtils.load <SoundEffect>(content, LEVEL_ENTRY_SFX_NAME); this.payDaySfx = LoadingUtils.load <SoundEffect>(content, "PayDay"); this.treasureSfx = LoadingUtils.load <SoundEffect>(content, "TreasureCollect"); this.guardDetectedSfx = LoadingUtils.load <SoundEffect>(content, "GuardDetection"); this.dumpsterCrashSfx = LoadingUtils.load <SoundEffect>(content, "DumpsterCrash"); this.dumpsterCloseSfx = LoadingUtils.load <SoundEffect>(content, "DumpsterClose"); }
public Player(ContentManager content, SpriteFont font, string name, Vector2 scorePosition, Vector2 turnSpritePosition, string aliveTexture, string dyingTexture, Flower.FlowerType flowerType) { this.name = name; this.AliveTexture = LoadingUtils.load <Texture2D>(content, aliveTexture); this.DyingTexture = LoadingUtils.load <Texture2D>(content, dyingTexture); this.FlowerType = flowerType; this.Score = 0; Text2DParams textParams = new Text2DParams(); textParams.Font = font; textParams.LightColour = ResourceManager.getInstance().TextColour; textParams.Position = scorePosition; this.Text = new Text2D(textParams); this.myTurnSprite = FlowerBuilder.getFlowerSprite(content, turnSpritePosition, this.AliveTexture, AnimationState.PlayForwardOnce); this.notMyTurnSprite = FlowerBuilder.getFlowerSprite(content, turnSpritePosition, this.DyingTexture, AnimationState.PlayForwardOnce); }
public GameOverMenu(ContentManager content, ScoreCalculationDelegate scoreCalculator, ResetBoardDelegate resetCallBack) { this.scoreCalculatorCallBack = (ScoreCalculationDelegate)scoreCalculator; this.resetCallBack = resetCallBack; ColouredButtonParams buttonParms = new ColouredButtonParams(); buttonParms.Font = ResourceManager.getInstance().Font; buttonParms.Height = 25; buttonParms.LinesTexture = ResourceManager.getInstance().ButtonLineTexture; buttonParms.MouseOverColour = ResourceManager.MOUSE_OVER_COLOUR; buttonParms.RegularColour = ResourceManager.TEXT_COLOUR; buttonParms.StartX = 580; buttonParms.Width = 205; buttonParms.StartY = 515; // replay button buttonParms.Text = "Replay"; buttonParms.TextsPosition = new Vector2(645f, buttonParms.StartY - 2f); this.replayButton = new ColouredButton(buttonParms); // Map selection button buttonParms.StartY = 557; buttonParms.Text = "Map Selection"; buttonParms.TextsPosition = new Vector2(610f, buttonParms.StartY - 2f); this.mapSelectionButton = new ColouredButton(buttonParms); // game over text Text2DParams textParams = new Text2DParams(); textParams.Font = ResourceManager.getInstance().Font; textParams.Position = new Vector2(200f, 50f); this.gameOverText = new Text2D(textParams); // loosing background StaticDrawable2DParams staticParms = new StaticDrawable2DParams(); staticParms.Position = new Vector2(-10f, 0f); staticParms.Texture = LoadingUtils.load <Texture2D>(content, "BackGround1"); this.looseBackGround = new StaticDrawable2D(staticParms); // winning background staticParms.Texture = LoadingUtils.load <Texture2D>(content, "BackGround2"); this.winBackGround = new StaticDrawable2D(staticParms); }
/// <summary> /// Building of a coloured button /// </summary> /// <param name="parms"></param> public ColouredButton(ColouredButtonParams parms) { this.regularColour = parms.RegularColour; this.mouseOverColour = parms.MouseOverColour; this.renderingRectangle = new Rectangle(parms.StartX, parms.StartY, parms.Width, parms.Height); this.ID = parms.ID; // create our lines this.lines = new Line2D[4]; Line2DParams lineParams = new Line2DParams(); lineParams.Texture = parms.LinesTexture; lineParams.LightColour = this.regularColour; lineParams.Position = new Vector2(parms.StartX, parms.StartY); lineParams.EndPosition = new Vector2(parms.StartX + parms.Width, parms.StartY); this.lines[0] = new Line2D(lineParams); lineParams.Position = new Vector2(parms.StartX + parms.Width, parms.StartY); lineParams.EndPosition = new Vector2(parms.StartX + parms.Width, parms.StartY + parms.Height); this.lines[1] = new Line2D(lineParams); lineParams.Position = new Vector2(parms.StartX + parms.Width, parms.StartY + parms.Height); lineParams.EndPosition = new Vector2(parms.StartX, parms.StartY + parms.Height); this.lines[2] = new Line2D(lineParams); lineParams.Position = new Vector2(parms.StartX, parms.StartY + parms.Height); lineParams.EndPosition = new Vector2(parms.StartX, parms.StartY); this.lines[3] = new Line2D(lineParams); // create the text Text2DParams textParams = new Text2DParams(); textParams.Font = parms.Font; textParams.LightColour = this.regularColour; textParams.Position = parms.TextsPosition; textParams.WrittenText = parms.Text; this.text = new Text2D(textParams); }
public HUD(ContentManager content) { SpriteFont font = LoadingUtils.load <SpriteFont>(content, "SpriteFont1"); Text2DParams parms = new Text2DParams(); parms.Font = font; parms.LightColour = Color.Red; parms.Position = new Vector2(Constants.RESOLUTION_X / 3, 450f); parms.WrittenText = TEXT_RESTART; this.statusText = new Text2D(parms); ColourLerpEffectParams effectParms = new ColourLerpEffectParams { LerpBy = 5f, LerpDownTo = Color.White, LerpUpTo = Color.Red }; int size = 1; if (StateManager.getInstance().GameMode == GameMode.TwoPlayer) { size = 2; } this.scoreTexts = new Text2D[size]; this.winnerTexts = new Text2D[size]; parms.Position = new Vector2(RIGHT_X, SCORES_Y); parms.WrittenText = TEXT_SCORE + getScore(0); this.scoreTexts[0] = new Text2D(parms); this.scoreTexts[0].addEffect(new ColourLerpEffect(effectParms)); parms.Position = new Vector2(RIGHT_X + WINNER_X_PADDING, SCORES_Y + WINNER_Y_OFFSET); parms.WrittenText = TEXT_WINNER; this.winnerTexts[0] = new Text2D(parms); this.winnerTexts[0].addEffect(new ColourLerpEffect(effectParms)); if (StateManager.getInstance().GameMode == GameMode.TwoPlayer) { parms.Position = new Vector2(LEFT_X, SCORES_Y); parms.WrittenText = TEXT_SCORE + getScore(1); this.scoreTexts[1] = new Text2D(parms); this.scoreTexts[1].addEffect(new ColourLerpEffect(effectParms)); parms.Position = new Vector2(LEFT_X + WINNER_X_PADDING, SCORES_Y + WINNER_Y_OFFSET); parms.WrittenText = TEXT_WINNER; this.winnerTexts[1] = new Text2D(parms); this.winnerTexts[1].addEffect(new ColourLerpEffect(effectParms)); } this.countDownImages = new StaticDrawable2D[3]; StaticDrawable2DParams countDownParms = new StaticDrawable2DParams { Position = new Vector2(Constants.RESOLUTION_X / 2, Constants.RESOLUTION_Y / 2), Origin = new Vector2(256f), }; for (int i = 0; i < this.countDownImages.Length; i++) { countDownParms.Texture = LoadingUtils.load <Texture2D>(content, (i + 1).ToString()); this.countDownImages[i] = new StaticDrawable2D(countDownParms); } StaticDrawable2DParams gameOverParms = new StaticDrawable2DParams { Position = new Vector2(Constants.RESOLUTION_X / 2, Constants.RESOLUTION_Y / 2), Origin = new Vector2(512f), Texture = LoadingUtils.load <Texture2D>(content, "GameOver") }; this.gameOver = new StaticDrawable2D(gameOverParms); scaleOverTimeEffectParms = new ScaleOverTimeEffectParams { ScaleBy = new Vector2(-1f) }; this.soundEffect = LoadingUtils.load <SoundEffect>(content, "ShortBeep"); this.index = 2; this.activeCountdownItem = this.countDownImages[this.index]; this.activeCountdownItem.addEffect(new ScaleOverTimeEffect(scaleOverTimeEffectParms)); this.elapsedTime = 0f; SoundManager.getInstance().SFXEngine.playSoundEffect(this.soundEffect); }
/// <summary> /// Constructs a Textbox based on the params object passed in /// </summary> /// <param name="parms">TextBoxParams object</param> public TextBox(TextBoxParams parms) : base(parms) { this.font = parms.Font; this.Text = parms.Text; this.SIZE_PER_CHARACTER = parms.SizePerCharacter; this.MAX_LENGTH = parms.MaxLength; this.VALID_KEYS = new List <Keys>(); this.VALID_KEYS.AddRange(KeyLists.DIRECTIONAL_KEYS); this.VALID_KEYS.AddRange(KeyLists.LETTERS_KEYS); this.VALID_KEYS.AddRange(KeyLists.NUMBER_KEYS); this.VALID_KEYS.AddRange(KeyLists.NUMPAD_KEYS); Vector2 endsScale = new Vector2(1f, parms.Scale.Y); Vector2 midScale = new Vector2(parms.Scale.X, 1f); this.imgs = new List <StaticDrawable2D>(); // Starting edge StaticDrawable2DParams imgParms = new StaticDrawable2DParams { Position = parms.Position, LightColour = parms.LightColour, RenderingRectangle = Constants.TXT_BOX_END, Scale = endsScale, Texture = LoadingUtils.load <Texture2D>(parms.Content, Constants.GUI_FILE_NAME) }; this.imgs.Add(new StaticDrawable2D(imgParms)); // Middle bars Vector2 start = new Vector2(imgParms.Position.X - 30f, imgParms.Position.Y); Vector2 startBar = Vector2.Add(start, new Vector2(Constants.TXT_BOX_END.Width, 0f)); START_BAR_X = startBar.X; float length = parms.MaxLength * parms.SizePerCharacter + parms.Scale.X; imgParms.Position = startBar; imgParms.RenderingRectangle = Constants.TXT_BOX_MIDDLE; imgParms.Scale = new Vector2(length, parms.Scale.Y); this.imgs.Add(new StaticDrawable2D(imgParms)); // Ending edge imgParms.Position = Vector2.Add(start, new Vector2(Constants.TXT_BOX_END.Width + length, 0f)); imgParms.RenderingRectangle = Constants.TXT_BOX_END; imgParms.Scale = endsScale; this.imgs.Add(new StaticDrawable2D(imgParms)); this.bbox = new BoundingBox(new Vector3(start.X, start.Y, 0f), new Vector3(imgParms.Position.X + Constants.TXT_BOX_MIDDLE.Width, imgParms.Position.Y + Constants.TXT_BOX_MIDDLE.Height, 0f)); // Cursor indicator float x = START_BAR_X + text.Length * SIZE_PER_CHARACTER + 4f; imgParms.Position = new Vector2(x, imgParms.Position.Y + 6f); imgParms.Scale = new Vector2(1f, (parms.Scale.Y - .5f)); imgParms.LightColour = parms.TextColour; this.cursorIndicator = new StaticDrawable2D(imgParms); updateIndicatorsPosition(); Text2DParams txtParms = new Text2DParams { Position = new Vector2(parms.Position.X + 2f, parms.Position.Y), Font = parms.Font, Scale = parms.TextScale, WrittenText = this.Text, LightColour = parms.TextColour }; this.text2D = new Text2D(txtParms); }
/// <summary> /// Builds an object that can write text to the screen /// </summary> /// <param name="parms">TextParams object</param> public Text2D(Text2DParams parms) : base(parms) { this.font = parms.Font; this.writtenText = parms.WrittenText; }
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 }