Example #1
0
            public Emitter(IModifier[] modifiers)
            {
                _modifiers = modifiers;

                for (var x = 0; x < Program.ParticleCount; x++)
                {
                    Particles.GetFloatValues("TimeAlive")[x]                   = 0;
                    Particles.GetFloatValues("RotationInRadians")[x]           = 1;
                    Particles.GetVector2Values("Position")[x]                  = new Vector2(100, 100);
                    Particles.GetVector2Values("ReferencePosition")[x]         = new Vector2(100, 100);
                    Particles.GetFloatValues("RotationalVelocityInRadians")[x] = 1f;
                    Particles.GetFloatValues("CurrentRed")[x]                  = 255;
                    Particles.GetFloatValues("CurrentGreen")[x]                = 255;
                    Particles.GetFloatValues("CurrentBlue")[x]                 = 255;
                    Particles.GetFloatValues("CurrentAlpha")[x]                = 255;
                    Particles.GetVector2Values("Size")[x]             = Vector2.Zero;
                    Particles.GetVector2Values("InitialSize")[x]      = new Vector2(32, 32);
                    Particles.GetVector2Values("Velocity")[x]         = new Vector2(100, 100);
                    Particles.GetByteValues("TextureSectionIndex")[x] = 0;
                    Particles.GetByteValues("InitialAlpha")[x]        = 255;
                    Particles.GetByteValues("InitialBlue")[x]         = 255;
                    Particles.GetByteValues("InitialGreen")[x]        = 255;
                    Particles.GetByteValues("InitialRed")[x]          = 255;
                    Particles.GetFloatValues("Altitude")[x]           = 0;
                    Particles.GetFloatValues("AltitudeVelocity")[x]   = 0;
                    Particles.GetIntValues("AltitudeBounceCount")[x]  = 0;
                }
            }
Example #2
0
            public void Modify(float timeSinceLastFrame, ParticleCollection particles)
            {
                var velocity          = particles.GetVector2Values("Velocity");
                var position          = particles.GetVector2Values("Position");
                var referencePosition = particles.GetVector2Values("ReferencePosition");
                var altitude          = particles.GetFloatValues("Altitude");

                for (var x = 0; x < Program.ParticleCount; x++)
                {
                    referencePosition[x] += velocity[x] * timeSinceLastFrame;
                    position[x].X         = referencePosition[x].X;
                    position[x].Y         = referencePosition[x].Y + altitude[x];
                }
            }
Example #3
0
            public void Modify(float timeSinceLastFrame, ParticleCollection particles)
            {
                var initialSize = particles.GetVector2Values("InitialSize");
                var size        = particles.GetVector2Values("Size");

                for (var x = 0; x < Program.ParticleCount; x++)
                {
                    var width = (((initialSize[x].X - Emitter.EndValue) / Emitter.MaxParticleLifeTime) *
                                 timeSinceLastFrame);
                    var height = (((initialSize[x].Y - Emitter.EndValue) / Emitter.MaxParticleLifeTime) *
                                  timeSinceLastFrame);
                    size[x].X -= width;
                    size[x].Y -= height;
                }
            }
Example #4
0
            public void Modify(float timeSinceLastFrame, ParticleCollection particles)
            {
                var velocity = particles.GetVector2Values("Velocity");

                for (var x = 0; x < Program.ParticleCount; x++)
                {
                    velocity[x] -= Emitter.Drag * velocity[x] * timeSinceLastFrame;
                }
            }
Example #5
0
            public void Modify(float timeSinceLastFrame, ParticleCollection particles)
            {
                var size = particles.GetVector2Values("Size");

                for (var x = 0; x < Program.ParticleCount; x++)
                {
                    size[x] += timeSinceLastFrame * new Vector2(Emitter.SizeChange, Emitter.SizeChange);
                }
            }
Example #6
0
            public void Modify(float timeSinceLastFrame, ParticleCollection particles)
            {
                var velocity          = particles.GetVector2Values("Velocity");
                var rotationInRadians = particles.GetFloatValues("RotationInRadians");

                for (var x = 0; x < Program.ParticleCount; x++)
                {
                    if (velocity[x] != Vector2.Zero)
                    {
                        rotationInRadians[x] =
                            (float)Math.Atan2(velocity[x].Y, velocity[x].X);
                    }
                }
            }