Example #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            if (readyToPlay)
            {
                GraphicsDevice.Clear(Color.CornflowerBlue);
                spriteBatch.Begin();

                spriteBatch.Draw(BGT, BackgroundR, Color.White);

                // Draw Tableus
                for (int i = 0; i < gameTableus.Count; i++)
                {
                    spriteBatch.Draw(gameTableus.ElementAt(i).getTableuTexture(), gameTableus.ElementAt(i).getTableuVector(), Color.White);

                    for (int j = 0; j < gameTableus.ElementAt(i).getTableuSize(); j++)
                    {
                        Card tempDraw = gameTableus.ElementAt(i).getTableuCard(j);
                        spriteBatch.Draw(tempDraw.getSprite(), tempDraw.getVector(), Color.White);
                    }
                }

                // Draw Foundations
                for (int i = 0; i < gameFoundations.Count; i++)
                {
                    spriteBatch.Draw(gameFoundations.ElementAt(i).getFoundationTexture(), gameFoundations.ElementAt(i).getFoundationVector(), Color.White);

                    for (int j = 0; j < gameFoundations.ElementAt(i).getFoundationSize(); j++)
                    {
                        Card tempDraw = gameFoundations.ElementAt(i).getFoundationCard(j);
                        spriteBatch.Draw(tempDraw.getSprite(), tempDraw.getVector(), Color.White);
                    }
                }

                // Draw the card currently in hand
                if (dragging && temp != null)
                {
                    spriteBatch.Draw(temp.getSprite(), temp.getVector(), Color.White);
                }


                //Code to display score; each card placed on tableu counts as 10 points

                gameFont = Content.Load <SpriteFont>("Courier New");
                spriteBatch.DrawString(gameFont, "Score: \n" + playerScore.ToString(), new Vector2(scoreDisplayX, scoreDisplayY), Color.White);

                if (win)
                {
                    spriteBatch.DrawString(gameFont, "YOU WIN!!! Press 'R' to restart!", new Vector2(winDisplayX, winDisplayY), Color.White);
                }

                if (help)
                {
                    spriteBatch.Draw(helpTexture, new Vector2(50, 50), Color.White);
                }

                spriteBatch.End();

                base.Draw(gameTime);
            }
        }