//----------------------------------------------------------------------------- // TexturedDrawableGameComponent.cs // // Microsoft XNA Community Game Platform // Copyright (C) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace HoneycombRush { /// /// This abstract class represent a component which has a texture that represents it visually. /// public abstract class TexturedDrawableGameComponent : DrawableGameComponent { 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; } /// /// 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)); } } }