// Update: public override void Update(GameTime gameTime, KeyboardState ks) { base.Update(gameTime, ks); if (!loadedSong) { parentManager.audioEngine.setNextSong(MGP_Constants.music.mainMenu); parentManager.audioEngine.playNextSong(2, true); Console.WriteLine("Added mainMenu to music queue"); loadedSong = true; } // Move Menu Selection Up: if (km.ActionPressed(KeyboardManager.action.up, KeyboardManager.playerIndex.all)) { currentMenuItem = items[currentMenuItem].above.activeValue; moveGlove = true; // SFX: parentManager.audioEngine.playSound(MGP_Constants.soundEffects.menuSelect, MGP_Constants.MENU_SFX_VOLUME); } // Move Menu Selection Down: if (km.ActionPressed(KeyboardManager.action.down, KeyboardManager.playerIndex.all)) { currentMenuItem = items[currentMenuItem].below.activeValue; moveGlove = true; // SFX: parentManager.audioEngine.playSound(MGP_Constants.soundEffects.menuSelect, MGP_Constants.MENU_SFX_VOLUME); } // Move glove if (moveGlove) { if (Vector2.Distance(glovePos, new Vector2(items[currentMenuItem].xPos - 60, items[currentMenuItem].yPos - 35)) < 1.0f) { moveGlove = false; } else { glovePos.Y = MGP_Tools.Ease(glovePos.Y, items[currentMenuItem].yPos - 35, 0.5f); } } // Press ENTER while some menu item is highlighted: if (km.ActionPressed(KeyboardManager.action.select, KeyboardManager.playerIndex.all)) { parentManager.audioEngine.playSound(MGP_Constants.soundEffects.diceHit, MGP_Constants.MENU_SFX_VOLUME + 0.15f); // Map: Pirate Bay if (currentMenuItem == (int)MenuItem.MainMenu.PIRATE) { parentManager.gameOptions.mapName = MenuItem.MainMenu.MOUNTAIN; S_PlayerCountMenu playerCountMenu = new S_PlayerCountMenu(parentManager, 0, 0); parentManager.AddStateQueue(playerCountMenu); this.flagForDeletion = true; } // Option: Controls if (currentMenuItem == (int)MenuItem.MainMenu.MOUNTAIN) { S_Controls controls = new S_Controls(parentManager, 0, 0); parentManager.AddStateQueue(controls); this.active = false; } // Option: About if (currentMenuItem == (int)MenuItem.MainMenu.ABOUT) { S_About about = new S_About(parentManager, 0, 0, this); parentManager.AddStateQueue(about); this.active = false; this.visible = false; } // Option: Exit if (currentMenuItem == (int)MenuItem.MainMenu.EXIT) { parentManager.game.Exit(); } } // end pressed 'select' button } // end update function
// Update: public override void Update(GameTime gameTime, KeyboardState ks) { base.Update(gameTime, ks); // Move Menu Selection Up: if (km.ActionPressed(KeyboardManager.action.up, KeyboardManager.playerIndex.all)) { // SFX: parentManager.audioEngine.playSound(MGP_Constants.soundEffects.menuSelect, MGP_Constants.MENU_SFX_VOLUME); currentMenuItem = items[currentMenuItem].above.activeValue; moveGlove = true; } // Move Menu Selection Down: if (km.ActionPressed(KeyboardManager.action.down, KeyboardManager.playerIndex.all)) { // SFX: parentManager.audioEngine.playSound(MGP_Constants.soundEffects.menuSelect, MGP_Constants.MENU_SFX_VOLUME); currentMenuItem = items[currentMenuItem].below.activeValue; moveGlove = true; } // Move glove if (moveGlove) { if (Vector2.Distance(glovePos, new Vector2(items[currentMenuItem].xPos - 60, items[currentMenuItem].yPos - 35)) < 1.0f) { moveGlove = false; } else { glovePos.Y = MGP_Tools.Ease(glovePos.Y, items[currentMenuItem].yPos - 35, 0.5f); } } // Press ENTER while some menu item is highlighted: if (km.ActionPressed(KeyboardManager.action.select, KeyboardManager.playerIndex.all)) { // SFX: parentManager.audioEngine.playSound(MGP_Constants.soundEffects.diceHit, MGP_Constants.MENU_SFX_VOLUME + 0.15f); // Difficulty: Easy if (currentMenuItem == (int)MenuItem.Difficulty.EASY) { parentManager.gameOptions.difficulty = MenuItem.Difficulty.EASY; } // Difficulty: Medium if (currentMenuItem == (int)MenuItem.Difficulty.MEDIUM) { parentManager.gameOptions.difficulty = MenuItem.Difficulty.MEDIUM; } // Difficulty: Medium if (currentMenuItem == (int)MenuItem.Difficulty.HARD) { parentManager.gameOptions.difficulty = MenuItem.Difficulty.HARD; } // Go to next menu S_NumRoundsMenu numRoundsMenu = new S_NumRoundsMenu(parentManager, 0, 0); parentManager.AddStateQueue(numRoundsMenu); this.flagForDeletion = true; } // Press Cancel Key: Goes back to Player Count menu: if (km.ActionPressed(KeyboardManager.action.cancel, KeyboardManager.playerIndex.all)) { // SFX: parentManager.audioEngine.playSound(MGP_Constants.soundEffects.menuCancel, MGP_Constants.MENU_SFX_VOLUME); S_PlayerCountMenu playerCountMenu = new S_PlayerCountMenu(parentManager, 0, 0); parentManager.AddStateQueue(playerCountMenu); this.flagForDeletion = true; } }
// Update: public override void Update(GameTime gameTime, KeyboardState ks) { base.Update(gameTime, ks); // Only the current player can press buttons if (players.Count == 1) { currPlayer = KeyboardManager.playerIndex.two; } else { currPlayer = KeyboardManager.playerIndex.one; } // Move Menu Selection Up: if (km.ActionPressed(KeyboardManager.action.up, currPlayer)) { // SFX: parentManager.audioEngine.playSound(MGP_Constants.soundEffects.menuSelect, MGP_Constants.MENU_SFX_VOLUME); if (items[currentMenuItem].above != null && (players.Count == 0 || items[currentMenuItem].above.activeValue != (int)players[0])) { currentMenuItem = items[currentMenuItem].above.activeValue; moveGlove = true; } } // Move Menu Selection Down: if (km.ActionPressed(KeyboardManager.action.down, currPlayer)) { // SFX: parentManager.audioEngine.playSound(MGP_Constants.soundEffects.menuSelect, MGP_Constants.MENU_SFX_VOLUME); if (items[currentMenuItem].below != null && (players.Count == 0 || items[currentMenuItem].below.activeValue != (int)players[0])) { currentMenuItem = items[currentMenuItem].below.activeValue; moveGlove = true; } } // Move Menu Selection Left: if (km.ActionPressed(KeyboardManager.action.left, currPlayer)) { // SFX: parentManager.audioEngine.playSound(MGP_Constants.soundEffects.menuSelect, MGP_Constants.MENU_SFX_VOLUME); if (items[currentMenuItem].left != null && (players.Count == 0 || items[currentMenuItem].left.activeValue != (int)players[0])) { currentMenuItem = items[currentMenuItem].left.activeValue; moveGlove = true; } } // Move Menu Selection Right: if (km.ActionPressed(KeyboardManager.action.right, currPlayer)) { // SFX: parentManager.audioEngine.playSound(MGP_Constants.soundEffects.menuSelect, MGP_Constants.MENU_SFX_VOLUME); if (items[currentMenuItem].right != null && (players.Count == 0 || items[currentMenuItem].right.activeValue != (int)players[0])) { currentMenuItem = items[currentMenuItem].right.activeValue; moveGlove = true; } } // Move glove if (moveGlove) { if (Vector2.Distance(glovePos, new Vector2(items[currentMenuItem].xPos - (cloudWidth / 2 + 60), items[currentMenuItem].yPos + 40)) < 1.0f) { moveGlove = false; } else { glovePos.X = MGP_Tools.Ease(glovePos.X, items[currentMenuItem].xPos - (cloudWidth / 2 + 60), 0.5f); glovePos.Y = MGP_Tools.Ease(glovePos.Y, items[currentMenuItem].yPos - 40, 0.5f); } } // Press ENTER while some menu item is highlighted: if (km.ActionPressed(KeyboardManager.action.select, currPlayer)) { // SFX: parentManager.audioEngine.playSound(MGP_Constants.soundEffects.diceHit, MGP_Constants.MENU_SFX_VOLUME + 0.15f); // Add character to List players.Add((Player.Type)items[currentMenuItem].activeValue); // If only one player or both players have made selections if (numOfPlayers == 1 || players.Count == 2) { // Add the computer players at random while (players.Count < 4) { comPlayer = parentManager.random.Next(0, 5); if (!players.Contains((Player.Type)comPlayer)) { players.Add((Player.Type)comPlayer); } } // Create player entitities and add to game options for (int i = 0; i < players.Count; i++) { // add as a human player if (i == 0) { parentManager.gameOptions.players.Add(new Player(this.creator, players[i], true, KeyboardManager.playerIndex.one)); } else if (i == numOfPlayers - 1) { parentManager.gameOptions.players.Add(new Player(this.creator, players[i], true, KeyboardManager.playerIndex.two)); } // add a comp player else { parentManager.gameOptions.players.Add(new Player(this.creator, players[i], false, KeyboardManager.playerIndex.none)); } } // Move onto next menu S_DifficultyMenu diffMenu = new S_DifficultyMenu(parentManager, 0, 0); parentManager.AddStateQueue(diffMenu); this.flagForDeletion = true; } // Begin character selection for player 2 else { // Move selection to first availble character for player two if (currentMenuItem == 0) { currentMenuItem = 1; } else { currentMenuItem = 0; } moveGlove = true; } } // end of enter action key press // Option: Cancel Key if (km.ActionPressed(KeyboardManager.action.cancel, currPlayer)) { // SFX: parentManager.audioEngine.playSound(MGP_Constants.soundEffects.menuCancel, MGP_Constants.MENU_SFX_VOLUME); // If first player has made a choice if (players.Count == 1) { // Remove the character choice so they can choose again players.RemoveAt(0); } // No selections have been made and we return to the player count menu else { S_PlayerCountMenu playerCountMenu = new S_PlayerCountMenu(parentManager, 0, 0); parentManager.AddStateQueue(playerCountMenu); this.flagForDeletion = true; } } // end of cancel key } // end of update