Exemple #1
0
        // 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;
            }
        }
Exemple #2
0
        // 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