public static void Load(string path, AssetStore <string> assets) { foreach (PropertyBag artProp in PropertyBag.FromFile(path)) { string sheetName = artProp.GetOrDefault("sheet", string.Empty); Spritesheet sheet = assets.GetAsset <Spritesheet>(sheetName); string name = artProp.Name; int x = artProp.GetOrDefault("x", 0); int y = artProp.GetOrDefault("y", 0); int width = artProp.GetOrDefault("width", -1); int height = artProp.GetOrDefault("height", -1); bool exact = artProp.GetOrDefault("exact", false); Vector2?origin = DataLoader.ParseVector(artProp.GetOrDefault("origin", null)); Sprite sprite; if (!exact) { sprite = sheet.CutSprite(x, y, width, height, name, origin); } else { sprite = sheet.CutSpriteExact(x, y, width, height, name, origin); } assets.AddAsset(name, sprite); Console.WriteLine($"Loaded Sprite: {name}"); } }
public static void Load(string path, AssetStore <string> assets, ContentManager content) { foreach (PropertyBag sheetProp in PropertyBag.FromFile(path)) { string name = sheetProp.Name; string sheetPath = sheetProp.GetOrDefault("path", "Content"); Texture2D texture = DataLoader.LoadTexture(Path.Combine(sheetPath, name)); Spritesheet spritesheet = new Spritesheet(name, texture); assets.AddAsset(name, spritesheet); } }
public static void Load(string path, AssetStore <string> assets) { foreach (PropertyBag raceProp in PropertyBag.FromFile(path)) { string name = raceProp.Name; int speed = raceProp.GetOrDefault("speed", Energy.NormalSpeed); int health = raceProp.GetOrDefault("health", 1); Animation animation = assets.GetAsset <Animation>(raceProp["animation"].Value); Color color = ColorParser.ParseColor(raceProp["color"].Value); Race race = new Race(name, animation, color, speed, health); assets.AddAsset(name, race); } }
public static void Load(string path, AssetStore <string> assets) { foreach (PropertyBag animProp in PropertyBag.FromFile(path)) { string name = animProp.Name; Spritesheet sheet = assets.GetAsset <Spritesheet>(animProp.GetOrDefault("sheet", string.Empty)); float frameDuration = animProp.GetOrDefault("frameDuration", 0.5f); string[] frames = animProp.GetOrDefault("frames", string.Empty).Split(','); AnimationFrame[] animationFrames = new AnimationFrame[frames.Length]; for (int i = 0; i < frames.Length; i++) { Sprite sprite = assets.GetAsset <Sprite>(frames[i].Trim()); animationFrames[i] = new AnimationFrame(sprite); } Animation animation = new Animation(frameDuration, animationFrames); assets.AddAsset(name, animation); } }
public static void Load(string path, AssetStore <string> assets) { foreach (PropertyBag tileProp in PropertyBag.FromFile(path)) { string name = tileProp.Name; bool isSolid = tileProp.GetOrDefault("solid", false); bool isTransparent = tileProp.GetOrDefault("transparent", true); byte id = _nextId++; string animation = tileProp.GetOrDefault("animation", null); Sprite sprite = null; if (string.IsNullOrWhiteSpace(animation)) { string spriteName = tileProp.GetOrDefault("sprite", name); sprite = assets.GetAsset <Sprite>(spriteName); } Color color = ColorParser.ParseColor(tileProp["color"].Value.ToLower().Trim()); Tile tile = new Tile(id, sprite, color, isSolid, isTransparent, animation); assets.AddAsset(name, tile); } }
private static void LoadSoundEffect(string name, ContentManager content, AssetStore <string> assets) { SoundEffect soundEffect = content.Load <SoundEffect>("Audio/" + name); assets.AddAsset(name, soundEffect); }