Esempio n. 1
0
        public void Load(string resourceFile)
        {
            this.resourceFile = resourceFile;
            if (!File.Exists(resourceFile))
            {
                throw new FileNotFoundException();
            }
            var json = File.ReadAllText(resourceFile);
            var obj  = JsonConvert.DeserializeObject <ResourceObject>(json);

            if (obj.Resources.Songs != null)
            {
                obj.Resources.Songs.ForEach(x =>
                {
                    songs.Add(x.name, content.Load <Microsoft.Xna.Framework.Media.Song>(x.name));
                });
            }
            if (obj.Resources.SoundEffects != null)
            {
                obj.Resources.SoundEffects.ForEach(x =>
                {
                    effects.Add(x.name, content.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(x.path));
                });
            }
            if (obj.Resources.Spritesheets != null)
            {
                obj.Resources.Spritesheets.ForEach(x =>
                {
                    var ss = new Graphics.Spritesheet(content.Load <Texture2D>(x.path), x.width, x.height);
                    ss.Unpack();
                    x.Aliases.ForEach(y => { ss.MapIndex(y.x, y.y, y.name); });
                    spritesheets.Add(x.name, ss);
                });
            }
            if (obj.Resources.Textures != null)
            {
                obj.Resources.Textures.ForEach(x => { textures.Add(x.name, content.Load <Texture2D>(x.path)); });
            }
            if (obj.Resources.Fonts != null)
            {
                obj.Resources.Fonts.ForEach(x =>
                {
                    fonts.Add(x.name, content.Load <Microsoft.Xna.Framework.Graphics.SpriteFont>(x.path));
                });
            }
            if (obj.Resources.EntityModels != null)
            {
                obj.Resources.EntityModels.ForEach(x =>
                {
                    var j = File.ReadAllBytes(@"Content\" + x.path + ".json");
                    //entityModels.Add(x.name, new Env.EntityModel(j));
                });
            }
            if (obj.Resources.InterfaceStyles != null)
            {
                obj.Resources.InterfaceStyles.ForEach(x =>
                {
                    var text = File.ReadAllText(@"Content\" + x.path + ".json");
                    styles.Add(x.name, InterfaceStyle.CreateFrom(text));
                });
            }
        }
Esempio n. 2
0
 public void Register(Graphics.Spritesheet spriteSheet, string name)
 {
     spritesheets.Add(name, spriteSheet);
 }