Пример #1
0
    private TileType[][] ConvertToTiles()
    {
        var tileLocations = tilesManager.GetTiles();

        Debug.Log(tileLocations.Count());
        foreach (var l in tileLocations)
        {
            Debug.Log(l.Key.x + "." + l.Key.y + "." + l.Key.z);
        }
        var xRange = new Range(tileLocations.Select(point => point.Key.x));
        var zRange = new Range(tileLocations.Select(point => point.Key.z));


        Debug.Log(xRange.Length + ", " + zRange.Length);

        var tiles = new TileType[xRange.Length][];

        for (var x = 0; x < xRange.Length; x++)
        {
            tiles[x] = new TileType[zRange.Length];
        }

        foreach (var tile in tileLocations)
        {
            Debug.Log(tile);
            var row = tiles[(int)tile.Key.x - xRange.Min];
            Debug.Log(row);
            row[(int)tile.Key.z - zRange.Min] = tile.Value;
        }
        return(tiles);
    }