Пример #1
0
        public void ChangeParticleSpeed(ParticleEngine.ParticleEffect p, GameTime gameTime)
        {
            double now = gameTime.TotalGameTime.TotalMilliseconds;

            for (int i = 0; i < p.particleList.Count; i++)
            {
                float timeAlive = (float)(now - p.particleList[i].BirthTime);
                if (!p.particleList[i].isModified)
                {
                    p.particleList[i].Direction *= new Vector2(p.particleList[i].Scaling - 0.33f, p.particleList[i].Scaling - 0.33f);
                    p.particleList[i].isModified = true;
                }
            }
        }
Пример #2
0
        public void ChangeParticleStress(ParticleEngine.ParticleEffect p, GameTime gameTime)
        {
            double now = gameTime.TotalGameTime.TotalMilliseconds;

            for (int i = 0; i < p.particleList.Count; i++)
            {
                float timeAlive = (float)(now - p.particleList[i].BirthTime);
                if (!p.particleList[i].isModified)
                {
                    float r = p.VectorToAngle(p.particleList[i].Direction);
                    r += (float)Math.PI;         // add a bit to the angle for the acceleration so that the particle curves in its trajectory
                    if (r > Math.PI * 2)         // make sure the acceleration doesn't exceed the full range of a circle
                    {
                        r -= (float)Math.PI * 2;
                    }
                    p.particleList[i].Acceleration = p.AngleToVector(r);
                    p.particleList[i].isModified   = true;
                }
                if (timeAlive / p.particleList[i].Life > 0.70f)                 // make the particle phase out in a not so ugly way
                {
                    p.particleList[i].ModColor = Color.Lerp(Color.DarkBlue, new Color(Color.DarkBlue, 0.0f), (timeAlive / p.particleList[i].Life));
                }
            }
            if (sourceEmitter.Left <= bounds.Left || sourceEmitter.Right >= bounds.Right)
            {
                motion.X = -motion.X;
            }
            if (sourceEmitter.Top <= bounds.Top || sourceEmitter.Bottom >= bounds.Bottom)
            {
                motion.Y = -motion.Y;
            }
            sourceEmitter.X += (int)(motion.X * 13);
            sourceEmitter.Y += (int)(motion.Y * 13);
            p.Emitter        = sourceEmitter;

            if (isAdding)
            {
                p.NumberOfParticles += 10;
            }
            if (isSubtracting && p.NumberOfParticles > 20)
            {
                p.NumberOfParticles -= 10;
            }

            isSubtracting = false;
            isAdding      = false;
        }
Пример #3
0
        public void ChangeParticleColors(ParticleEngine.ParticleEffect p, GameTime gameTime)
        {
            double now = gameTime.TotalGameTime.TotalMilliseconds;

            for (int i = 0; i < p.particleList.Count; i++)
            {
                float timeAlive = (float)(now - p.particleList[i].BirthTime);
                if (timeAlive / p.particleList[i].Life < 0.85f)
                {
                    p.particleList[i].ModColor = Color.Lerp(new Color(255, 120, 40, 255), new Color(255, 120, 40, 125), (timeAlive / p.particleList[i].Life));
                }
                if (timeAlive / p.particleList[i].Life >= 0.85f)
                {
                    p.particleList[i].ModColor = Color.Lerp(new Color(255, 120, 40, 255), new Color(Color.DarkOrange, 0), (timeAlive / p.particleList[i].Life));
                }
            }
        }