public void AddMenuOption(MenuOption menuOption, bool setDefault) { menuOptions.Add(menuOption); if (setDefault == true) { defaultMenuOption = menuOption; } }
public void LoadTechniques(BattleCharacter character) { battleTechniques = new List<BattleTechnique>(); menuOptions = new List<MenuOption>(); currentMenuOption = null; defaultMenuOption = null; foreach (BattleTechnique battleTechnique in character.Techniques) { if (battleTechnique.techniqueName != "Attack" && battleTechnique.techniqueName != "Defend") { MenuOption option = new MenuOption(battleTechnique.techniqueName, battleTechnique.techniqueDescription, Color.Yellow, Color.White, "blank", "blank"); AddMenuOption(option, (menuOptions.Count == 0)); battleTechniques.Add(battleTechnique); } } }
public void LoadContent(PartyCharacter partyCharacter) { linkedCharacter = partyCharacter; switch (mode) { case PlayerCharacterStatusBoxMode.EndOfBattle: GameClass.SoundManager.LoadSound("Audio/expAddSound"); GameClass.SoundManager.LoadSound("Audio/levelUpSound"); GameClass.SoundManager.LoadSound("Audio/newTechniqueSound"); break; case PlayerCharacterStatusBoxMode.MapStatus: spendPointsMenu = new Menu("Spend Points Menu", Vector2.Zero, 5, "Blank", "General/playerTurnMenuCursor", Vector2.Zero, Vector2.Zero, false); MenuOption HPOption = new MenuOption("AddPointsHP", "Spend a point to increase " + linkedCharacter.CharacterID.ToString() + "'s HP by 2.", Color.White, Color.White, "General/spendPointsSelected", "General/spendPointsNotSelected"); spendPointsMenu.AddMenuOption(HPOption, true); MenuOption MPOption = new MenuOption("AddPointsMP", "Spend a point to increase " + linkedCharacter.CharacterID.ToString() + "'s MP by 2.", Color.White, Color.White, "General/spendPointsSelected", "General/spendPointsNotSelected"); spendPointsMenu.AddMenuOption(MPOption, false); MenuOption ATKOption = new MenuOption("AddPointsATK", "Spend a point to increase " + linkedCharacter.CharacterID.ToString() + "'s ATK by 1.", Color.White, Color.White, "General/spendPointsSelected", "General/spendPointsNotSelected"); spendPointsMenu.AddMenuOption(ATKOption, false); MenuOption DEFOption = new MenuOption("AddPointsDEF", "Spend a point to increase " + linkedCharacter.CharacterID.ToString() + "'s DEF by 1.", Color.White, Color.White, "General/spendPointsSelected", "General/spendPointsNotSelected"); spendPointsMenu.AddMenuOption(DEFOption, false); MenuOption MAG_ATKOption = new MenuOption("AddPointsMAG_ATK", "Spend a point to increase " + linkedCharacter.CharacterID.ToString() + "'s MAG_ATK by 1.", Color.White, Color.White, "General/spendPointsSelected", "General/spendPointsNotSelected"); spendPointsMenu.AddMenuOption(MAG_ATKOption, false); MenuOption MAG_DEFOption = new MenuOption("AddPointsMAG_DEF", "Spend a point to increase " + linkedCharacter.CharacterID.ToString() + "'s MAG_DEF by 1.", Color.White, Color.White, "General/spendPointsSelected", "General/spendPointsNotSelected"); spendPointsMenu.AddMenuOption(MAG_DEFOption, false); MenuOption SPDOption = new MenuOption("AddPointsSPD", "Spend a point to increase " + linkedCharacter.CharacterID.ToString() + "'s SPD by 1.", Color.White, Color.White, "General/spendPointsSelected", "General/spendPointsNotSelected"); spendPointsMenu.AddMenuOption(SPDOption, false); spendPointsInfoBar = new InfoBar("General/InfoBarBG", Vector2.Zero, GameClass.Size8Font, Color.White, new Vector2(-225, -10), 0.1f); break; } }
public void ClearOptions() { menuOptions = new List<MenuOption>(); defaultMenuOption = null; }
public override void Update(GameTime gameTime) { if (menuState != MenuState.IdleAwaitingInput) { controls.ControlsActive = false; debugControls.ControlsActive = false; } switch(menuState) { case MenuState.FadingIn: if (alpha < 1.0f) { alpha += fadeSpeed; } else { alpha = 1.0f; menuState = MenuState.IdleAwaitingInput; controls.ControlsActive = true; debugControls.ControlsActive = true; } break; case MenuState.FadingOut: if (alpha > 0.0f) { alpha -= fadeSpeed; } else { alpha = 0.0f; menuState = MenuState.IdleFaded; } break; case MenuState.FadingOutHalf: if (alpha > 0.5f) { alpha -= fadeSpeed; } else { alpha = 0.5f; menuState = MenuState.IdleHalfFaded; } break; } controls.Update(gameTime); debugControls.Update(gameTime); if (controls.ButtonPressed(Buttons.DPadDown, true, true) || debugControls.KeyPressed(Keys.Down, true, true)) { GameClass.SoundManager.PlaySoundEffect("Audio/cursorMove"); currentMenuOption.MenuOptionState = MenuOptionState.NotSelected; if (menuOptions.IndexOf(currentMenuOption) < menuOptions.Count - 1) { currentMenuOption = menuOptions[menuOptions.IndexOf(currentMenuOption) + 1]; } else { currentMenuOption = menuOptions[0]; } currentMenuOption.MenuOptionState = MenuOptionState.Selected; } else if (controls.ButtonPressed(Buttons.DPadUp, true, true) || debugControls.KeyPressed(Keys.Up, true, true)) { GameClass.SoundManager.PlaySoundEffect("Audio/cursorMove"); currentMenuOption.MenuOptionState = MenuOptionState.NotSelected; if (menuOptions.IndexOf(currentMenuOption) > 0) { currentMenuOption = menuOptions[menuOptions.IndexOf(currentMenuOption) - 1]; } else { currentMenuOption = menuOptions[menuOptions.Count - 1]; } currentMenuOption.MenuOptionState = MenuOptionState.Selected; } else if (controls.ButtonPressed(Buttons.B, false, false) || debugControls.KeyPressed(Keys.Space, false, false)) { menuState = MenuState.IdleValueSelected; GameClass.SoundManager.PlaySoundEffect("Audio/menuConfirm"); controls.ControlsActive = false; debugControls.ControlsActive = false; } base.Update(gameTime); }
public void Show() { menuState = MenuState.FadingIn; if (currentMenuOption == null) { currentMenuOption = defaultMenuOption; currentMenuOption.MenuOptionState = MenuOptionState.Selected; } controls.ControlsActive = true; debugControls.ControlsActive = true; }
public void SetDefaultMenuOption(int menuOptionIndex) { defaultMenuOption = menuOptions[menuOptionIndex]; }
public void ResetSelection() { currentMenuOption = defaultMenuOption; }
public override void LoadContent() { //Loads the content for a battle. //load the static and resued textures. battleBG = GlobalGameInfo.CurrentBattleBG; battleHUD = GameClass.LoadTextureData("General/BattleHUD"); turnChartBG = GameClass.LoadTextureData("General/TurnChartBG"); statusBarTexture = GameClass.LoadTextureData("General/StatusBar"); hpBarTexture = GameClass.LoadTextureData("General/HPBar"); mpBarTexture = GameClass.LoadTextureData("General/MPBar"); buffArrowTexture = GameClass.LoadTextureData("General/buffArrow"); turnChartSelection = GameClass.LoadTextureData("General/turnChartSelection"); //Load in the sound effects used by the BattleScreen. GameClass.SoundManager.LoadSound("Audio/dash"); GameClass.SoundManager.LoadSound("Audio/victory"); GameClass.SoundManager.LoadSound("Audio/loss"); //reset the games camera to zero as the BattleScreen does not use the camera. GameClass.CurrentGameCamera.Position = Vector2.Zero; //Initialise the controllers. controls = new GamePadController(PlayerIndex.One); controls.ControlsActive = false; debugControls = new KeyboardController(); debugControls.ControlsActive = false; restartScreenControls = new KeyboardController(); //Set up the player turn menu. playerTurnMenu = new Menu("Player Turn Menu", new Vector2(138, 172), 8, "General/playerTurnMenuBG", "General/playerTurnMenuCursor", Vector2.Zero, Vector2.Zero, true); playerTechniqueMenu = new CharacterTechniqueMenu(new Vector2(150, 172), "General/playerTurnMenuCursor", "General/playerTechniqueMenuBG", new Vector2(59, 12)); battleInventoryMenu = new BattleInventoryMenu(new Vector2(150, 172), "General/playerTurnMenuCursor", "General/battleInventoryMenuBG", new Vector2(59, 12)); battleTargetSelector = new BattleTargetSelector("General/playerTurnMenuCursor"); //Set up and add the options for the player turn menu. MenuOption attackOption = new MenuOption("Attack", "Perform a normal attack.", Color.Black, Color.White, "General/playerTurnMenuButtonSelected", "General/playerTurnMenuButtonNotSelected"); playerTurnMenu.AddMenuOption(attackOption, true); MenuOption defendOption = new MenuOption("Defend", "Defend yourself.", Color.Black, Color.White, "General/playerTurnMenuButtonSelected", "General/playerTurnMenuButtonNotSelected"); playerTurnMenu.AddMenuOption(defendOption, false); MenuOption skillsOption = new MenuOption("Skills", "Use a special skill.", Color.Black, Color.White, "General/playerTurnMenuButtonSelected", "General/playerTurnMenuButtonNotSelected"); playerTurnMenu.AddMenuOption(skillsOption, false); MenuOption itemsOption = new MenuOption("Items", "Use an Item.", Color.Black, Color.White, "General/playerTurnMenuButtonSelected", "General/playerTurnMenuButtonNotSelected"); playerTurnMenu.AddMenuOption(itemsOption, false); //Set up the game over menu. gameOverMenu = new Menu("Game Over Menu", new Vector2(GameClass.CurrentGameCamera.Position.X + GameClass.CurrentGameCamera.Size.X / 2, GameClass.CurrentGameCamera.Position.Y + GameClass.CurrentGameCamera.Size.Y / 2), 8, "General/gameOverMenuBG", "General/playerTurnMenuCursor", Vector2.Zero, new Vector2(0, 50), true); MenuOption retryOption = new MenuOption("Retry", "Retry this battle from the beginning.", Color.Black, Color.White, "General/playerTurnMenuButtonSelected", "General/playerTurnMenuButtonNotSelected"); gameOverMenu.AddMenuOption(retryOption, true); MenuOption quitOption = new MenuOption("Quit", "Quit the game.", Color.Black, Color.White, "General/playerTurnMenuButtonSelected", "General/playerTurnMenuButtonNotSelected"); gameOverMenu.AddMenuOption(quitOption, false); //Set up the info bar. infoBar = new InfoBar("General/InfoBarBG", new Vector2(230, 10), GameClass.Size8Font, Color.White, new Vector2(-225, -10), 0.1f); //For all the items in the players general inventory, check which are battle items and set them up as new BattleItem objects, loading their effect data from BattleCharacters/BattleItemList.xml into the battle inventory. List<BattleItemData> battleItemDataList = GameClass.ContentManager.Load<List<BattleItemData>>("BattleCharacters/BattleItemDataList"); foreach (KeyValuePair<InventoryItemIdentity, int> inventoryItem in GlobalGameInfo.Inventory) { foreach (BattleItemData battleItemData in battleItemDataList) { if (battleItemData.itemID == inventoryItem.Key) { BattleItem newBattleItem = new BattleItem(); newBattleItem.LoadContent(battleItemData, inventoryItem.Value); battleItemInventory.Add(newBattleItem); } } } //Initialise the status box list. playerStatusBoxes = new List<PlayerCharacterStatusBox>(); //For the first three characters in the players party, load the characters sprites and techniques from <characterName>Battle.xml and load their stats from the PartyCharacter into a BattleCharacter //The players party takes up Battle Orders 0-2. int battleOrder = 0; int statusBoxDrawPos = 110; for (int count = 0; count < 3; count++) { if (GlobalGameInfo.CurrentPlayerParty[count] != null) { PlayerBattleCharacter newPlayerCharacter = new PlayerBattleCharacter(); newPlayerCharacter.LoadContent(battleOrder, GlobalGameInfo.CurrentPlayerParty[count]); activeCharacters.Add(newPlayerCharacter); battleOrder ++; //Create a new status box for each loaded character. PlayerCharacterStatusBox newStatusBox = new PlayerCharacterStatusBox(new Vector2(statusBoxDrawPos, 170), PlayerCharacterStatusBoxMode.EndOfBattle); newStatusBox.LoadContent(GlobalGameInfo.CurrentPlayerParty[count]); playerStatusBoxes.Add(newStatusBox); statusBoxDrawPos += 210; } } //Load the enemies. battleOrder = 3; if (retryingBattle == false) {//If this battle is a fresh battle.... //load the 'mandatory' enemy (i.e. The map enemy that the player collided with) into the first enemy slot (Battle Order 3) EnemyBattleCharacter mandatoryEnemyCharacter = new EnemyBattleCharacter(); mandatoryEnemyCharacter.LoadContent(battleOrder, GlobalGameInfo.CurrentEnemyInBattle.CharacterID); activeCharacters.Add(mandatoryEnemyCharacter); enemyGroupLostTo.Add(GlobalGameInfo.CurrentEnemyInBattle.CharacterID); battleOrder++; //Load in BattleCharacters/EnemyDifficultyList.xml and find the 'mandatory' enemy's difficulty rating. List<EnemyDifficultyData> enemyDifficultyList = GameClass.ContentManager.Load<List<EnemyDifficultyData>>("BattleCharacters/EnemyDifficultyList"); int currentEnemyDifficulty = -1; int spawnEnemy = 0; foreach (EnemyDifficultyData difficultyData in enemyDifficultyList) { if (difficultyData.enemyID == GlobalGameInfo.CurrentEnemyInBattle.CharacterID) { currentEnemyDifficulty = difficultyData.difficultyLevel; } } //Iterate through BattleCharacters/EnemyDifficultyList.xml and retrieve all enemies of a similar difficulty rating (i.e. within a range of -1 to 1 from it) List<CharacterIdentity> similarDifficultyEnemies = new List<CharacterIdentity>(); foreach (EnemyDifficultyData difficultyData in enemyDifficultyList) { if (Math.Abs(difficultyData.difficultyLevel - currentEnemyDifficulty) < 2) { similarDifficultyEnemies.Add(difficultyData.enemyID); } } if (similarDifficultyEnemies.Count > 0) {//if there are more enemies of a similar difficulty.... for (int count = 0; count < 2; count++) {//for the rest of the enemy slots (Battle Orders 4 and 5).... //Decide randomly whether to spawn another enemy. spawnEnemy = GameClass.Random.Next(0, 2); if (spawnEnemy == 1) {//if decided to spawn another enemy... //Decide randomly which enemy to spawn, and load it in. CharacterIdentity enemyToSpawn = similarDifficultyEnemies[GameClass.Random.Next(0, similarDifficultyEnemies.Count)]; EnemyBattleCharacter optionalEnemyCharacter = new EnemyBattleCharacter(); optionalEnemyCharacter.LoadContent(battleOrder, enemyToSpawn); activeCharacters.Add(optionalEnemyCharacter); enemyGroupLostTo.Add(enemyToSpawn); battleOrder++; } } } } else if(retryingBattle == true) {//Otherwise if this battle is a retry, load the previous enemy group back in. foreach (CharacterIdentity enemyID in enemyGroupLostTo) { EnemyBattleCharacter reloadedEnemyCharacter = new EnemyBattleCharacter(); reloadedEnemyCharacter.LoadContent(battleOrder, enemyID); activeCharacters.Add(reloadedEnemyCharacter); battleOrder++; } retryingBattle = false; } //Add all the loaded characters to the draw list. foreach (BattleCharacter character in activeCharacters) { drawList.Add(character); } //Initialise the turn chart and its indicator. turnChartSelectorFadeState = AlternatingFadeState.FadingOut; turnChartSelectionAlpha = 1.0f; currentTurnCount = 1; currentTurnIndex = 0; //Calculate the first turns order. CalculateTurnOrder(); }