Exemplo n.º 1
0
        public override void PostUpdate(GameTime gameTime)
        {
            int hearts   = deckManager.CardsInPlay["Hearts"].Length - 1;
            int spades   = deckManager.CardsInPlay["Spades"].Length - 1;
            int diamonds = deckManager.CardsInPlay["Diamonds"].Length - 1;
            int clubs    = deckManager.CardsInPlay["Clubs"].Length - 1;

            if (MouseInput.CheckForDoubleClick(pmState, gameTime, clickTimer))
            {
                clickTimer = 0;
            }
            else if (MouseInput.CheckForSingleClick(pmState))
            {
                clickTimer = gameTime.TotalGameTime.TotalMilliseconds;
            }
            if (smiPlayed &&
                playAgainDist > Layout.ButtonRadius &&
                exitDist > Layout.ButtonRadius)
            {
                smiPlayed = false;
            }
            score  = hearts + spades + diamonds + clubs;
            score *= 10;
            if (hearts > 12)
            {
                score += 120;
            }
            if (spades > 12)
            {
                score += 120;
            }
            if (diamonds > 12)
            {
                score += 120;
            }
            if (clubs > 12)
            {
                score += 120;
            }

            pmState = mState;
        }
Exemplo n.º 2
0
        public override void Update(GameTime gameTime)
        {
            var scaleX = (float)graphicsDevice.PresentationParameters.BackBufferWidth / 1920;
            var scaleY = (float)graphicsDevice.PresentationParameters.BackBufferHeight / 1080;
            var matrix = Matrix.CreateScale(scaleX, scaleY, 1.0f);

            mState = Mouse.GetState();
            var mousePosition = new Vector2(mState.X, mState.Y);
            var smPosition    = Vector2.Transform(mousePosition, Matrix.Invert(matrix));

            playDist = Vector2.Distance(Layout.MenuPlayButton, new Vector2(smPosition.X, smPosition.Y));
            exitDist = Vector2.Distance(Layout.MenuExitButton, new Vector2(smPosition.X, smPosition.Y));

            if (playDist < Layout.ButtonRadius ||
                exitDist < Layout.ButtonRadius)
            {
                if (!smiPlayed)
                {
                    SoundEffectInstance smi = selectMenuItem.CreateInstance();
                    smi.Volume = 0.2f;
                    smi.Pitch  = 0.5f;
                    smi.Play();
                    smiPlayed = true;
                }
            }

            if (MouseInput.CheckForSingleClick(pmState))
            {
                if (playDist < Layout.ButtonRadius)
                {
                    game.ChangeToGameState();
                }
                if (exitDist < Layout.ButtonRadius)
                {
                    game.Exit();
                }
            }
        }
Exemplo n.º 3
0
        public override void Update(GameTime gameTime)
        {
            var scaleX = (float)graphicsDevice.PresentationParameters.BackBufferWidth / 1920;
            var scaleY = (float)graphicsDevice.PresentationParameters.BackBufferHeight / 1080;
            var matrix = Matrix.CreateScale(scaleX, scaleY, 1.0f);

            var pMousePosition = new Vector2(pmState.X, pmState.Y);
            var psmPosition    = Vector2.Transform(pMousePosition, Matrix.Invert(matrix));

            mState = Mouse.GetState();
            var mousePosition = new Vector2(mState.X, mState.Y);
            var smPosition    = Vector2.Transform(mousePosition, Matrix.Invert(matrix));

            CollisionManager cm = new CollisionManager(mState, pmState, smPosition);

            playAgainDist = Vector2.Distance(Layout.PlayAgain, new Vector2(smPosition.X, smPosition.Y));
            exitDist      = Vector2.Distance(Layout.Exit, new Vector2(smPosition.X, smPosition.Y));

            if (!mcm.MovingCard.IsMoving && !msm.StackIsMoving)
            {
                if (playAgainDist < Layout.ButtonRadius ||
                    exitDist < Layout.ButtonRadius)
                {
                    if (!smiPlayed)
                    {
                        PlaySoundEffect(selectMenuItem, 0.2f, 0.3f);
                        smiPlayed = true;
                    }
                }

                if (MouseInput.CheckForSingleClick(pmState))
                {
                    if (playAgainDist < Layout.ButtonRadius)
                    {
                        game.ChangeToGameState();
                    }
                    if (exitDist < Layout.ButtonRadius)
                    {
                        game.Exit();
                    }
                }

                if (!canWin)
                {
                    deckManager.SendDoubleClicksToFoundation(mState, pmState, gameTime, clickTimer, smPosition);

                    deckManager.ClickToFlipTableauCard(mState, pmState, smPosition);

                    if (cm.DeckPileClick(deckManager))
                    {
                        if (deckManager.CardsInPlay["Deck"].Length <= 0)
                        {
                            deckManager.ReturnWasteToDeck();
                            PlaySoundEffect(returnToDeck, 0.2f, -0.5f);
                        }
                        else
                        {
                            if (deckManager.CardWasAlreadyDrawn)
                            {
                                deckManager.AddCardToPile(deckManager.CardsInPlay["Deck"][deckManager.CardsInPlay["Deck"].Length - 1], "Waste");
                                deckManager.CardsInPlay["Deck"] = deckManager.DownsizePile(deckManager.CardsInPlay["Deck"]);
                            }

                            if (deckManager.CardsInPlay["Deck"].Length > 0)
                            {
                                deckManager.DrawACard();
                            }
                            else
                            {
                                deckManager.CardWasAlreadyDrawn = false;
                            }

                            PlaySoundEffect(draw, 0.3f, 0.8f);
                        }
                    }
                }
                else
                {
                    deckManager.WinGame();
                    if (deckManager.CardsInPlay["Hearts"].Length > 13 &&
                        deckManager.CardsInPlay["Spades"].Length > 13 &&
                        deckManager.CardsInPlay["Diamonds"].Length > 13 &&
                        deckManager.CardsInPlay["Clubs"].Length > 13)
                    {
                        canWin = false;
                    }
                }
            }

            if (mcm.CheckIfMovementStopped(mState) || msm.CheckIfMovementStopped(mState))
            {
                if (mcm.MovingCard.IsMoving)
                {
                    mcm.MovingCard.IsMoving = false;
                    if (cm.CheckCollisions(mcm.MovingCard, deckManager))
                    {
                        mcm.MovingCard = new Card();
                    }
                    else
                    {
                        mcm.ReturnCardToPile(deckManager);
                    }
                }
                else
                {
                    msm.StackIsMoving = false;
                    if (cm.CheckStackCollisions(msm.MovingStack, deckManager))
                    {
                        msm.MovingStack = new Card[0];
                    }
                    else
                    {
                        msm.ReturnStackToPile(deckManager);
                    }
                }

                PlaySoundEffect(placeCard, 0.1f, 0.6f);
            }

            if (!mcm.MovingCard.IsMoving && msm.CheckForMovement(deckManager, mState, pmState, smPosition))
            {
                msm.MoveStack(mState, pmState, smPosition, psmPosition);
            }

            if (!msm.StackIsMoving && mcm.CheckForMovement(deckManager, mState, pmState, smPosition))
            {
                mcm.MoveCard(mState, pmState, smPosition, psmPosition);
            }

            CheckCardsForAnimations(gameTime);

            if (!canWin)
            {
                canWin = deckManager.CheckForWin(mcm, msm);
            }
        }
Exemplo n.º 4
0
 //Checks for Mouse Click on Deck Pile
 public bool DeckPileClick(DeckManager deckManager)
 {
     return(MouseInput.CheckForSingleClick(pmState) && Layout.MakeCardBox(
                new Vector2(Layout.Deck.X + deckManager.CardsInPlay["Deck"].Length * 3 - 6, Layout.Deck.Y))
            .Contains(smPosition));
 }