public Player(GameStateManager gameStateManager, Player.Type type, bool isHuman, KeyboardManager.playerIndex pi) { this.isHuman = isHuman; this.coins = 0; this.stars = 0; this.totalMiniGameWins = 0; this.totalMiniGameLosses = 0; this.totalRedSpaceLands = 0; this.totalBlueSpaceLands = 0; this.totalChanceSpaceLands = 0; this.totalSpecialSpaceLands = 0; this.totalCoinsGained = 0; this.totalCoinsLost = 0; this.playerControlsIndex = pi; this.uiColor = Color.White; switch (type) { case Player.Type.FRANK: this.meeple = new E_Meeple(gameStateManager, new Vector2(0, 0), type); this.closeupPicture = gameStateManager.game.spr_FrankCloseup; this.chancePicture = gameStateManager.game.spr_chanceFrank; this.characterColor = Color.SaddleBrown; this.type = type; break; case Player.Type.LOUIE: this.meeple = new E_Meeple(gameStateManager, new Vector2(0, 0), type); this.closeupPicture = gameStateManager.game.spr_LouieCloseup; this.chancePicture = gameStateManager.game.spr_chanceLouie; this.characterColor = Color.Lime; this.type = type; break; case Player.Type.MANFORD: this.meeple = new E_Meeple(gameStateManager, new Vector2(0, 0), type); this.closeupPicture = gameStateManager.game.spr_ManfordCloseup; this.chancePicture = gameStateManager.game.spr_chanceManford; this.characterColor = Color.Red; this.type = type; break; case Player.Type.SUE: this.meeple = new E_Meeple(gameStateManager, new Vector2(0, 0), type); this.closeupPicture = gameStateManager.game.spr_SueCloseup; this.chancePicture = gameStateManager.game.spr_chanceSue; this.characterColor = Color.Magenta; this.type = type; break; case Player.Type.VELMA: this.meeple = new E_Meeple(gameStateManager, new Vector2(0, 0), type); this.closeupPicture = gameStateManager.game.spr_VelmaCloseup; this.chancePicture = gameStateManager.game.spr_chanceVelma; this.characterColor = Color.Yellow; this.type = type; break; case Player.Type.WILBER: this.meeple = new E_Meeple(gameStateManager, new Vector2(0, 0), type); this.closeupPicture = gameStateManager.game.spr_WilberCloseup; this.chancePicture = gameStateManager.game.spr_chanceWilber; this.characterColor = Color.DarkOrchid; this.type = type; break; } // end switch } // end constructor
// ** CONSTRUCTOR ** public S_Pause(GameStateManager creator, float xPos, float yPos, KeyboardManager.playerIndex playerWhoPaused) : base(creator, xPos, yPos) { this.playerWhoPaused = playerWhoPaused; // Center title: pauseTitlePos = CenterString.getCenterStringVector(pauseTitlePos, "Paused", this.parentManager.game.ft_confirmPlayer_Bold); // pause items: pauseItems = new List <PauseItem>(); piPos = new Vector2(MGP_Constants.SCREEN_MID_X, MGP_Constants.SCREEN_MID_Y - piHeight * 2); // init position SpriteFont sf = parentManager.game.ft_confirmPlayer_s32; int numItems = 0; Vector2 startPos = new Vector2(piPos.X, piPos.Y + (numItems * piHeight)); PauseItem curItem = new PauseItem(startPos, "Resume", sf, S_Pause.pauseOptions.resume); pauseItems.Add(curItem); currentSelection = numItems; // first selection here numItems++; this.glove = new E_Glove(creator, new Vector2(curItem.screenPosCentered.X - gloveAdjustX, curItem.screenPosCentered.Y - gloveAdjustY)); curItem = new PauseItem(new Vector2(piPos.X, piPos.Y + (numItems * piHeight)), "View Board", sf, S_Pause.pauseOptions.viewBoard); pauseItems.Add(curItem); numItems++; curItem = new PauseItem(new Vector2(piPos.X, piPos.Y + (numItems * piHeight)), "Quit Match", sf, S_Pause.pauseOptions.quit); pauseItems.Add(curItem); numItems++; curItem = new PauseItem(new Vector2(piPos.X, piPos.Y + (numItems * piHeight)), "Exit Program", sf, S_Pause.pauseOptions.exitProgram); pauseItems.Add(curItem); numItems++; // Store all other States into a list of states that we will 'pause' statesToPause = new List <State>(); foreach (State s in creator.states) { // only change states that are already active (don't tamper with other states) if (s.active == true && s != parentManager.audioEngine) { statesToPause.Add(s); } } // Pause those selected states: foreach (State s in statesToPause) { // don't pause itself, but pause all other active states: if (s != this) { s.active = false; } } // Create the transparent black background: overlayTexture = new Texture2D(parentManager.game.GraphicsDevice, 1, 1, false, SurfaceFormat.Color); Color[] c = new Color[1]; int transparencyAmount = (int)(255f * 0.9f); c[0] = Color.FromNonPremultiplied(255, 255, 255, transparencyAmount); overlayTexture.SetData <Color>(c); overlay = new Rectangle(0, 0, MGP_Constants.SCREEN_WIDTH, MGP_Constants.SCREEN_HEIGHT); // Turn down the music a little: parentManager.audioEngine.setMusicVolume(MGP_Constants.PAUSE_MUSIC_VOLUME); }
// 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