public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            var rotationRateDelta = RotationRate * elapsedSeconds;

            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                particle->Rotation += rotationRateDelta;
            }
        }
Пример #2
0
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            var delta = FinalOpacity - InitialOpacity;

            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                particle->Opacity = delta * particle->Age + InitialOpacity;
            }
        }
        public override unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            var vector = Direction * (Strength * elapsedSeconds);

            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                particle->Velocity = new Vector2(
                    particle->Velocity.X + vector.X * particle->Mass,
                    particle->Velocity.Y + vector.Y * particle->Mass);
            }
        }
Пример #4
0
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                var drag     = -DragCoefficient * Density * particle->Mass * elapsedSeconds;

                particle->Velocity = new Vector(
                    particle->Velocity.X + particle->Velocity.X * drag,
                    particle->Velocity.Y + particle->Velocity.Y * drag);
            }
        }
Пример #5
0
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            var delta = FinalHue - InitialHue;

            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                particle->Colour = new Colour(
                    delta * particle->Age + InitialHue,
                    particle->Colour.S,
                    particle->Colour.L);
            }
        }
Пример #6
0
        public void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                var diff     = Position + particle->TriggerPos - particle->Position;

                var distance2 = diff.LengthSquared();

                var speedGain = _gravConst * Mass / distance2 * elapsedSeconds;
                // normalize distances and multiply by speedGain
                particle->Velocity += diff.ToAxis() * speedGain;
            }
        }
Пример #7
0
        public override unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            var n = Interpolators.Count;

            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                for (var i = 0; i < n; i++)
                {
                    var interpolator = Interpolators[i];
                    interpolator.Update(particle->Age, particle);
                }
            }
        }
Пример #8
0
        public unsafe void Update(float elapsedseconds, ParticleBuffer.ParticleIterator iterator)
        {
            var delta = new HslColor(FinalColor.H - InitialColor.H,
                                     FinalColor.S - InitialColor.S,
                                     FinalColor.L - InitialColor.L);

            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                particle->Color = new HslColor(
                    InitialColor.H + delta.H * particle->Age,
                    InitialColor.S + delta.S * particle->Age,
                    InitialColor.L + delta.L * particle->Age);
            }
        }
        public override unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            while (iterator.HasNext)
            {
                var particle = iterator.Next();

                var left   = particle->TriggerPos.X + Width * -0.5f;
                var right  = particle->TriggerPos.X + Width * 0.5f;
                var top    = particle->TriggerPos.Y + Height * -0.5f;
                var bottom = particle->TriggerPos.Y + Height * 0.5f;

                var xPos = particle->Position.X;
                var xVel = particle->Velocity.X;
                var yPos = particle->Position.Y;
                var yVel = particle->Velocity.Y;

                if ((int)particle->Position.X < left)
                {
                    xPos = left + (left - xPos);
                    xVel = -xVel * RestitutionCoefficient;
                }
                else
                {
                    if (particle->Position.X > right)
                    {
                        xPos = right - (xPos - right);
                        xVel = -xVel * RestitutionCoefficient;
                    }
                }

                if (particle->Position.Y < top)
                {
                    yPos = top + (top - yPos);
                    yVel = -yVel * RestitutionCoefficient;
                }
                else
                {
                    if ((int)particle->Position.Y > bottom)
                    {
                        yPos = bottom - (yPos - bottom);
                        yVel = -yVel * RestitutionCoefficient;
                    }
                }
                particle->Position = new Vector2(xPos, yPos);
                particle->Velocity = new Vector2(xVel, yVel);
            }
        }
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            while (iterator.HasNext)
            {
                var particle = iterator.Next();

                var left   = 0;
                var right  = MapManager.Instance.MapWidth;
                var top    = 0;
                var bottom = MapManager.Instance.MapHeight - MapManager.Instance.TileSize.Y;

                var xPos = particle->Position.X;
                var xVel = particle->Velocity.X;
                var yPos = particle->Position.Y;
                var yVel = particle->Velocity.Y;

                if ((int)particle->Position.X < left)
                {
                    xPos = left + (left - xPos);
                    xVel = -xVel * RestitutionCoefficient;
                }
                else if (particle->Position.X > right)
                {
                    xPos = right - (xPos - right);
                    xVel = -xVel * RestitutionCoefficient;
                }

                if (particle->Position.Y < top)
                {
                    yPos = top + (top - yPos);
                    yVel = -yVel * RestitutionCoefficient;
                }
                else if ((int)particle->Position.Y > bottom)
                {
                    yPos = bottom - (yPos - bottom);
                    yVel = -yVel * RestitutionCoefficient;
                    xVel = xVel * RestitutionCoefficient * 2;
                }
                particle->Position = new Vector2(xPos, yPos);
                particle->Velocity = new Vector2(xVel, yVel);
            }
        }
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                var left     = particle->TriggerPos.X + Width * -0.5f;
                var right    = particle->TriggerPos.X + Width * 0.5f;
                var top      = particle->TriggerPos.Y + Height * -0.5f;
                var bottom   = particle->TriggerPos.Y + Height * 0.5f;

                var xPos = particle->Position.X;
                var yPos = particle->Position.Y;

                if ((int)particle->Position.X < left)
                {
                    xPos = particle->Position.X + Width;
                }
                else
                {
                    if ((int)particle->Position.X > right)
                    {
                        xPos = particle->Position.X - Width;
                    }
                }

                if ((int)particle->Position.Y < top)
                {
                    yPos = particle->Position.Y + Height;
                }
                else
                {
                    if ((int)particle->Position.Y > bottom)
                    {
                        yPos = particle->Position.Y - Height;
                    }
                }
                particle->Position = new Vector2(xPos, yPos);
            }
        }
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            var velocityThreshold2 = VelocityThreshold * VelocityThreshold;

            while (iterator.HasNext)
            {
                var particle  = iterator.Next();
                var velocity2 = particle->Velocity.LengthSq;

                float h;
                if (velocity2 >= velocityThreshold2)
                {
                    h = VelocityHue;
                }
                else
                {
                    var t = (float)Math.Sqrt(velocity2) / VelocityThreshold;
                    h = MathHelper.Lerp(StationaryHue, VelocityHue, t);
                }
                particle->Colour = new Colour(h, particle->Colour.S, particle->Colour.L);
            }
        }
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            if (TimePass < VelocityChangeColor)
            {
                TimePass++;
            }
            else
            {
                TimePass = 0;
            }

            if (TimePass >= VelocityChangeColor)
            {
                useColour1 = !useColour1;
                TimePass   = 0;
            }

            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                particle->Colour = useColour1 ? Colour1 : Colour2;
            }
        }
Пример #14
0
 public abstract void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator);