Exemplo n.º 1
0
        private static void Read(IDeserializer context, out KeyValuePair <Point, ITile> entry)
        {
            var x    = context.Read <int>("x");
            var y    = context.Read <int>("y");
            var tile = context.Read <ITile>("tile", Read);

            entry = new KeyValuePair <Point, ITile>(new Point(x, y), tile);
        }
Exemplo n.º 2
0
        public override void Read(GameAssetStore store, IDeserializer context)
        {
            base.Read(store, context);
            this.Crew           = context.Read <int>("crew");
            this.Passengers     = context.Read <int>("passengers");
            this.Acceleration   = context.Read <float>("acceleration");
            this.TurnSpeed      = context.Read <float>("turn_speed");
            this.MaxHealth      = context.Read <float>("health");
            this.Mass           = context.Read <float>("mass");
            this.RadarRadius    = context.Read <float>("radar");
            this.EnginePosition = context.Read <Vector2>("engine", CommonSerialize.Read);
            var spriteName = context.Read <string>("sprite");

            this.SpriteTemplate = store.Sprites[spriteName];
            var weapons = context.ReadList("weapons", (ctx) =>
            {
                var name = ctx.Read <string>("weapon");
                var pos  = ctx.Read <Vector2>("pos", CommonSerialize.Read);
                return(new WeaponPlacement
                {
                    Weapon = store.Objects.Get <WeaponTemplate>(name),
                    LocalPosition = pos,
                });
            });

            this.AddWeapons(weapons);
        }
Exemplo n.º 3
0
        public override void Read(GameAssetStore store, IDeserializer context)
        {
            base.Read(store, context);
            this.ProjectileVelocity = context.Read <float>("projectile_velocity");
            this.ProjectileMass     = context.Read <float>("projectile_mass");
            this.FireRate           = TimeSpan.FromSeconds(context.Read <double>("fire_rate"));
            this.Damage             = context.Read <float>("damage");
            var spriteName = context.Read <string>("sprite");

            this.SpriteTemplate = store.Sprites[spriteName];
        }
Exemplo n.º 4
0
        public static void Read(IDeserializer context, out ITile tile)
        {
            var kind = context.Read <string>("kind");

            switch (kind)
            {
            case "m":
                var type = (MaterialType)context.Read <int>("type");
                tile = new Material(type);
                break;

            case "b":
                var id = context.Read <int>("id");
                tile = new Tile(id);
                break;

            default:
                throw new InvalidOperationException("Unknown tile type");
            }
        }
Exemplo n.º 5
0
        public static void Read(Store store, IDeserializer context, out ISpriteTemplate sprite)
        {
            var type = context.Read <int>("type");

            switch (type)
            {
            case 0:
                var parent = context.Read <string>("parent");
                var index  = context.Read <int>("index");
                sprite = (store.Sprites(parent) as SpriteSheetTemplate).Sprites[index];
                break;

            case 1:
                var name = context.Read <string>("sprite");
                sprite = store.Sprites(name);
                break;

            default:
                throw new InvalidOperationException("Unknown sprite type");
            }
        }
Exemplo n.º 6
0
        private static void Read(IDeserializer context, out KeyValuePair <MaterialType, IList <int> > blocks)
        {
            MaterialType material;

            if (!Enum.TryParse(context.Read <string>("material"), out material))
            {
                throw new InvalidOperationException("Unknown material type");
            }
            var tiles = context.ReadList <int>("tiles");

            blocks = new KeyValuePair <MaterialType, IList <int> >(material, tiles);
        }
Exemplo n.º 7
0
        public static void Read(Store store, IDeserializer context, out BlockStore blockStore)
        {
            var tileSize = context.Read <int>("tilesize");

            blockStore = new BlockStore(tileSize);
            var materials = context.ReadList <KeyValuePair <MaterialType, IList <int> > >("materials", Read);

            foreach (var kvp in materials)
            {
                blockStore.Materials[kvp.Key].AddRange(kvp.Value);
            }
            var tiles = context.ReadList <ISpriteTemplate, Store>("tiles", store, Read);

            blockStore.Tiles.AddRange(tiles);
            var flags = context.ReadList <KeyValuePair <int, TileFlags> >("flags", Read);

            foreach (var flag in flags)
            {
                blockStore[flag.Key] = flag.Value;
            }
        }
Exemplo n.º 8
0
 private static void Read(IDeserializer context, out KeyValuePair <int, TileFlags> flags)
 {
     flags = new KeyValuePair <int, TileFlags>(context.Read <int>("id"), (TileFlags)context.Read <int>("flags"));
 }
Exemplo n.º 9
0
                public XmlGraphData <TUIRawData, TEditorData> Read(Stream stream)
                {
                    var data = m_inner.Read(stream);

                    return(new XmlGraphData <TUIRawData, TEditorData>(Enumerable.Empty <GraphAndUI <TUIRawData> >(), data.EditorData, data.Errors, data.DocumentId));
                }
Exemplo n.º 10
0
            public XmlGraphData <TUIRawData, TEditorData> Read(Stream stream)
            {
                var data = m_inner.Read(stream);

                return(new XmlGraphData <TUIRawData, TEditorData>(data.Nodes, data.EditorData, data.Errors, data.DocumentId));
            }