using Azimuth; using Prism; namespace Konis.Testbed { /// /// The effects the testbed offers. Sizes and speeds are in world units, which are pixels at the camera's starting /// zoom, and the ground is the plane of altitude zero. /// public static class Effects { private static GradientDef Tint(Gradient gradient) { return new GradientDef { Gradient = gradient }; } private static Color Rgb(int red, int green, int blue) { return Color.FromArgb(255, red, green, blue); } public static readonly Effect Fire = new Effect("Fire", new StandardEmitterDef { Name = "Fire", Capacity = 500, Rate = 140, Lifetime = new Variation(0.6, 1.0), Speed = new Variation(20, 50), Heading = new Variation(0, 1), Elevation = new Variation(0.2, 0.3), AngularVelocity = new Variation(-0.5, 0.5), Size = new Variation(16, 26), Gravity = -30, Drag = 0.5, SizeOverLife = fraction => 1.0 - 0.8 * fraction, AlphaOverLife = fraction => 1.0 - fraction, TintOverLife = Tint(new Gradient( GradientSpace.LinearLight, new GradientStop(0, Rgb(255, 240, 150)), new GradientStop(0.4, Rgb(255, 140, 30)), new GradientStop(1, Rgb(150, 20, 10)))), }, additive: true); public static readonly Effect Smoke = new Effect("Smoke", new StandardEmitterDef { Name = "Smoke", Capacity = 400, Rate = 30, Lifetime = new Variation(3, 5), Speed = new Variation(10, 25), Heading = new Variation(0, 1), Elevation = new Variation(0.2, 0.3), AngularVelocity = new Variation(-0.1, 0.1), Size = new Variation(14, 20), Gravity = -8, Drag = 0.3, SizeOverLife = fraction => 1.0 + 3.0 * fraction, AlphaOverLife = fraction => 0.5 * Scalar.Min(1.0, fraction * 8.0) * (1.0 - fraction), TintOverLife = Tint(Gradient.Constant(Rgb(170, 170, 175))), }, additive: false); public static readonly Effect Fountain = new Effect("Fountain", new StandardEmitterDef { Name = "Fountain", Capacity = 800, Rate = 160, Lifetime = new Variation(1.6, 2.0), Speed = new Variation(150, 190), Heading = new Variation(0, 1), Elevation = new Variation(0.21, 0.26), Size = new Variation(6, 10), Gravity = 220, AlphaOverLife = fraction => 1.0 - 0.6 * fraction, TintOverLife = Tint(Gradient.Between(Rgb(200, 235, 255), Rgb(60, 140, 230))), }, additive: false); public static readonly Effect Sparks = new Effect("Sparks", new StandardEmitterDef { Name = "Sparks", Capacity = 300, Rate = 800, Lifespan = 0.15, Lifetime = new Variation(0.5, 1.2), Speed = new Variation(80, 260), Heading = new Variation(0, 1), Elevation = new Variation(0.02, 0.25), Size = new Variation(5, 9), Gravity = 260, Drag = 1.0, AlphaOverLife = fraction => 1.0 - fraction, TintOverLife = Tint(Gradient.Between(Rgb(255, 250, 200), Rgb(255, 110, 20))), }, additive: true); public static readonly Effect Spinner = new Effect("Spinner", new StandardEmitterDef { Name = "Spinner", Capacity = 200, Rate = 60, Lifetime = 2.5, Speed = 70, Heading = new Variation(0, 1), Elevation = 0, AngularVelocity = new Variation(0.5, 1.5), Size = 28, Drag = 0.6, AlphaOverLife = fraction => 1.0 - fraction, TintOverLife = Tint(Gradient.Between(Rgb(120, 255, 160), Rgb(40, 120, 255))), }, additive: false); /// /// Gets every effect, in the order the testbed lists them. /// public static readonly Effect[] All = { Fire, Smoke, Fountain, Sparks, Spinner }; /// /// Returns whether the effect that runs is blended additively. /// public static bool IsAdditive(EmitterDef def) { for (int i = 0; i < All.Length; i++) { if (ReferenceEquals(All[i].Def, def)) { return All[i].Additive; } } return false; } } }