Example #1
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
Example #2
0
        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