public override void Initialize() { base.Initialize(); resLeftButton = new MenuDisplayObject(game, buttonsSprite.GetSubSprite(new Rectangle(20, 135, 12, 11)), buttonsSprite.GetSubSprite(new Rectangle(4, 135, 12, 11)), new Vector2(Game1.ScreenSize.X - 168, Game1.ScreenSize.Y / 3 - 1 + (2 * 22)), new Vector2(6, 5)); resLeftButton.Initialize(); resRightButton = new MenuDisplayObject(game, buttonsSprite.GetSubSprite(new Rectangle(4, 135, 12, 11)), buttonsSprite.GetSubSprite(new Rectangle(4, 135, 12, 11)), new Vector2(Game1.ScreenSize.X - 45, Game1.ScreenSize.Y / 3 - 2 + (2 * 22)), new Vector2(6, 5)); resRightButton.Initialize(); resLeftButton.name = "left res"; resRightButton.name = "right res"; directionalButtons.Add(resLeftButton); directionalButtons.Add(resRightButton); holdTimer = game.HoldKeyTreshold; cursorIndex = 0; menuOptions = new String[5, 2]; onEnterMenuOptions = new String[5]; }
public override void Update(Microsoft.Xna.Framework.GameTime gameTime) { ButtonControls(gameTime); MouseControls(); if ((ControlManager.CheckPress(RebindableKeys.Action2) || ControlManager.CheckPress(RebindableKeys.Pause)) && Game.menuBGController.backdropSpeed.Equals(0)) { Game.menuBGController.SetPreferredBackdropPosition(new Vector2(-101, -703), "MainMenuState"); } else if (ControlManager.CheckPress(RebindableKeys.Action1) || ControlManager.CheckKeyPress(Keys.Enter)) { ButtonActions(); } selectedButton = buttons[buttonIndex]; foreach (MenuDisplayObject button in buttons) { button.isActive = false; } selectedButton.isActive = true; base.Update(gameTime); }
public virtual void Update(GameTime gameTime) { activeMenuState.Update(gameTime); MouseControls(); if (buttonControl == ButtonControl.Menu) { if (ControlManager.CheckPress(RebindableKeys.Down)) { activeButtonIndexY++; WrapActiveButton(); ActiveMenuState.CursorActions(); } else if (ControlManager.CheckPress(RebindableKeys.Up)) { activeButtonIndexY--; WrapActiveButton(); ActiveMenuState.CursorActions(); } previousButton = activeButton; activeButton = allButtons[activeButtonIndexY]; } else if (buttonControl.Equals(ButtonControl.Mission) || buttonControl.Equals(ButtonControl.Response) || buttonControl.Equals(ButtonControl.Confirm)) { activeButton = null; } if (ControlManager.CheckPress(RebindableKeys.Action1) || ControlManager.CheckKeyPress(Keys.Enter)) { ActiveMenuState.ButtonActions(); } foreach (MenuDisplayObject button in allButtons) { if (button != null) { button.isActive = false; } } if (activeButton != null) { activeButton.isActive = true; } missionMenuState.UpdateTextCursorPos(); foreach (TextBox txtBox in textBoxes) { txtBox.Update(gameTime); } }
protected void WrapActiveButton() { if (buttonControl.Equals(ButtonControl.Menu)) { if (activeButtonIndexY >= allButtons.Count) { activeButtonIndexY = 0; } else if (activeButtonIndexY < 0) { activeButtonIndexY = allButtons.Count - 1; } activeButton = allButtons[activeButtonIndexY]; } }
public void Initialize() { edgePadding = Game1.ScreenSize.X / 16; int spacing = 75; float totalButtonHeight = spacing * 3; int xOrigin = MissionScreenState.GetLowerLeftRectangle.Width / 2; float yOrigin = Game.ScreenCenter.Y + Game.ScreenCenter.Y / 2 - totalButtonHeight / 2; displayList = new List <MenuDisplayObject>(); displayList.Add(activeMissionsDisplay = new MenuDisplayObject(Game, spriteSheet.GetSubSprite(new Rectangle(0, 216, 159, 40)), spriteSheet.GetSubSprite(new Rectangle(0, 258, 159, 40)), spriteSheet.GetSubSprite(new Rectangle(0, 258, 159, 40)), new Vector2(xOrigin, yOrigin), new Vector2(79.5f, 20))); activeMissionsDisplay.name = "Active Missions"; displayList.Add(completedMissionsDisplay = new MenuDisplayObject(Game, spriteSheet.GetSubSprite(new Rectangle(0, 216, 159, 40)), spriteSheet.GetSubSprite(new Rectangle(0, 258, 159, 40)), spriteSheet.GetSubSprite(new Rectangle(0, 258, 159, 40)), new Vector2(xOrigin, yOrigin + spacing), new Vector2(79.5f, 20))); completedMissionsDisplay.name = "Completed Missions"; displayList.Add(failedMissionsDisplay = new MenuDisplayObject(Game, spriteSheet.GetSubSprite(new Rectangle(0, 216, 159, 40)), spriteSheet.GetSubSprite(new Rectangle(0, 258, 159, 40)), spriteSheet.GetSubSprite(new Rectangle(0, 258, 159, 40)), new Vector2(xOrigin, yOrigin + spacing * 2), new Vector2(79.5f, 20))); failedMissionsDisplay.name = "Failed Missions"; displayList.Add(backDisplay = new MenuDisplayObject(Game, spriteSheet.GetSubSprite(new Rectangle(0, 216, 159, 40)), spriteSheet.GetSubSprite(new Rectangle(0, 258, 159, 40)), spriteSheet.GetSubSprite(new Rectangle(0, 258, 159, 40)), new Vector2(xOrigin, yOrigin + spacing * 3), new Vector2(79.5f, 20))); backDisplay.name = "Back"; CursorLevel2 = new Cursor(Game, spriteSheet, new Rectangle(120, 124, 14, 14), new Rectangle(120, 138, 14, 14)); CursorLevel2.Initialize(); }
private MenuDisplayObject CreateButton(string name, int multiplier) { MenuDisplayObject button; tempRectPassive = new Rectangle(202, 334, 245, 60); tempRectActive = new Rectangle(202, 395, 245, 60); tempRectSelected = new Rectangle(202, 395, 245, 60); button = new MenuDisplayObject(this.Game, SpriteSheet.GetSubSprite(tempRectPassive), SpriteSheet.GetSubSprite(tempRectActive), SpriteSheet.GetSubSprite(tempRectSelected), new Vector2(Game1.ScreenSize.X / 2, (Game1.ScreenSize.Y / 2) + (Game1.ScreenSize.Y / 8) * multiplier), new Vector2(tempRectActive.Value.Width / 2f, tempRectActive.Value.Height / 2f)); button.name = name; button.isVisible = true; return(button); }
public override void Update(GameTime gameTime) { MouseControls(); if (activeOptionState != null && Game.menuBGController.DisplayButtons) { activeOptionState.Update(gameTime); } else if (Game.menuBGController.DisplayButtons) { ButtonControls(gameTime); if ((ControlManager.CheckPress(RebindableKeys.Action2) || ControlManager.CheckPress(RebindableKeys.Pause)) && Game.menuBGController.backdropSpeed.Equals(0)) { if (GameStateManager.previousState == "MainMenuState") { Game.menuBGController.SetPreferredBackdropPosition(new Vector2(-101, -703), "MainMenuState"); } else { Game.stateManager.ChangeState("OverworldState"); } } else if (ControlManager.CheckPress(RebindableKeys.Action1) || ControlManager.CheckKeyPress(Keys.Enter)) { ButtonActions(); } } selectedButton = buttons[buttonIndex]; foreach (MenuDisplayObject button in buttons) button.isActive = false; selectedButton.isActive = true; }
public void SetButtons() { int multiplier = 1; BaseStateManager.AllButtons.Clear(); if (!BaseState.GetBase().HasShop) { BaseStateManager.AllButtons.Add(buttonMission = CreateButton("Missions", multiplier++)); } else { BaseStateManager.AllButtons.Add(buttonShop = CreateButton("Buy/Sell", multiplier++)); } if (BaseStateManager.RumorsMenuState.HasRumors) { BaseStateManager.AllButtons.Add(buttonRumors = CreateButton("Rumors", multiplier++)); } BaseStateManager.AllButtons.Add(buttonBack = CreateButton("Back", multiplier)); }
public override void Initialize() { base.Initialize(); musicLeftButton = new MenuDisplayObject(game, buttonsSprite.GetSubSprite(new Rectangle(20, 135, 12, 11)), buttonsSprite.GetSubSprite(new Rectangle(4, 135, 12, 11)), new Vector2(Game1.ScreenSize.X - 168, Game1.ScreenSize.Y / 3 - 1 + (1 * 22)), new Vector2(6, 5)); musicLeftButton.Initialize(); musicRightButton = new MenuDisplayObject(game, buttonsSprite.GetSubSprite(new Rectangle(4, 135, 12, 11)), buttonsSprite.GetSubSprite(new Rectangle(4, 135, 12, 11)), new Vector2(Game1.ScreenSize.X - 112, Game1.ScreenSize.Y / 3 - 1 + (1 * 22)), new Vector2(6, 5)); musicRightButton.Initialize(); soundLeftButton = new MenuDisplayObject(game, buttonsSprite.GetSubSprite(new Rectangle(20, 135, 12, 11)), buttonsSprite.GetSubSprite(new Rectangle(4, 135, 12, 11)), new Vector2(Game1.ScreenSize.X - 168, Game1.ScreenSize.Y / 3 - 1 + (3 * 22)), new Vector2(6, 5)); soundLeftButton.Initialize(); soundRightButton = new MenuDisplayObject(game, buttonsSprite.GetSubSprite(new Rectangle(4, 135, 12, 11)), buttonsSprite.GetSubSprite(new Rectangle(4, 135, 12, 11)), new Vector2(Game1.ScreenSize.X - 112, Game1.ScreenSize.Y / 3 - 1 + (3 * 22)), new Vector2(6, 5)); soundRightButton.Initialize(); soundLeftButton.name = "left sound"; soundRightButton.name = "right sound"; musicLeftButton.name = "left music"; musicRightButton.name = "right music"; directionalButtons.Add(musicLeftButton); directionalButtons.Add(musicRightButton); directionalButtons.Add(soundLeftButton); directionalButtons.Add(soundRightButton); menuOptions = new String[5, 2]; onEnterMenuOptions = new String[5]; }
public override void Initialize() { buttonsSprite = new Sprite(Game.Content.Load<Texture2D>("Overworld-Sprites/buttons"), null); buttonsFont = Game.fontManager.GetFont(16); buttonYPosition = Game1.ScreenSize.Y / 5; gameOptionsSubState = new GameOptionsSubState(Game, buttonsSprite, this, "Game Options"); controlOptionsSubState = new ControlOptionsSubState(Game, buttonsSprite, this, "Control Options"); soundOptionsSubState = new SoundOptionsSubState(Game, buttonsSprite, this, "Sound Options"); visualOptionsSubState = new VisualOptionsSubState(Game, buttonsSprite, this, "Visual Options"); gameOptionsSubState.Initialize(); controlOptionsSubState.Initialize(); soundOptionsSubState.Initialize(); visualOptionsSubState.Initialize(); subStates = new List<OptionSubState>(); subStates.Add(gameOptionsSubState); subStates.Add(controlOptionsSubState); subStates.Add(soundOptionsSubState); subStates.Add(visualOptionsSubState); previousScreen = ""; gameOptionsButton = new MenuDisplayObject(Game, buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)), buttonsSprite.GetSubSprite(new Rectangle(0, 65, 256, 65)), new Vector2(Game1.ScreenSize.X / 4, buttonYPosition), new Vector2(buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Width / 2, buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Height / 2)); gameOptionsButton.name = "Game Options"; controlOptionsButton = new MenuDisplayObject(Game, buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)), buttonsSprite.GetSubSprite(new Rectangle(0, 65, 256, 65)), new Vector2(Game1.ScreenSize.X / 4, buttonYPosition + BUTTON_Y_DISTANCE), new Vector2(buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Width / 2, buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Height / 2)); controlOptionsButton.name = "Control Options"; visualOptionsButton = new MenuDisplayObject(Game, buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)), buttonsSprite.GetSubSprite(new Rectangle(0, 65, 256, 65)), new Vector2(Game1.ScreenSize.X / 4, buttonYPosition + BUTTON_Y_DISTANCE * 2), new Vector2(buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Width / 2, buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Height / 2)); visualOptionsButton.name = "Visual Options"; soundOptionsButton = new MenuDisplayObject(Game, buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)), buttonsSprite.GetSubSprite(new Rectangle(0, 65, 256, 65)), new Vector2(Game1.ScreenSize.X / 4, buttonYPosition + BUTTON_Y_DISTANCE * 3), new Vector2(buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Width / 2, buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Height / 2)); soundOptionsButton.name = "Sound Options"; backButton = new MenuDisplayObject(Game, buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)), buttonsSprite.GetSubSprite(new Rectangle(0, 65, 256, 65)), new Vector2(Game1.ScreenSize.X / 4, buttonYPosition + BUTTON_Y_DISTANCE * 4), new Vector2(buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Width / 2, buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Height / 2)); backButton.name = "Back"; buttons = new List<MenuDisplayObject>(); buttons.Add(gameOptionsButton); buttons.Add(controlOptionsButton); buttons.Add(visualOptionsButton); buttons.Add(soundOptionsButton); buttons.Add(backButton); holdTimer = Game.HoldKeyTreshold; buttonIndex = 0; base.Initialize(); }
private void CreateButtons() { buttons = new List <MenuDisplayObject>(); newGameButton = new MenuDisplayObject(this.Game, buttonSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)), buttonSprite.GetSubSprite(new Rectangle(0, 65, 256, 65)), new Vector2(Game1.ScreenSize.X / 2, Game1.ScreenSize.Y / 3), new Vector2(buttonSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Width / 2, buttonSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Height / 2)); newGameButton.name = "New Game"; buttons.Add(newGameButton); casualNewGameButton = new MenuDisplayObject(this.Game, buttonSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)), buttonSprite.GetSubSprite(new Rectangle(0, 65, 256, 65)), new Vector2(Game1.ScreenSize.X / 2, Game1.ScreenSize.Y / 3 + 80), new Vector2(buttonSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Width / 2, buttonSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Height / 2)); casualNewGameButton.name = "Continue"; buttons.Add(casualNewGameButton); optionsButton = new MenuDisplayObject(this.Game, buttonSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)), buttonSprite.GetSubSprite(new Rectangle(0, 65, 256, 65)), new Vector2(Game1.ScreenSize.X / 2, Game1.ScreenSize.Y / 3 + 160), new Vector2(buttonSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Width / 2, buttonSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Height / 2)); optionsButton.name = "Options"; buttons.Add(optionsButton); mapCreatorButton = new MenuDisplayObject(this.Game, buttonSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)), buttonSprite.GetSubSprite(new Rectangle(0, 65, 256, 65)), new Vector2(Game1.ScreenSize.X / 2, Game1.ScreenSize.Y / 3 + 240), new Vector2(buttonSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Width / 2, buttonSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Height / 2)); //mapCreatorButton.name = "Create Level"; mapCreatorButton.name = "Credits"; buttons.Add(mapCreatorButton); exitGameButton = new MenuDisplayObject(this.Game, buttonSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)), buttonSprite.GetSubSprite(new Rectangle(0, 65, 256, 65)), new Vector2(Game1.ScreenSize.X / 2, Game1.ScreenSize.Y / 3 + 320), new Vector2(buttonSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Width / 2, buttonSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Height / 2)); exitGameButton.name = "Exit Game"; buttons.Add(exitGameButton); }
private void ButtonControls(GameTime gameTime) { if (ControlManager.CheckPress(RebindableKeys.Up)) { buttonIndex--; holdTimer = Game.HoldKeyTreshold; PlayHoverSound(); } else if (ControlManager.CheckHold(RebindableKeys.Up)) { holdTimer -= gameTime.ElapsedGameTime.Milliseconds; if (holdTimer <= 0) { buttonIndex--; holdTimer = Game.ScrollSpeedSlow; PlayHoverSound(); } } else if (ControlManager.CheckPress(RebindableKeys.Down)) { buttonIndex++; holdTimer = Game.HoldKeyTreshold; PlayHoverSound(); } else if (ControlManager.CheckHold(RebindableKeys.Down)) { holdTimer -= gameTime.ElapsedGameTime.Milliseconds; if (holdTimer <= 0) { buttonIndex++; holdTimer = Game.ScrollSpeedSlow; PlayHoverSound(); } } if (buttonIndex > buttons.Count - 1) { if (ControlManager.PreviousKeyUp(RebindableKeys.Down)) { buttonIndex = 0; } else { buttonIndex = buttons.Count - 1; } } else if (buttonIndex < 0) { if (ControlManager.PreviousKeyUp(RebindableKeys.Up)) { buttonIndex = buttons.Count - 1; } else { buttonIndex = 0; } } activeButton = buttons[buttonIndex]; foreach (MenuDisplayObject button in buttons) { button.isActive = false; } activeButton.isActive = true; if (ControlManager.CheckPress(RebindableKeys.Action1) || ControlManager.CheckKeyPress(Keys.Enter)) { ButtonActions(); } // TODO: REMOVE FOR RELEASE VERSION //if (ControlManager.CheckKeyPress(Keys.M)) //{ // Game.stateManager.ChangeState("LevelTesterState"); //} if (ControlManager.CheckKeyHold(Keys.LeftAlt) && ControlManager.CheckKeyPress(Keys.C)) { Game.stateManager.ChangeState("CampaignState"); } }
public override void Initialize() { buttonYPosition = Game1.ScreenSize.Y / 5; buttonsSprite = new Sprite(Game.Content.Load <Texture2D>("Overworld-Sprites/buttons"), null); buttonsFont = Game.fontManager.GetFont(16); contrastBackDropSprite = buttonsSprite.GetSubSprite(new Rectangle(0, 0, 1, 1)); //devButton = new MenuDisplayObject(Game, // buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)), // buttonsSprite.GetSubSprite(new Rectangle(0, 65, 256, 65)), // new Vector2(Game1.ScreenSize.X / 4, buttonYPosition), // new Vector2(buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Width / 2, // buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Height / 2)); //devButton.name = "Develop"; easyButton = new MenuDisplayObject(Game, buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)), buttonsSprite.GetSubSprite(new Rectangle(0, 65, 256, 65)), new Vector2(Game1.ScreenSize.X / 4, buttonYPosition + BUTTON_Y_DISTANCE), new Vector2(buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Width / 2, buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Height / 2)); easyButton.name = "Easy"; normalButton = new MenuDisplayObject(Game, buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)), buttonsSprite.GetSubSprite(new Rectangle(0, 65, 256, 65)), new Vector2(Game1.ScreenSize.X / 4, buttonYPosition + BUTTON_Y_DISTANCE * 2), new Vector2(buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Width / 2, buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Height / 2)); normalButton.name = "Normal"; hardButton = new MenuDisplayObject(Game, buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)), buttonsSprite.GetSubSprite(new Rectangle(0, 65, 256, 65)), new Vector2(Game1.ScreenSize.X / 4, buttonYPosition + BUTTON_Y_DISTANCE * 3), new Vector2(buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Width / 2, buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Height / 2)); hardButton.name = "Hard"; //hardCoreButton = new MenuDisplayObject(Game, // buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)), // buttonsSprite.GetSubSprite(new Rectangle(0, 65, 256, 65)), // new Vector2(Game1.ScreenSize.X / 4, buttonYPosition + BUTTON_Y_DISTANCE * 4), // new Vector2(buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Width / 2, // buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Height / 2)); //hardCoreButton.name = "Hardcore"; backButton = new MenuDisplayObject(Game, buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)), buttonsSprite.GetSubSprite(new Rectangle(0, 65, 256, 65)), new Vector2(Game1.ScreenSize.X / 4, buttonYPosition + BUTTON_Y_DISTANCE * 4), new Vector2(buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Width / 2, buttonsSprite.GetSubSprite(new Rectangle(0, 0, 256, 65)).Height / 2)); backButton.name = "Back"; buttons = new List <MenuDisplayObject>(); //buttons.Add(devButton); buttons.Add(easyButton); buttons.Add(normalButton); buttons.Add(hardButton); //buttons.Add(hardCoreButton); buttons.Add(backButton); holdTimer = Game.HoldKeyTreshold; buttonIndex = 0; descriptions = new List <string>(); //descriptions.Add("Mode for development and testing."); descriptions.Add("Easy mode for inexperienced players.\nYou take less damage from enemy fire and you receive more money."); descriptions.Add("Regular difficulty.\nThe way the game is intended to be played."); descriptions.Add("An extra difficulty for players looking for a real challenge.\nYou take more damage from enemy fire."); //descriptions.Add("An extra difficulty for players looking for a real \nchallenge.\nAs hard as Hard-difficulty but your life remain constant in both Shooter and Space.\nIf you run out of life you die... "); descriptions.Add("Return to main menu"); base.Initialize(); }