private Location[] getLocations(CartesianPointer position, CartesianSize mapSize, string map, int minCapacity, int maxCapacity) { var locations = new List <Location>(); var matrixSize = _converter.GetMatrixSize(map); var blockSize = _converter.GetBlockSize(mapSize, matrixSize); var mapArray = _converter.GetMapArray(map, matrixSize); var center = new CartesianPointer(matrixSize.SizeX / 2.0, matrixSize.SizeY / 2.0); for (var x = 0; x < matrixSize.SizeX; x++) { for (var y = 0; y < matrixSize.SizeY; y++) { if (mapArray[x, y] != LocationType.Default) { var pontoCentral = _converter.GetGlobalPointer(blockSize, position, mapSize, matrixSize, center, x, y); var l = new Location { Size = blockSize, Capacity = _rd.Next(minCapacity, maxCapacity), LocationType = mapArray[x, y], Occupation = 0, Position = pontoCentral }; if (l.Inside(_env)) { locations.Add(l); } } } } return(locations.ToArray()); }
public CartesianPointer GetGlobalPointer(CartesianSize blockSize, CartesianPointer position, CartesianSize mapSize, CartesianSize matrixSize, CartesianPointer center, int x, int y) { var deslocamentoLocal = new CartesianPointer(x - center.X, y - center.Y); var porcentagem = new CartesianSize(mapSize.SizeX / matrixSize.SizeX, mapSize.SizeY / matrixSize.SizeY); var deslocamentoGlobal = new CartesianPointer(deslocamentoLocal.X * porcentagem.SizeX, deslocamentoLocal.Y * porcentagem.SizeY); var ponto = new CartesianPointer(deslocamentoGlobal.X + position.X, deslocamentoGlobal.Y + position.Y); var pontoCentral = new CartesianPointer(ponto.X + blockSize.SizeX / 2.0, ponto.Y + blockSize.SizeY / 2.0); return(pontoCentral); }
static void Main(string[] args) { var file = File.ReadAllText(@"C:\Users\lucas.fernandes\Desktop\mapa1.txt") .Replace(@"\n", "") .Replace(@"\r", ""); var mapGlobalSize = new CartesianSize(1024, 768); var mapLocalSize = new CartesianSize(108, 96); var pontoReferencia = new CartesianPointer(-100, -100); var b = new EnvironmentBuilder(mapGlobalSize) .PlotMap(file, mapLocalSize, pontoReferencia); var threadId = Thread.CurrentContext.ContextID.ToString(); var h = new Helpers(new GetTaskStub(threadId, null), null, null, null, null, null); }
public EnvironmentBuilder PlotMap(string map, CartesianSize size, CartesianPointer position) { _currentMap = _converter.GetMapName(map); _locations.Add(_currentMap, getLocations(position, size, map, 0, 2)); return(this); }