/// <summary> /// Draws the sprite. Override to add functionality. Call last. /// </summary> /// <param name="spriteBatch">The sprite batch to draw with.</param> public virtual void Draw() { if (IsVisible) { BlockSprite.Draw(game.GameSpriteBatch); } }
protected BlockModel(BlockSpriteFactory blockSpriteFactory) { BlockSpriteFactory = blockSpriteFactory; Sprite = new BlockSprite(this); Color = Color.White; Time = new System.Diagnostics.Stopwatch(); }
static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("Usage: BuildBlockSprite <SpritePath> <DestinationPath>"); return; } var spritePath = args[0]; var destinationPath = args[1]; BlockSprite blockSprite; using (var stream = new FileStream(spritePath, FileMode.Open)) { var bitmap = new Bitmap(stream); var w = bitmap.Width; var h = bitmap.Height; if (w != 16 || h != 16) { throw new InvalidOperationException("The size of a sprite is invalid."); } blockSprite = new BlockSprite(w, h); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { var c = bitmap.GetPixel(x, y); blockSprite.SetPixel(x, y, new XnaColor(c.R, c.G, c.B, c.A)); } } } var processor = new BlockSpriteProcessor(); var block = processor.Process(blockSprite); var destinationDir = Path.GetDirectoryName(destinationPath); if (!Directory.Exists(destinationDir)) { Directory.CreateDirectory(destinationDir); } var serializer = new ContentSerializer <Block>(); using (var stream = new FileStream(destinationPath, FileMode.Create)) { serializer.Serialize(stream, block); } }
public HiddenBlock(ContentManager content, GraphicsDevice graphicsDevice) { GraphicsDevice = graphicsDevice; Content = content; ContainedItems = new Collection <IEntity>(); BlockState = new HiddenBlockState(graphicsDevice); Sprite = new BlockSprite(graphicsDevice); Bump = true; Bumping = false; Sprite = HiddenBlockSpriteFactory.Instance.FactoryMethod(this.Content, this, GraphicsDevice, false); sound = content.Load <SoundEffect>("Sound Effects/Item Appears"); isConsumed = false; //Sprite.Toggle(); // Turns initial display value to false }
public override void Draw(SpriteBatch spriteBatch, Vector2 spriteLocation, Color color) { BlockSprite.Draw(spriteBatch, spriteLocation, color); }
public UsedBlock(ContentManager content, GraphicsDevice graphicsDevice) { Content = content; Sprite = new BlockSprite(graphicsDevice); Sprite = UsedBlockSpriteFactory.Instance.FactoryMethod(this.Content, this, graphicsDevice, false); }
public virtual void Update() { BlockSprite.Update(); }
public virtual void Draw(SpriteBatch spriteBatch, Vector2 location) { BlockSprite.Draw(spriteBatch, location); }
protected Block() { blockState = new NotActivatedBlockState(this); UpdateSprite(); Hitbox = BlockSprite.GetHitboxFromSprite(location); }
public FloorBlock(ContentManager Content, GraphicsDevice graphicsDevice, bool underworld) { Underworld = underworld; Sprite = new BlockSprite(graphicsDevice); Sprite = FloorBlockSpriteFactory.Instance.FactoryMethod(Content, this, graphicsDevice, Underworld); }
/// <summary> /// Draws the sprite. /// </summary> public virtual void Draw() { BlockSprite.Draw(game.GameSpriteBatch); }