예제 #1
0
        /// <summary>
        /// Creates all the static particle emitters used in the game.
        /// </summary>
        public void CreateParticles()
        {
            ParticleManager = new ParticleManager(ComponentManager);

            // Smoke
            EmitterData puff = ParticleManager.CreatePuffLike("puff", new SpriteSheet(ContentPaths.Particles.puff), Point.Zero, BlendState.AlphaBlend);
            ParticleManager.RegisterEffect("puff", puff);

            // Bubbles
            EmitterData bubble = ParticleManager.CreatePuffLike("splash2", new SpriteSheet(ContentPaths.Particles.splash2), Point.Zero, BlendState.AlphaBlend);
            bubble.ConstantAccel = new Vector3(0, 5, 0);
            bubble.EmissionSpeed = 3;
            bubble.LinearDamping = 0.9f;
            bubble.GrowthSpeed = -2.5f;
            bubble.MinScale = 1.5f;
            bubble.MaxScale = 2.5f;
            bubble.ParticleDecay = 1.5f;
            bubble.HasLighting = false;
            ParticleManager.RegisterEffect("splash2", bubble);

            EmitterData splat = ParticleManager.CreatePuffLike("splat", new SpriteSheet(ContentPaths.Particles.splat), Point.Zero, BlendState.AlphaBlend);
            splat.ConstantAccel = Vector3.Zero;
            splat.EmissionRadius = 0.01f;
            splat.EmissionSpeed = 0.0f;
            splat.GrowthSpeed = -1.75f;
            splat.MinAngle = -0.0f;
            splat.MaxAngle = 0.0f;
            splat.MinAngular = -0.01f;
            splat.MaxAngular = 0.01f;
            splat.MaxParticles = 500;
            splat.MinScale = 0.05f;
            splat.ParticleDecay = 1.5f;
            splat.HasLighting = false;
            splat.MaxScale = 1.1f;
            splat.EmitsLight = false;
            ParticleManager.RegisterEffect("splat", splat);

            EmitterData heart = ParticleManager.CreatePuffLike("heart", new SpriteSheet(ContentPaths.Particles.heart),
                Point.Zero, BlendState.AlphaBlend);
            heart.MinAngle = 0.01f;
            heart.MaxAngle = 0.01f;
            heart.MinAngular = 0.0f;
            heart.MinAngular = 0.0f;
            heart.ConstantAccel = Vector3.Up * 20;
            ParticleManager.RegisterEffect("heart", heart);

            // Fire
            SpriteSheet fireSheet = new SpriteSheet(ContentPaths.Particles.more_flames, 32, 32);
            EmitterData flame = ParticleManager.CreatePuffLike("flame", fireSheet, Point.Zero, BlendState.AlphaBlend);
            flame.ConstantAccel = Vector3.Up*20;
            flame.EmissionSpeed = 2;
            flame.GrowthSpeed = -1.9f;
            flame.MinAngle = -0.2f;
            flame.MaxAngle = 0.2f;
            flame.MinAngular = -0.01f;
            flame.MaxAngular = 0.01f;
            flame.MaxParticles = 500;
            flame.MinScale = 0.2f;
            flame.HasLighting = false;
            flame.MaxScale = 2.0f;
            flame.EmitsLight = true;
            flame.Blend = new BlendState()
            {
                AlphaSourceBlend = Blend.One,
                AlphaDestinationBlend = Blend.InverseSourceAlpha,
                ColorDestinationBlend = Blend.InverseSourceAlpha,
                ColorSourceBlend = Blend.One
            };
            ParticleManager.RegisterEffect("flame", flame, flame.Clone(fireSheet, new Point(1, 0)), flame.Clone(fireSheet, new Point(2, 0)), flame.Clone(fireSheet, new Point(3, 0)));

            EmitterData greenFlame = ParticleManager.CreatePuffLike("green_flame", new SpriteSheet(ContentPaths.Particles.green_flame), new Point(0, 0), BlendState.Additive);
            greenFlame.ConstantAccel = Vector3.Up * 20;
            greenFlame.EmissionSpeed = 2;
            greenFlame.GrowthSpeed = -1.9f;
            greenFlame.MinAngle = -0.2f;
            greenFlame.MaxAngle = 0.2f;
            greenFlame.MinAngular = -0.01f;
            greenFlame.MaxAngular = 0.01f;
            greenFlame.HasLighting = false;

            ParticleManager.RegisterEffect("green_flame", greenFlame);

            List<Point> frm2 = new List<Point>
            {
                new Point(0, 0)
            };

            // Leaves
            EmitterData testData2 = new EmitterData
            {
                Animation = new Animation(GraphicsDevice, new SpriteSheet(ContentPaths.Particles.leaf), "leaf", 32, 32, frm2, true, Color.White, 1.0f, 1.0f, 1.0f, false),
                ConstantAccel = new Vector3(0, -10, 0),
                LinearDamping = 0.95f,
                AngularDamping = 0.99f,
                EmissionFrequency = 1.0f,
                EmissionRadius = 2.0f,
                EmissionSpeed = 5.0f,
                GrowthSpeed = -0.5f,
                MaxAngle = 3.14159f,
                MinAngle = 0.0f,
                MaxParticles = 1000,
                MaxScale = 0.5f,
                MinScale = 0.1f,
                MinAngular = -5.0f,
                MaxAngular = 5.0f,
                ParticleDecay = 0.5f,
                ParticlesPerFrame = 0,
                Sleeps = true,
                ReleaseOnce = true,
                CollidesWorld = true,
                Texture = TextureManager.GetTexture(ContentPaths.Particles.leaf)
            };

            ParticleManager.RegisterEffect("Leaves", testData2);

            // Various resource explosions
            ParticleManager.CreateGenericExplosion(ContentPaths.Particles.dirt_particle, "dirt_particle");
            EmitterData stars = ParticleManager.CreatePuffLike( "star_particle", new SpriteSheet(ContentPaths.Particles.star_particle), new Point(0, 0),  BlendState.Additive);
            stars.MinAngle = -0.1f;
            stars.MaxAngle = 0.1f;
            stars.MinScale = 0.2f;
            stars.MaxScale = 0.5f;
            stars.AngularDamping = 0.99f;
            stars.LinearDamping = 0.999f;
            stars.GrowthSpeed = -0.8f;
            stars.EmissionFrequency = 5;
            stars.CollidesWorld = false;
            stars.HasLighting = false;

            ParticleManager.RegisterEffect("star_particle", stars);

            ParticleManager.CreateGenericExplosion(ContentPaths.Particles.stone_particle, "stone_particle");
            ParticleManager.CreateGenericExplosion(ContentPaths.Particles.sand_particle, "sand_particle");
            ParticleManager.CreateGenericExplosion(ContentPaths.Particles.dirt_particle, "dirt_particle");

            SpriteSheet bloodSheet = new SpriteSheet(ContentPaths.Particles.gibs, 32, 32);
            // Blood explosion
               // ParticleEmitter b = ParticleManager.CreateGenericExplosion(ContentPaths.Particles.blood_particle, "blood_particle").Emitters[0];
            EmitterData b = ParticleManager.CreateExplosionLike("blood_particle", bloodSheet, Point.Zero, BlendState.AlphaBlend);
            b.MinScale = 0.75f;
            b.MaxScale = 1.0f;
            b.Damping = 0.1f;
            b.GrowthSpeed = -0.8f;
            b.RotatesWithVelocity = true;

            ParticleManager.RegisterEffect("blood_particle", b);
            ParticleManager.RegisterEffect("gibs",  b.Clone(bloodSheet, new Point(1, 0)), b.Clone(bloodSheet, new Point(2, 0)), b.Clone(bloodSheet, new Point(3, 0)));
        }