private void PlaceTile(Vector2i position)
{
position = new Vector2i(position.X + this._mapEditorProperties.MapEditorLeft, position.Y + this._mapEditorProperties.MapEditorTop);
for (int x = 0; x < this._selectedTileSprite.TextureRect.Width / 32; x++)
{
for (int y = 0; y < this._selectedTileSprite.TextureRect.Height / 32; y++)
{
var tileSpriteRect = new IntRect(this._selectedTileSprite.TextureRect.Left + (x * 32), this._selectedTileSprite.TextureRect.Top + (y * 32), 32, 32);
var tileSprite = new Sprite(this._selectedTileSprite.Texture, tileSpriteRect);
if (x + position.X >= this._mapEditorProperties.CurrentMap.MapWidth || y + position.Y >= this._mapEditorProperties.CurrentMap.MapHeight)
return;
if (this._mapEditorProperties.CurrentMap.GetTile(position.X + x, position.Y + y) == null)
this._mapEditorProperties.CurrentMap.SetTile(position.X + x, position.Y + y, new Map.Tile());
var layer = new Map.Tile.Layer(tileSprite, position.X + x, position.Y + y);
this._mapEditorProperties.CurrentMap.GetTile(position.X + x, position.Y + y).Layers[(int)this._mapEditorProperties.CurrentLayer] = layer;
if (this._mapEditorProperties.TileBlockedAttribute)
{
this._mapEditorProperties.CurrentMap.GetTile(position.X + x, position.Y + y).Blocked = true;
this._mapEditorProperties.CurrentMap.GetTile(position.X + x, position.Y + y).BlockedCover = new RectangleShape(new Vector2f(32, 32));
this._mapEditorProperties.CurrentMap.GetTile(position.X + x, position.Y + y).BlockedCover.FillColor = new Color(255, 0, 0, 100);
this._mapEditorProperties.CurrentMap.GetTile(position.X + x, position.Y + y).BlockedCover.Position = new Vector2f((position.X + x) * 32, (position.Y + y) * 32);
}
else
{
this._mapEditorProperties.CurrentMap.GetTile(position.X + x, position.Y + y).Blocked = false;
this._mapEditorProperties.CurrentMap.GetTile(position.X + x, position.Y + y).BlockedCover = null;
}
}
}
}