コード例 #1
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);
        }
コード例 #2
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];
        }