public SetSpriteCommand(SpriteLayer spriteLayer, Sprite sprite) { spriteLayer.ThrowIfNull("spriteLayer"); sprite.ThrowIfNull("sprite"); _spriteLayer = spriteLayer; _sprite = sprite; }
public XElement Serialize(Sprite sprite, string elementName = "sprite") { sprite.ThrowIfNull("sprite"); elementName.ThrowIfNull("elementName"); return new XElement( elementName, CharacterSerializer.Instance.Serialize(sprite.Character), new XAttribute("coordinate", CoordinateSerializer.Instance.Serialize(sprite.Coordinate))); }
public byte[] Serialize(Sprite sprite) { sprite.ThrowIfNull("sprite"); var serializer = new CompactSerializer(); serializer[0] = CoordinateSerializer.Instance.Serialize(sprite.Coordinate); serializer[1] = CharacterSerializer.Instance.Serialize(sprite.Character); return serializer.Serialize(); }
public void Draw() { Board board = _boardRendererState.Board; if (board == null || _pencilRendererState.TopLeftSelectionCoordinate == null) { return; } Coordinate topLeftSelectionCoordinate = _pencilRendererState.TopLeftSelectionCoordinate.Value; switch (_boardRendererState.ActiveLayer) { case Layer.Background: for (int x = topLeftSelectionCoordinate.X; x < topLeftSelectionCoordinate.X + _pencilRendererState.SelectionSize; x++) { for (int y = topLeftSelectionCoordinate.Y; y < topLeftSelectionCoordinate.Y + _pencilRendererState.SelectionSize; y++) { if (x < 0 || x >= board.Size.Width || y < 0 || y >= board.Size.Height) { continue; } var coordinate = new Coordinate(x, y); var sprite = new Sprite(coordinate, _pencilRendererState.Character); board.BackgroundLayer.SetTile(coordinate, sprite); } } break; case Layer.Foreground: break; case Layer.ActorInstance: break; default: throw new Exception(String.Format("Unexpected active layer '{0}'.", _boardRendererState.ActiveLayer)); } }
public static SetSpriteCommand SetSprite(SpriteLayer spriteLayer, Sprite sprite) { return new SetSpriteCommand(spriteLayer, sprite); }