#region File Description //----------------------------------------------------------------------------- // TexturedDrawableGameComponent.cs // // Microsoft XNA Community Game Platform // Copyright (C) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- #endregion #region Using Statements using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; #endregion namespace HoneycombRush { /// /// This abstract class represent a component which has a texture that represents it visually. /// public abstract class TexturedDrawableGameComponent : DrawableGameComponent { #region Fields/Properties protected ScaledSpriteBatch scaledSpriteBatch; protected Texture2D texture; protected Vector2 position; protected GameplayScreen gamePlayScreen; /// /// Represents the bounds of the component. /// public virtual Rectangle Bounds { get { if (texture == null) { return default(Rectangle); } else { return new Rectangle((int)position.X, (int)position.Y, (int)(texture.Width * scaledSpriteBatch.ScaleVector.X), (int)(texture.Height * scaledSpriteBatch.ScaleVector.Y)); } } } /// /// Represents an area used for collision calculations. /// public virtual Rectangle CentralCollisionArea { get { return default(Rectangle); } } public Dictionary AnimationDefinitions { get; set; } #endregion /// /// Creates a new instance. /// /// Associated game object. /// Gameplay screen where the component will be presented. public TexturedDrawableGameComponent(Game game, GameplayScreen gamePlayScreen) : base(game) { this.gamePlayScreen = gamePlayScreen; scaledSpriteBatch = (ScaledSpriteBatch)game.Services.GetService(typeof(ScaledSpriteBatch)); } } }