public override void Update(GameTime gameTime, KeyboardState ks) { base.Update(gameTime, ks); // If result has finished easing if (Vector2.Distance(entities[currentIndex].position, resultPos[currentIndex]) < 1.0f) { // Last result has been eased if (currentIndex == 3) { // Wait time after displaying last result if (waitTime >= maxWaitTime) { S_BonusResults bonusResults = new S_BonusResults(parentManager, xPos, yPos); parentManager.AddStateQueue(bonusResults); this.flagForDeletion = true; } waitTime++; } else { // ease next result currentIndex++; } } // Continue to ease the current indexed result else { entities[currentIndex].position.Y = MGP_Tools.Ease(entities[currentIndex].position.Y, resultPos[currentIndex].Y, 0.05f); } }
public static void Follow_Player(GameStateManager parentManager, Player currPlayer) { // Move camera to current player parentManager.boardGame.cameraProperties.setPos(currPlayer.meeple.pos); // Make sure camera is still on the board MGP_Tools.KeepCameraOnBoard(parentManager); }
// Update: public override void Update(GameTime gameTime, KeyboardState ks) { base.Update(gameTime, ks); // Move the player if (moveNum > 0) { // Find next space E_Space spaceToMoveTo = currPlayer.currSpace.spacesAhead[0]; // Move the meeple untill it's close enough to space if (Vector2.Distance(spaceToMoveTo.getMeepleLocation(), currPlayer.meeple.getPosCenter()) > 1.0F) { float newX = MGP_Tools.Ease(currPlayer.meeple.getPosCenter().X, spaceToMoveTo.getMeepleLocation().X, 0.15F); float newY = MGP_Tools.Ease(currPlayer.meeple.getPosCenter().Y, spaceToMoveTo.getMeepleLocation().Y, 0.15F); currPlayer.meeple.setPos(new Vector2(newX, newY)); MGP_Tools.Follow_Player(parentManager, currPlayer); // Play space sound effect: if (!soundPlayed) { parentManager.audioEngine.playSound(MGP_Constants.soundEffects.space, 0.7f); soundPlayed = true; } } // Meeple has arrived at new space else { moveNum--; currPlayer.currSpace = spaceToMoveTo; // allow sound to play next time: soundPlayed = false; // If player passes a star if (currPlayer.currSpace.type == Entity.typeSpace.star) { S_BuyStar buyStar = new S_BuyStar(parentManager, 0, 0); parentManager.AddStateQueue(buyStar); this.active = false; //pause moving player } } } // finished moving meeple else { // Occupy that space so another meeple doesn't run him/her over: currPlayer.currSpace.occupySpace(currPlayer); S_LandAction landAction = new S_LandAction(parentManager, 0, 0); parentManager.AddStateQueue(landAction); this.flagForDeletion = true; } // Listen for pausing here: ListenPause(); }
// Update: public override void Update(GameTime gameTime, KeyboardState ks) { base.Update(gameTime, ks); // If result has finished easing if (Vector2.Distance(entities[currentIndex].position, resultPos[currentIndex]) < 1.0f) { // Last result has been eased if (currentIndex == 3) { // Wait time after displaying last result if (waitTime >= maxWaitTime) { // Begin next round: parentManager.round.currRound++; parentManager.round.playerIsPlaying = false; parentManager.round.roundStart = true; this.flagForDeletion = true; parentManager.round.active = true; } else if (!changedLastPlayer) { // update last players coins results[currentIndex].coins += entities[currentIndex].changeValue; // Prevent negative coin values if (results[currentIndex].coins < 0) { results[currentIndex].coins = 0; } changedLastPlayer = true; } waitTime++; } else { // update players coins results[currentIndex].coins += entities[currentIndex].changeValue; // Prevent negative coin values if (results[currentIndex].coins < 0) { results[currentIndex].coins = 0; } // ease next result currentIndex++; } } // Continue to ease the current indexed result else { entities[currentIndex].position.Y = MGP_Tools.Ease(entities[currentIndex].position.Y, resultPos[currentIndex].Y, 0.1f); } }
public override void Update(GameTime gameTime, KeyboardState ks) { base.Update(gameTime, ks); // Buy the star Or acknowledging they suck and cant buy the star, either way move on if (parentManager.km.ActionPressed(KeyboardManager.action.select, KeyboardManager.playerIndex.all) || AI_Timer > 60 || moveYPos > 90) { // start the animation for getting a star if (buystar) { startAnimation = true; } // Finished star animation or couldnt buy star if (moveYPos > 90 || !buystar) { // Move the star to new space if (buystar) { MGP_Tools.Assign_Star(parentManager.boardGame); parentManager.round.currPlayer.currSpace.type = Entity.typeSpace.chance; } this.flagForDeletion = true; // Start moving the player again parentManager.states.Find(s => s.GetType() == typeof(S_MovePlayer)).active = true; } } // If player is buying star, start animation for buying star if (startAnimation) { moveYPos++; } // If current play is com, increase AI_Timer if (!parentManager.round.currPlayer.isHuman) { AI_Timer++; } }
// Update: public override void Update(GameTime gameTime, KeyboardState ks) { base.Update(gameTime, ks); // do this at the beginning of every round, but only once: if (roundStart) { // Set the player ui's to white at the beginning of each round: foreach (Player p in parentManager.gameOptions.players) { p.uiColor = Color.White; } // switch minigames: minigame = (minigame == 0) ? 1 : 0; // Queue pirate bay music again: parentManager.audioEngine.setNextSong(MGP_Constants.music.pirateBay); parentManager.audioEngine.playNextSong(85, true); Console.WriteLine("Added pirateBay to music queue"); // only run once each round: roundStart = false; } // Move camera to player MGP_Tools.Follow_Player(parentManager, currPlayer); // Start next player's turn if (!playerIsPlaying) { // Last player went. Go to minigame if (playerIndex == 4) { // Queue minigame music: parentManager.audioEngine.setNextSong(MGP_Constants.music.minigame); parentManager.audioEngine.playNextSong(50, true); S_MinigameInstructions minigameInstructions = new S_MinigameInstructions(parentManager, 0, 0, minigame); parentManager.AddStateQueue(minigameInstructions); playerIndex = 0; // start with player one when round resumes this.active = false; } // Start next players turn else { currPlayer = gameOptions.players[playerIndex]; // set current player MGP_Tools.Follow_Player(parentManager, currPlayer); // move camera to current player // start confirm player state S_ConfirmPlayer confirmPlayer = new S_ConfirmPlayer(parentManager, 0, 0); parentManager.AddStateQueue(confirmPlayer); this.active = false; //set vars for next round playerIndex++; playerIsPlaying = true; } } // Listen for and allow for pauses: ListenPause(); // Update player places: updatePlayerPlaces(); } // end Update method
// 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); if (currentMenuItem == 1) { currentMenuItem = 0; 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); if (currentMenuItem == 0) { currentMenuItem = 1; moveGlove = true; } } // 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); // One Player if (currentMenuItem == 0) { parentManager.gameOptions.numPlayers = 1; S_CharacterMenu characterMenu = new S_CharacterMenu(parentManager, 0, 0); parentManager.AddStateQueue(characterMenu); this.flagForDeletion = true; } //Two Players if (currentMenuItem == 1) { parentManager.gameOptions.numPlayers = 2; S_CharacterMenu characterMenu = new S_CharacterMenu(parentManager, 0, 0); parentManager.AddStateQueue(characterMenu); this.flagForDeletion = true; } } // Press Cancel Key: Goes back to main menu: if (km.ActionPressed(KeyboardManager.action.cancel, KeyboardManager.playerIndex.all)) { // SFX: parentManager.audioEngine.playSound(MGP_Constants.soundEffects.menuCancel, MGP_Constants.MENU_SFX_VOLUME); S_MainMenu mainMenu = new S_MainMenu(parentManager, 0, 0); parentManager.AddStateQueue(mainMenu); this.flagForDeletion = 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); } } } // End update
// 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); if (rollTime == 60 / ROLL_SPEED && isRolling) // update according to roll speed { rollTime = 0; dice.Update(gameTime, ks); // if comp is rolling if (!currPlayer.isHuman) { compRollBegin++; } } else { rollTime++; } // Allow the transition to run after select is pressed jsut once if (km.ActionPressed(KeyboardManager.action.select, KeyboardManager.playerIndex.one) && currPlayer.isHuman == true) { playerSelected = true; } // If human wait till select is pressed. If computer, wait till comp roll ends if (playerSelected || compRollBegin == compRollEnd) { isRolling = false; // move meeple up if (!bounceUp) { if (Vector2.Distance(currPlayer.meeple.pos, dice.pos) <= 50.0f) { bounceUp = true; // stop moving up // play hit sound effect just once: parentManager.audioEngine.playSound(MGP_Constants.soundEffects.diceHit, 0.8f); } else { currPlayer.meeple.pos.Y = MGP_Tools.Ease(currPlayer.meeple.pos.Y, dice.pos.Y, 0.1f); } } // move meeple back down else if (bounceUp && !bounceDown) { if (Vector2.Distance(currPlayer.meeple.getPosCenter(), currPlayer.currSpace.getPosCenter()) <= 10.0f) { bounceDown = true; // stop moving down } else { currPlayer.meeple.pos.Y = MGP_Tools.Ease(currPlayer.meeple.pos.Y, currPlayer.currSpace.pos.Y, 0.05f); } } // transistions are finished else if (bounceUp && bounceDown) { // wait 1/4 of a sec before the meeple starts moving spaces if (waitTime >= 15) { // Start moving the player based on the roll S_MovePlayer movePlayer = new S_MovePlayer(parentManager, 0, 0, parentManager.boardGame.testDice.diceRoll); parentManager.AddStateQueue(movePlayer); this.flagForDeletion = true; } waitTime++; } } // end if // Listen for and allow a pause ListenPause(); // Rolling Sound Effect: if (isRolling) { rollingSoundCounter--; if (rollingSoundCounter <= 0) { rollingSoundCounter = ROLL_SOUND_LEN; parentManager.audioEngine.playSound(MGP_Constants.soundEffects.diceRolling, 0.4f); } } } // end update
// 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); if (currentMenuItem == 1) { currentMenuItem = 0; } 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); if (currentMenuItem == 0) { currentMenuItem = 1; } 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); // Allow Bonuses if (currentMenuItem == 0) { parentManager.gameOptions.allowBonus = true; } // No Bonuses if (currentMenuItem == 1) { parentManager.gameOptions.allowBonus = false; } // DEBUG: PRINT GAME OPTIONS Console.WriteLine("Map: " + parentManager.gameOptions.mapName + "\nPlayer Count: " + parentManager.gameOptions.numPlayers); int x = 1; foreach (Player player in parentManager.gameOptions.players) { Console.WriteLine("Character " + x + ": " + player.type); x++; } Console.WriteLine("Difficulty: " + parentManager.gameOptions.difficulty + "\nRound Count: " + parentManager.gameOptions.numRounds + "\nAllow Bonuses: " + parentManager.gameOptions.allowBonus + "\n"); // Start game based on game options from here. S_Board board = new B_PirateBay(parentManager, 0, 0); parentManager.AddStateQueue(board); // Add UI to game: board.playerUI = new S_PlayerUI(parentManager, 0, 0); parentManager.AddStateQueue(board.playerUI); this.flagForDeletion = true; } // Press Cancel Key: Goes back one menu: if (km.ActionPressed(KeyboardManager.action.cancel, KeyboardManager.playerIndex.all)) { // SFX: parentManager.audioEngine.playSound(MGP_Constants.soundEffects.menuCancel, MGP_Constants.MENU_SFX_VOLUME); S_NumRoundsMenu numRoundsMenu = new S_NumRoundsMenu(parentManager, 0, 0); parentManager.AddStateQueue(numRoundsMenu); this.flagForDeletion = true; } }
} // end constructor public override void Update(GameTime gameTime, KeyboardState ks) { base.Update(gameTime, ks); // DEBUG: Cancel out: if (km.ActionPressed(KeyboardManager.action.cancel, KeyboardManager.playerIndex.all)) { closeChanceTime(); } // HUMAN CONTROLS: // Hit dices #1, #2, and #3 if (km.ActionPressed(KeyboardManager.action.select, p.playerControlsIndex) && p.isHuman == true) { diceNum++; hit = true; } // end if pressed and human // AI SCRIPTING: if (!p.isHuman) { this.aiTimer++; if (aiTimer >= this.aiHitTime) { diceNum++; // Next die // reset timer and new timer window: this.aiHitTime = parentManager.random.Next(AI_HIT_TIMER_MIN, AI_HIT_TIMER_MAX); aiTimer = 0; hit = true; } } if (hit) { // LEFT die (player) -------------------------------------------- if (diceNum == 1) { suspenseLevel += 0.2f; delayDrum = (int)(delayDrum * 0.75); delayString = (int)(delayString * 0.75); // left block chosen, other blocks faster now: leftBlock.hitBlock(); leftBlock.newBlockColor(Color.Tan); leftPlayer = leftBlock.getCurrentPlayer(); // get the left chosen player leftBlock.newHighlightColor(leftPlayer.characterColor); middleBlock.increaseFaceChangeSpeed(0.6f); rightBlock.increaseFaceChangeSpeed(0.6f); rightBlock.removePlayerFace(leftPlayer); // REMOVE THIS PLAYER FROM RIGHT BLOCK // Create player meeple: leftMeeple = new E_Meeple(parentManager, leftMeepleStartPos, leftPlayer.type); leftMeeple.setPos(leftMeepleStartPos); leftMeeple.drawToScreen = true; // draw coordinates directly on screen leftMeepleMove = true; // Play SFX for finished! parentManager.audioEngine.playSound(MGP_Constants.soundEffects.diceRolling, 0.35f); } // RIGHT die (player) -------------------------------------------- else if (diceNum == 2) { suspenseLevel += 0.2f; delayDrum = (int)(delayDrum * 0.75); delayString = (int)(delayString * 0.75); rightBlock.hitBlock(); rightBlock.newBlockColor(Color.Tan); rightPlayer = rightBlock.getCurrentPlayer(); // get the right chosen player rightBlock.newHighlightColor(rightPlayer.characterColor); middleBlock.increaseFaceChangeSpeed(0.6f); // Create player meeple: rightMeeple = new E_Meeple(parentManager, rightMeepleStartPos, rightPlayer.type); rightMeeple.setPos(rightMeepleStartPos); rightMeeple.drawToScreen = true; // draw coordinates directly on screen rightMeepleMove = true; // Play SFX for finished! parentManager.audioEngine.playSound(MGP_Constants.soundEffects.diceRolling, 0.35f); } // MIDDLE die (condition) ---------------------------------------- else { middleBlock.newBlockColor(Color.Tan); middleBlock.newHighlightColor(Color.Yellow); finishTransition = true; middleBlock.hitBlock(); chanceEvent = middleBlock.getCurrentCondition(); // get the right chosen player // Play SFX for finished! parentManager.audioEngine.playSound(MGP_Constants.soundEffects.chanceTimeCymbal, 1.0f); } hit = false; } // end if hit // EASE the left meeple to his spot for shame: if (leftMeepleMove) { if (Vector2.Distance(leftMeeple.getPos(), leftMeepleEndPos) > 1.0F) { float newX = MGP_Tools.Ease(leftMeeple.getPos().X, leftMeepleEndPos.X, 0.15F); float newY = MGP_Tools.Ease(leftMeeple.getPos().Y, leftMeepleEndPos.Y, 0.15F); leftMeeple.setPos(new Vector2(newX, newY)); } } // EASE the right meeple to his spot for shame: if (rightMeepleMove) { if (Vector2.Distance(rightMeeple.getPos(), RightMeepleEndPos) > 1.0F) { float newX = MGP_Tools.Ease(rightMeeple.getPos().X, RightMeepleEndPos.X, 0.15F); float newY = MGP_Tools.Ease(rightMeeple.getPos().Y, RightMeepleEndPos.Y, 0.15F); rightMeeple.setPos(new Vector2(newX, newY)); } } // THE EVENT WAS CHOSEN, IT MUUUUST BE DONEEEE AHAHAHAHHAA: if (finishTransition && !implementedEvent) { int amount = 0; switch (chanceEvent) { // COINS case condition.leftCoin10: amount = 10; if (rightPlayer.coins < amount) { amount = rightPlayer.coins; } leftPlayer.coins += amount; leftPlayer.totalCoinsGained += amount; rightPlayer.coins = MGP_Tools.NonNegSub(rightPlayer.coins, amount); rightPlayer.totalCoinsLost += amount; break; case condition.leftCoin20: amount = 20; if (rightPlayer.coins < amount) { amount = rightPlayer.coins; } leftPlayer.coins += amount; leftPlayer.totalCoinsGained += amount; rightPlayer.coins = MGP_Tools.NonNegSub(rightPlayer.coins, amount); rightPlayer.totalCoinsLost += amount; break; case condition.leftCoin30: amount = 30; if (rightPlayer.coins < amount) { amount = rightPlayer.coins; } leftPlayer.coins += amount; leftPlayer.totalCoinsGained += amount; rightPlayer.coins = MGP_Tools.NonNegSub(rightPlayer.coins, amount); rightPlayer.totalCoinsLost += amount; break; case condition.rightCoin10: amount = 10; if (leftPlayer.coins < amount) { amount = leftPlayer.coins; } rightPlayer.coins += amount; rightPlayer.totalCoinsGained += amount; leftPlayer.coins = MGP_Tools.NonNegSub(leftPlayer.coins, amount); leftPlayer.totalCoinsLost += amount; break; case condition.rightCoin20: amount = 20; if (leftPlayer.coins < amount) { amount = leftPlayer.coins; } rightPlayer.coins += amount; rightPlayer.totalCoinsGained += amount; leftPlayer.coins = MGP_Tools.NonNegSub(leftPlayer.coins, amount); leftPlayer.totalCoinsLost += amount; break; case condition.rightCoin30: amount = 30; if (leftPlayer.coins < amount) { amount = leftPlayer.coins; } rightPlayer.coins += amount; rightPlayer.totalCoinsGained += amount; leftPlayer.coins = MGP_Tools.NonNegSub(leftPlayer.coins, amount); leftPlayer.totalCoinsLost += amount; break; // STARS case condition.rightStar1: amount = 1; if (leftPlayer.stars < amount) { amount = leftPlayer.stars; } leftPlayer.stars = MGP_Tools.NonNegSub(leftPlayer.stars, amount); rightPlayer.stars += amount; break; case condition.rightStar2: amount = 2; if (leftPlayer.stars < amount) { amount = leftPlayer.stars; } leftPlayer.stars = MGP_Tools.NonNegSub(leftPlayer.stars, amount); rightPlayer.stars += amount; break; case condition.leftStar1: amount = 1; if (rightPlayer.stars < amount) { amount = rightPlayer.stars; } rightPlayer.stars = MGP_Tools.NonNegSub(rightPlayer.stars, amount); leftPlayer.stars += amount; break; case condition.leftStar2: amount = 2; if (rightPlayer.stars < amount) { amount = rightPlayer.stars; } rightPlayer.stars = MGP_Tools.NonNegSub(rightPlayer.stars, amount); leftPlayer.stars += amount; break; // SWAPS: case condition.swapCoins: int leftCoins = leftPlayer.coins; int rightCoins = rightPlayer.coins; leftPlayer.coins = rightCoins; rightPlayer.coins = leftCoins; if (leftCoins < rightCoins) { rightPlayer.totalCoinsLost += (rightCoins - leftCoins); } else if (rightCoins < leftCoins) { leftPlayer.totalCoinsLost += (leftCoins - rightCoins); } break; case condition.swapStars: int leftStars = leftPlayer.stars; int rightStars = rightPlayer.stars; leftPlayer.stars = rightStars; rightPlayer.stars = leftStars; break; // BOTH LOSE: case condition.bothLoseCoin10: leftPlayer.coins = MGP_Tools.NonNegSub(leftPlayer.coins, 10); leftPlayer.totalCoinsLost += 10; rightPlayer.coins = MGP_Tools.NonNegSub(rightPlayer.coins, 10); rightPlayer.totalCoinsLost += 10; break; case condition.bothLoseCoin20: leftPlayer.coins = MGP_Tools.NonNegSub(leftPlayer.coins, 20); leftPlayer.totalCoinsLost += 20; rightPlayer.coins = MGP_Tools.NonNegSub(rightPlayer.coins, 20); rightPlayer.totalCoinsLost += 20; break; case condition.bothLoseCoin30: leftPlayer.coins = MGP_Tools.NonNegSub(leftPlayer.coins, 30); leftPlayer.totalCoinsLost += 30; rightPlayer.coins = MGP_Tools.NonNegSub(rightPlayer.coins, 30); rightPlayer.totalCoinsLost += 30; break; case condition.bothLoseStar: leftPlayer.stars = MGP_Tools.NonNegSub(leftPlayer.stars, 1); rightPlayer.stars = MGP_Tools.NonNegSub(rightPlayer.stars, 1); break; // BOTH WIN: case condition.bothGainCoin20: leftPlayer.coins += 20; leftPlayer.totalCoinsGained += 20; rightPlayer.coins += 20; rightPlayer.totalCoinsGained += 20; break; case condition.bothGainStar: leftPlayer.stars += 1; rightPlayer.stars += 1; break; default: Console.WriteLine("Error, default value in S_ChanceTime for implementedEvent"); break; } // end switch implementedEvent = true; } // finish implementation // Give the player time to celebrate/grieve their gains/losses: if (finishTransition) { finishTimer++; if (finishTimer >= FINISH_TIMER_COMPLETE) { closeChanceTime(); } } // Update Dice Entities: if (!finishTransition) { leftBlock.Update(gameTime, ks); middleBlock.Update(gameTime, ks); rightBlock.Update(gameTime, ks); } // ------------------ Music designed algorithmically with SFX: -------------------------------- if (!finishTransition) { musicCounter++; // Drum: if (musicCounter % delayDrum == 0) { parentManager.audioEngine.playSound(MGP_Constants.soundEffects.chanceTimeDrum, drumVolume + suspenseLevel); } // String: if (musicCounter % delayString == 0) { if (this.highString) { parentManager.audioEngine.playSound(MGP_Constants.soundEffects.chanceTimeHigh, 0.4f + suspenseLevel); this.highString = false; } else { parentManager.audioEngine.playSound(MGP_Constants.soundEffects.chanceTimeLow, 0.4f + suspenseLevel); this.highString = true; } } // change accent if needed: if (musicCounter % DRUM_ACCENT == 0) { drumVolume = DRUM_ACCENT_VOLUME; } else { drumVolume = DRUM_NORMAL_VOLUME; } } // ------------------------------------ END PROGRAMATIC MUSIC ------------------------------ } // end update
public override void Update(GameTime gameTime, KeyboardState ks) { base.Update(gameTime, ks); if (timer >= maxTime && !animation) { // Move onto final results if (textIndex == text.Count - 1) { S_FinalResults finalResults = new S_FinalResults(parentManager, xPos, yPos); parentManager.AddStateQueue(finalResults); this.flagForDeletion = true; } // Show next text else { textIndex++; timer = 0; } } // Start animation else if (textIndex == 2 || textIndex == 4) { if (textIndex == 2) { winnerIndex = minigameWinnerIndex; } else { winnerIndex = mostCoinsWinnerIndex; } animation = true; // move the player towards center if (!movedPlayer) { if (Vector2.Distance(currMeeplePos[winnerIndex], awardPos) < 5.0f) { movedPlayer = true; timer = 0; } else { Vector2 temp = currMeeplePos[winnerIndex]; temp.X = MGP_Tools.Ease(currMeeplePos[winnerIndex].X, awardPos.X, 0.05f); temp.Y = MGP_Tools.Ease(currMeeplePos[winnerIndex].Y, awardPos.Y, 0.05f); currMeeplePos[winnerIndex] = new Vector2(temp.X, temp.Y); } } // move the star else if (!movedStar) { if (Math.Abs(curStarPos.Y - starAwardPos.Y) < 10 && timer > maxTime) { movedStar = true; } else { curStarPos.Y = (int)MGP_Tools.Ease(curStarPos.Y, starAwardPos.Y, 0.1f); } } // move player back else { // move star back up curStarPos = origStarPos; // Finished all animations if (Vector2.Distance(currMeeplePos[winnerIndex], origMeeplePos[winnerIndex]) < 5.0f) { animation = false; movedStar = false; movedPlayer = false; } // ease player back to orig spot else { Vector2 temp = currMeeplePos[winnerIndex]; temp.X = MGP_Tools.Ease(currMeeplePos[winnerIndex].X, origMeeplePos[winnerIndex].X, 0.1f); temp.Y = MGP_Tools.Ease(currMeeplePos[winnerIndex].Y, origMeeplePos[winnerIndex].Y, 0.1f); currMeeplePos[winnerIndex] = new Vector2(temp.X, temp.Y); } } // End of moving player back } // End of animation // Spin the star! if (timer % 30 < 6) { starIndex = 0; } else if (timer % 30 >= 6 && timer % 30 < 12) { starIndex = 1; } else if (timer % 30 >= 12 && timer % 30 < 18) { starIndex = 2; } else if (timer % 30 >= 18 && timer % 30 < 24) { starIndex = 3; } else { starIndex = 4; } timer++; }
// 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); // Seven Rounds Selected if (currentMenuItem == 0) { parentManager.gameOptions.numRounds = 7; } //parentManager.gameOptions.numRounds = 1; // DEBUG DEBUG DEBUG DEBUG DEBUG // Twelve Rounds Selected else if (currentMenuItem == 1) { parentManager.gameOptions.numRounds = 12; } // Twenty Rounds Selected else { parentManager.gameOptions.numRounds = 20; } // Go to next menu S_BonusMenu bonusMenu = new S_BonusMenu(parentManager, 0, 0); parentManager.AddStateQueue(bonusMenu); this.flagForDeletion = true; } // Press Cancel Key: Goes back to difficulty menu: if (km.ActionPressed(KeyboardManager.action.cancel, KeyboardManager.playerIndex.all)) { // SFX: parentManager.audioEngine.playSound(MGP_Constants.soundEffects.menuCancel, MGP_Constants.MENU_SFX_VOLUME); S_DifficultyMenu difficultyMenu = new S_DifficultyMenu(parentManager, 0, 0); parentManager.AddStateQueue(difficultyMenu); this.flagForDeletion = true; } }
// Collection of Spaces: //public List<E_Space> spaces; // Constructor: public B_PirateBay(GameStateManager creator, float xPos, float yPos) : base(creator, xPos, yPos) { // --------------------------- Create Spaces: ---------------------------------- // initialize list of spaces: spaces = new List <E_Space>(); E_Space curSpace; E_Space prevSpace; // STARTING WITH BOTTOM RIGHT // <<---- MOVING LEFT NOW: ----->> // Bottom right space: curSpace = new E_Space(this, GetTilePosCenter(21, 16), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.left); spaces.Add(curSpace); this.startingSpace = curSpace; // STARTING SPACE prevSpace = curSpace; // 20, 16 // Blue curSpace = new E_Space(this, GetTilePosCenter(20, 16), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.left); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 19, 16 // Blue curSpace = new E_Space(this, GetTilePosCenter(19, 16), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.left); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 17, 16 // Red curSpace = new E_Space(this, GetTilePosCenter(17, 16), Entity.typeSpace.red); curSpace.setOverlapPositions(E_Space.direction.left); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 16, 15 // Blue curSpace = new E_Space(this, GetTilePosCenter(16, 15), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.left); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 15, 15 // Blue curSpace = new E_Space(this, GetTilePosCenter(15, 15), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.left); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 14, 15 // Red curSpace = new E_Space(this, GetTilePosCenter(14, 15), Entity.typeSpace.red); curSpace.setOverlapPositions(E_Space.direction.left); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 12, 15 // Blue curSpace = new E_Space(this, GetTilePosCenter(12, 15), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.left); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 12, 16 // Blue curSpace = new E_Space(this, GetTilePosCenter(12, 16), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.left); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 10, 16 curSpace = new E_Space(this, GetTilePosCenter(10, 16), Entity.typeSpace.red); curSpace.setOverlapPositions(E_Space.direction.left); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 7, 16 curSpace = new E_Space(this, GetTilePosCenter(7, 16), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.left); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 6, 16 CHANCE TIME curSpace = new E_Space(this, GetTilePosCenter(6, 16), Entity.typeSpace.chance); curSpace.setOverlapPositions(E_Space.direction.left); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // <<---- MOVING UP NOW: ----->> // 6, 15 curSpace = new E_Space(this, GetTilePosCenter(6, 15), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.up); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 6, 13 curSpace = new E_Space(this, GetTilePosCenter(6, 13), Entity.typeSpace.red); curSpace.setOverlapPositions(E_Space.direction.up); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 6, 10 curSpace = new E_Space(this, GetTilePosCenter(6, 10), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.up); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 6, 9 curSpace = new E_Space(this, GetTilePosCenter(6, 9), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.up); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 4, 9 curSpace = new E_Space(this, GetTilePosCenter(4, 9), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.up); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 3, 9 curSpace = new E_Space(this, GetTilePosCenter(3, 9), Entity.typeSpace.chance); curSpace.setOverlapPositions(E_Space.direction.up); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 3, 8 curSpace = new E_Space(this, GetTilePosCenter(3, 8), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.up); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 3, 7 curSpace = new E_Space(this, GetTilePosCenter(3, 7), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.up); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 3, 3 curSpace = new E_Space(this, GetTilePosCenter(3, 3), Entity.typeSpace.red); curSpace.setOverlapPositions(E_Space.direction.up); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 3, 2 curSpace = new E_Space(this, GetTilePosCenter(3, 2), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.up); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // <<---- MOVING RIGHT NOW: ----->> // 4, 1 curSpace = new E_Space(this, GetTilePosCenter(4, 1), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.right); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 5, 1 curSpace = new E_Space(this, GetTilePosCenter(5, 1), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.right); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 7, 1 curSpace = new E_Space(this, GetTilePosCenter(7, 1), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.right); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 8, 2 curSpace = new E_Space(this, GetTilePosCenter(8, 2), Entity.typeSpace.red); curSpace.setOverlapPositions(E_Space.direction.right); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 9, 2 curSpace = new E_Space(this, GetTilePosCenter(9, 2), Entity.typeSpace.red); curSpace.setOverlapPositions(E_Space.direction.right); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 10, 3 curSpace = new E_Space(this, GetTilePosCenter(10, 3), Entity.typeSpace.red); curSpace.setOverlapPositions(E_Space.direction.right); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 12, 3 curSpace = new E_Space(this, GetTilePosCenter(12, 3), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.right); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 13, 3 curSpace = new E_Space(this, GetTilePosCenter(13, 3), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.right); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 14, 3 curSpace = new E_Space(this, GetTilePosCenter(14, 3), Entity.typeSpace.chance); curSpace.setOverlapPositions(E_Space.direction.right); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 16, 3 curSpace = new E_Space(this, GetTilePosCenter(16, 3), Entity.typeSpace.red); curSpace.setOverlapPositions(E_Space.direction.right); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 17, 4 curSpace = new E_Space(this, GetTilePosCenter(17, 4), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.right); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 18, 4 curSpace = new E_Space(this, GetTilePosCenter(18, 4), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.right); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // <<---- MOVING DOWN NOW: ----->> // 19, 5 curSpace = new E_Space(this, GetTilePosCenter(19, 5), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.down); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 19, 7 curSpace = new E_Space(this, GetTilePosCenter(19, 7), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.down); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 19, 8 curSpace = new E_Space(this, GetTilePosCenter(19, 8), Entity.typeSpace.red); curSpace.setOverlapPositions(E_Space.direction.down); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 19, 10 curSpace = new E_Space(this, GetTilePosCenter(19, 10), Entity.typeSpace.chance); curSpace.setOverlapPositions(E_Space.direction.down); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 19, 11 curSpace = new E_Space(this, GetTilePosCenter(19, 11), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.down); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 19, 13 curSpace = new E_Space(this, GetTilePosCenter(19, 13), Entity.typeSpace.red); curSpace.setOverlapPositions(E_Space.direction.down); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 21, 13 curSpace = new E_Space(this, GetTilePosCenter(21, 13), Entity.typeSpace.blue); curSpace.setOverlapPositions(E_Space.direction.down); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 22, 13 curSpace = new E_Space(this, GetTilePosCenter(22, 13), Entity.typeSpace.red); curSpace.setOverlapPositions(E_Space.direction.down); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); prevSpace = curSpace; // 22, 15 FINAL PIECE curSpace = new E_Space(this, GetTilePosCenter(22, 15), Entity.typeSpace.chance); curSpace.setOverlapPositions(E_Space.direction.down); spaces.Add(curSpace); // add to overall list curSpace.assignSpaces(prevSpace); this.finalSpace = curSpace; // FINAL SPACE // Finally, link up last space and first space: this.startingSpace.assignSpaces(this.finalSpace); // Assign the star space to a random space MGP_Tools.Assign_Star(this); // Assign starting space to all players foreach (Player p in this.gameOptions.players) { p.currSpace = this.startingSpace; p.meeple.setPos(p.currSpace.getMeepleLocation()); // Occupy that space so another meeple doesn't run him/her over: p.currSpace.occupySpace(p); } } // end constructor
// 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); // 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