public void LoadTexture(ContentHouse ch) { switch (ID) { default: texture.Load(ch.Get("tile_" + ID)); break; } }
public void Load(string prefix, ContentHouse ch) { DirectoryInfo taskDirectory = new DirectoryInfo("Tilemaps/"); FileInfo[] taskFiles = taskDirectory.GetFiles(prefix + "*.txt"); foreach (var file in taskFiles) { var x = 0; var y = 0; var position = file.Name.Substring(prefix.Length + 1); position = position.Replace(".txt", ""); position = position.Replace("_", ""); if (position[0] == '-') { x = Int32.Parse(position.Substring(0, 2)); if (position[2] == '-') { y = Int32.Parse(position.Substring(2, 2)); } else { y = Int32.Parse(position.Substring(2, 1)); } } else { x = Int32.Parse(position.Substring(0, 1)); if (position[1] == '-') { y = Int32.Parse(position.Substring(1, 2)); } else { y = Int32.Parse(position.Substring(1, 1)); } } Tilemap tilemap = new Tilemap(x, y); tilemap.Load(ch, file.DirectoryName + "/" + file.Name); tilemaps.Add(tilemap); } }
public void Load(ContentHouse ch, string path) { List <List <Tile> > tileS; using (StreamReader sr = File.OpenText(path)) { JsonSerializer serializer = new JsonSerializer(); tileS = (List <List <Tile> >)serializer.Deserialize(sr, typeof(List <List <Tile> >)); } layers = new List <List <Tile> >(); for (int i = 0; i < tileS.Count; i++) { layers.Add(new List <Tile>()); for (int h = 0; h < tileS[i].Count; h++) { Tile tile = tileS[i][h]; layers[i].Add(new Tile((int)(position.X + tile.position.X), (int)(position.Y + tile.position.Y), tile.ID)); layers[i][h].LoadTexture(ch); } } }
public virtual void Unload() { ch = null; }
//Constructor public Scene() { ch = new ContentHouse(); }