private void Paint(TerrainPosition position, TerrainTileDefinitionResource tileData, List<Int32>visitedPositions)
        {
            var initialTileKey = Terrain.GetTileKey(position);

            Terrain.SetTile(position, tileData);
            visitedPositions.Add(position.Row * Terrain.Columns + position.Column);
            
            // North
            if (position.Row > 0)
            {
                if (!visitedPositions.Contains((position.Row - 1) * Terrain.Columns + position.Column))
                {
                    var newPosition = new TerrainPosition() { Row = position.Row - 1, Column = position.Column };
                    if (Terrain.GetTileKey(newPosition) == initialTileKey)
                    {
                        Paint(newPosition, tileData, visitedPositions);
                    }
                }
            }

            // South
            if (position.Row < (Terrain.Rows - 1))
            {
                if (!visitedPositions.Contains((position.Row + 1) * Terrain.Columns + position.Column))
                {
                    var newPosition = new TerrainPosition() { Row = position.Row + 1, Column = position.Column };
                    if (Terrain.GetTileKey(newPosition) == initialTileKey)
                    {
                        Paint(newPosition, tileData, visitedPositions);
                    }
                }
            }

            // West
            if (position.Column < (Terrain.Columns - 1))
            {
                if (!visitedPositions.Contains(position.Row * Terrain.Columns + position.Column + 1))
                {
                    var newPosition = new TerrainPosition() { Row = position.Row, Column = position.Column + 1 };
                    if (Terrain.GetTileKey(newPosition) == initialTileKey)
                    {
                        Paint(newPosition, tileData, visitedPositions);
                    }
                }
            }

            // East
            if (position.Column > 0)
            {
                if (!visitedPositions.Contains(position.Row * Terrain.Columns + position.Column - 1))
                {
                    var newPosition = new TerrainPosition() { Row = position.Row, Column = position.Column - 1 };
                    if (Terrain.GetTileKey(newPosition) == initialTileKey)
                    {
                        Paint(newPosition, tileData, visitedPositions);
                    }
                }
            }
        }
        public void SetTile(TerrainPosition position, TerrainTileDefinitionResource tileResource)
        {
            var tilesAtPosition = _tiles.Where(x => x.Column == position.Column && x.Row == position.Row);

            if (tilesAtPosition.Count() > 0)
            {
                foreach (var tile in tilesAtPosition.ToArray())
                    _tiles.Remove(tile);
            }

            var newTile = new Tile() { Key = tileResource.Key,  Row = position.Row, Column = position.Column, Sprite = _spriteLoader.LoadSprite(tileResource.SpriteKey) };
            _tiles.Add(newTile);
        }