#region File Description
//-----------------------------------------------------------------------------
// AnimatedCardsGameComponent.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion
#region Using Statements
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using CardsFramework;
using Microsoft.Xna.Framework.Graphics;
using System.Diagnostics;
#endregion
namespace CardsFramework
{
///
/// An implemented for a card game
///
public class AnimatedCardsGameComponent : AnimatedGameComponent
{
public TraditionalCard Card { get; private set; }
///
/// Initializes a new instance of the class.
///
/// The card associated with the animation component.
/// The associated game.
public AnimatedCardsGameComponent(TraditionalCard card, CardsGame cardGame)
: base(cardGame, null)
{
Card = card;
}
#region Update and Render
///
/// Updates the component.
///
/// The game time.
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
CurrentFrame = IsFaceDown ? CardGame.cardsAssets["CardBack_" + CardGame.Theme] :
CardGame.cardsAssets[UIUtilty.GetCardAssetName(Card)];
}
///
/// Draws the component.
///
/// The game time.
public override void Draw(GameTime gameTime)
{
base.Draw(gameTime);
CardGame.SpriteBatch.Begin();
// Draw the current at the designated destination, or at the initial
// position if a destination has not been set
if (CurrentFrame != null)
{
if (CurrentDestination.HasValue)
{
CardGame.SpriteBatch.Draw(CurrentFrame,
CurrentDestination.Value, Color.White);
}
else
{
CardGame.SpriteBatch.Draw(CurrentFrame,
CurrentPosition, Color.White);
}
}
CardGame.SpriteBatch.End();
}
#endregion
}
}