Beispiel #1
0
        public IEnumerable <Property> ToProperties()
        {
            // Add simple fields.
            var properties = new List <Property>
            {
                new Property(nameof(WorldSize), WorldSize.ToString(),
                             comment: "The width and height of the game world."),
                new Property(nameof(MsPerFrame), MsPerFrame.ToString(),
                             comment: "The number of milliseconds to spend per frame. FPS = 1000 / MsPerFrame."),
                new Property(nameof(FramesPerShot), FramesPerShot.ToString(),
                             comment: "The number of frames to pause between each firing of a projectile."),
                new Property(nameof(RespawnRate), RespawnRate.ToString(),
                             comment: "How many frames before a dead ship respawns."),
                new Property(nameof(ShipHitpoints), ShipHitpoints.ToString(),
                             comment: "How many hitpoints ships should start with."),
                new Property(nameof(ProjectileSpeed), ProjectileSpeed.ToString(CultureInfo.InvariantCulture),
                             comment: "How many units per frame that projectiles travel."),
                new Property(nameof(ShipEngineStrength), ShipEngineStrength.ToString(CultureInfo.InvariantCulture),
                             comment: "How many units per frame that ships accellerate when thrusting."),
                new Property(nameof(ShipTurningRate), ShipTurningRate.ToString(CultureInfo.InvariantCulture),
                             comment: "The degrees that a ship can rotate per frame."),
                new Property(nameof(ShipCollisionRadius), ShipCollisionRadius.ToString(CultureInfo.InvariantCulture),
                             comment: "How close a projectile must get to collide with a ship."),
                new Property(nameof(StarCollisionRadius), StarCollisionRadius.ToString(CultureInfo.InvariantCulture),
                             comment: "How close a projectile or ship must get to collide with a star."),
                new Property(nameof(ExplosiveGameMode), ExplosiveGameMode.ToString(),
                             comment:
                             "Set to true to enable the explosive game mode, where a large number of projectiles are spawned each time a sihp dies.")
            };

            // Add all stars.
            foreach (var star in Stars)
            {
                properties.Add(new Property(
                                   nameof(Star),
                                   attributes: new Dictionary <string, string>
                {
                    ["x"]    = star.Location.GetX().ToString(CultureInfo.InvariantCulture),
                    ["y"]    = star.Location.GetY().ToString(CultureInfo.InvariantCulture),
                    ["mass"] = star.Mass.ToString(CultureInfo.InvariantCulture)
                },
                                   comment: "The location and mass of a star."
                                   ));
            }

            return(properties);
        }