private void LoadBiomes() { XmlDocument xml = new XmlDocument(); xml.Load("Content/XML/Biomes.xml"); foreach (XmlNode node in xml.SelectNodes("Biomes/Biome")) { string uid = node.Attributes.GetNamedItem("UID").Value; string file = node.Attributes.GetNamedItem("File").Value; string name = node.Attributes.GetNamedItem("Name").Value; try { using (Texture2D texture = TextureUtility.LoadTexture(GraphicsDevice, "Content/Graphics/Biomes/" + file)) { Texture2D[,] variants = TextureUtility.Split(GraphicsDevice, texture, 64, 64); BasicSprite[] sprites = new BasicSprite[variants.Length]; int i = 0, maxY = variants.GetLength(1), maxX = variants.GetLength(0); for (int y = 0; y < maxY; y++) { for (int x = 0; x < maxX; x++) { sprites[i] = Textures.Copy(variants[x, y]); i++; } } Biome biome = new Biome(uid, name, sprites); Data.Biomes.Add(uid, biome); } } catch { } } Textures.ApplyChanges(); }
private void LoadTexture(XmlElement node) { string id = node.GetAttribute("ID"); string file = node.GetAttribute("Source"); using (Texture2D texture = TextureUtility.LoadTexture(Game.GraphicsDevice, "Mods/" + file)) Textures.Add(id, TextureAtlases.Copy(texture)); }