Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
        // 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();
        }
Ejemplo n.º 3
0
        // 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);
            }
        }
Ejemplo n.º 4
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);

                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
Ejemplo n.º 5
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);

                // 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;
            }
        }
Ejemplo n.º 6
0
        // 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
Ejemplo n.º 7
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);

                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;
            }
        }
Ejemplo n.º 8
0
        } // 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
Ejemplo n.º 9
0
        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++;
        }
Ejemplo n.º 10
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;
            }
        }
Ejemplo n.º 11
0
        // 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
Ejemplo n.º 12
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