public static void LoadTilesFromMap(string name, params TilemapCell[] cells) { Texture tilemap = Resourcepack.GetResource <Texture>(name); if (tilemap != null) { for (int k = 0; k < cells.Length; k++) { TilemapCell cell = cells[k]; Texture tile = new Texture(cell.Width, cell.Height); ImageProcessor.Copy(tilemap, tile, cell.X, cell.Y); Resourcepack.AddAsset(cell.name, tile); Resourcepack.AddAsset(cell.name, new Sprite(tile)); } } }
public void Setup() { char [,] tilemap = new char[10, 10] { { '.', '.', '.', '.', '.', '.', '.', '.', '.', '.' }, // 0 { '.', '.', '.', '.', '#', '#', '#', '#', '#', '.' }, // 1 { '.', '.', '.', '.', '#', '#', '#', '#', '.', '.' }, // 2 { '.', '#', '#', '.', '#', '#', '.', '.', '.', '.' }, // 3 { '.', '#', '#', '.', '#', '#', 'T', '.', '.', '.' }, // 4 { '.', '#', '#', '.', '#', '#', '.', '.', '.', '.' }, // 5 { '.', '#', '#', '.', '#', '#', '#', '#', '#', '#' }, // 6 { '.', '.', '.', '.', '#', '#', '#', '#', '#', '.' }, // 7 { '.', '.', '.', 'S', '#', '#', '#', '#', '#', '.' }, // 8 { '.', '.', '.', '.', '.', '.', '.', '.', '.', '.' }, // 9 // 0 1 2 3 4 5 6 7 8 9 }; grid = new TilemapGrid(tilemap); start = new TilemapCell(3, 8, 0); target = new TilemapCell(6, 4, 0); }