public TileMap(string mapDataAsString) { if (String.IsNullOrWhiteSpace(mapDataAsString)) throw new NoTileMapData(); string[] tileLines = mapDataAsString.SplitAndTrim(Environment.NewLine); mapData = new CompleteSquare[tileLines.Length * tileLines[0].Length]; size = new Size(tileLines[0].Length, tileLines.Length); for (int lineIndex = 0; lineIndex < Height; lineIndex++) for (int symbolIndex = 0; symbolIndex < Width; symbolIndex++) { var index = symbolIndex + lineIndex * Width; mapData[index] = new CompleteSquare(tileLines[lineIndex][symbolIndex]); } }
public TileMap(string mapDataAsString) { if (String.IsNullOrWhiteSpace(mapDataAsString)) { throw new NoTileMapData(); } string[] tileLines = mapDataAsString.SplitAndTrim(Environment.NewLine); mapData = new CompleteSquare[tileLines.Length * tileLines[0].Length]; size = new Size(tileLines[0].Length, tileLines.Length); for (int lineIndex = 0; lineIndex < Height; lineIndex++) { for (int symbolIndex = 0; symbolIndex < Width; symbolIndex++) { var index = symbolIndex + lineIndex * Width; mapData[index] = new CompleteSquare(tileLines[lineIndex][symbolIndex]); } } }
public TileMap(CompleteSquare[] mapData, Size size) { this.mapData = mapData; this.size = size; }