# Calculate path without obstacles

I have this map in my game and I want to make a method to calculate a path beggining in my enemies current position and ending in my character current position . A* pathing would be a viable approach?

``````public class MapManager
{
private TileManager tiles;
private int[,] map;
private const int mapWidth = 60;
private const int mapHeight = 60;

public MapManager()
{
this.map = new int[mapHeight, mapWidth];
this.tiles = new TileManager();

FillMap();

}

public TileManager GetTiles()
{
return tiles;
}

public int [,] GetMap()
{
return map;
}

public int GetTileType(int _x ,int _y)
{
return map[_x, _y];
}

private void FillMap()
{
for (int i = 0; i < mapWidth; i++)
{
map[0, i] = 2;
map[mapHeight - 1, i] = 2;
}

for (int i = 0; i < mapHeight; i++)
{
map[i, 0] = 2;
map[i, mapWidth - 1] = 2;
}

/* for (int i = 1; i < mapWidth - 1; i++)
{
map[i, i] = 1;

}*/

map[22, 13] = 6;
map[22, 14] = 7;
map[22, 15] = 8;
map[23, 13] = 9;
map[23, 14] = 2;
map[23, 15] = 10;
map[24, 13] = 3;
map[24, 14] = 4;
map[24, 15] = 5;

}

public void Draw(Vector2 _offset)
{
Rectangle position = new Rectangle(0, 0, this.tiles.GetTilesWidht(), this.tiles.GetTilesHeight());

for (int row = 0; row < mapHeight; row++)
{

for (int col = 0; col < mapWidth; col++)
{

tiles.GetTile(map[row, col]).Draw(_offset, position);
position.X += tiles.GetTilesWidht();
}
position.X = 0;
position.Y += tiles.GetTilesHeight();

}
}
}
``````
`````` public class TileManager
{
private Tile[] arrayTile;
private int tilesWidht;
private int tilesHeight;

public TileManager()
{
arrayTile = new Tile[11];
tilesWidht = 64;
tilesHeight = 64;

arrayTile[0] = new Tile("2D\\MapTiles\\DirtTile", true,true,tilesWidht,tilesHeight);
arrayTile[1] = new Tile("2D\\MapTiles\\GrassTile", true,true, tilesWidht, tilesHeight);
arrayTile[2] = new Tile("2D\\MapTiles\\WaterTile", false,false, tilesWidht, tilesHeight);
arrayTile[3] = new Tile("2D\\MapTiles\\WaterDownLeftTile", false,false, tilesWidht, tilesHeight);
arrayTile[4] = new Tile("2D\\MapTiles\\WaterDownMidTile", false,false, tilesWidht, tilesHeight);
arrayTile[5] = new Tile("2D\\MapTiles\\WaterDownRightTile", false,false, tilesWidht, tilesHeight);
arrayTile[6] = new Tile("2D\\MapTiles\\WaterTopLeftTile", false,false, tilesWidht, tilesHeight);
arrayTile[7] = new Tile("2D\\MapTiles\\WaterTopMidTile", false,false, tilesWidht, tilesHeight);
arrayTile[8] = new Tile("2D\\MapTiles\\WaterTopRightTile", false,false, tilesWidht, tilesHeight);
arrayTile[9] = new Tile("2D\\MapTiles\\WaterMidLeftTile", false,false, tilesWidht, tilesHeight);
arrayTile[10] = new Tile("2D\\MapTiles\\WaterMidRightTile", false,false, tilesWidht, tilesHeight);

}
public int GetTilesWidht()
{
return tilesWidht;
}

public int GetTilesHeight()
{
return tilesHeight;
}

public Tile GetTile(int _position)
{
return arrayTile[_position];
}
}
``````
`````` public class Tile :Basic2D
{
private bool crossableUnit;
private bool crossableProjectile;

public Tile(string _path, bool _crossableUnit, bool _crossableProjectile, int _width,int _height) :base (_path, Vector2.Zero, new Vector2(_width,_height))
{
this.crossableUnit = _crossableUnit;
crossableProjectile = _crossableProjectile;

}

public bool UnitCross()
{
return this.crossableUnit;
}

public bool ProjectileCross()
{
return crossableProjectile;
}

}
``````