Ejemplo n.º 1
0
        // update method based on different gamestates
        public override void Update(GameTime gameTime)
        {
            if (base.isPaused)
            {
                return;
            }
            if (isHalted)
            {
                return;
            }
            if (speedState == gameState.GamePlay)
            {
                delayTimer.Update(gameTime);
            }
            if (myType == gameType.Timed)
            {
                //time1.changeContent(gameTimer.getCountDown(0));
                time2.changeContent(gameTimer.getCountDown(0));
                //if (speedState == gameState.GamePlay) delayTimer.Update(gameTime);
                if (speedState == gameState.ReBeginning && gameTimer.getTimeLeft(0) <= 20)
                {
                    gameTimer.isPaused = true;
                }
                else
                {
                    gameTimer.isPaused = false;
                }
            }

            switch (speedState)
            {
            case gameState.Dealing:
                if ((shuffleinstance.State == SoundState.Stopped) && soundOn)
                {
                    shuffleinstance.Play();
                }
                break;

            case gameState.AskBegin:
            case gameState.Beginning:
                DoNothing();
                break;

            case gameState.GamePlay:
                yourScore.changeContent(you.score.ToString());
                oppScore.changeContent(opp.score.ToString());
                if (ExistWinner())
                {
                    Winner(DetermineWinner());
                }
                else if (!ExistMoves())
                {
                    ReBegin();
                }
                you.Update(yourCards, rGameStack, lGameStack, gameTime);
                opp.Update(opponentCards, rGameStack, lGameStack, gameTime);
                yourSelector.attributes.position = yourCards[you.selector].position;
                oppSelector.attributes.position  = opponentCards[opp.selector].position;
                break;

            case gameState.ReBeginning:
            case gameState.PlayingCard:
                you.Update(yourCards, rGameStack, lGameStack, gameTime);
                opp.Update(opponentCards, rGameStack, lGameStack, gameTime);
                yourSelector.attributes.position = yourCards[you.selector].position;
                oppSelector.attributes.position  = opponentCards[opp.selector].position;
                break;

            case gameState.Winner:
                break;

            case gameState.PlayAgain:
                break;
            }
            //bool moveExists = ComputerPlayer.FindPileNumber(opponentCards, lGameStack, rGameStack);
            KeyUpdate(gameTime);
            base.Update(gameTime);
        }
Ejemplo n.º 2
0
 //
 public void PauseFreeze()
 {
     freezeTimer.isPaused = true;
     timeLeft             = freezeTimer.getTimeLeft(1);
 }