Esempio n. 1
0
 public void Update(ParticleSystem system, long delta)
 {
     timer -= delta;
     if (timer <= 0)
     {
         timer = interval;
         Particle p = system.GetNewParticle(this, 1000);
         p.SetColor(1, 1, 1, 0.5f);
         p.SetPosition(x, y);
         p.SetSize(size);
         float vx = (-0.02f + (MathUtils.Random() * 0.04f));
         float vy = (-(MathUtils.Random() * 0.15f));
         p.SetVelocity(vx, vy, 1.1f);
     }
 }
Esempio n. 2
0
 public void Update(ParticleSystem system, long delta)
 {
     timer -= delta;
     if (timer <= 0)
     {
         timer = interval;
         Particle p = system.GetNewParticle(this, 1000);
         p.SetColor(1, 1, 1, 0.5f);
         p.SetPosition(x, y);
         p.SetSize(size);
         float vx = (-0.02f + (MathUtils.Random() * 0.04f));
         float vy = (-(MathUtils.Random() * 0.15f));
         p.SetVelocity(vx, vy, 1.1f);
     }
 }
Esempio n. 3
0
        public void Update(ParticleSystem system, long delta)
        {
            this.engine = system;

            if (!adjust)
            {
                adjustx = 0;
                adjusty = 0;
            }
            else
            {
                adjust = false;
            }

            if (updateImage)
            {
                updateImage = false;
                string name = (relativePath + imageName).Trim();
                if (name.Length > 0)
                {
                    try {
                        image = LTextures.LoadTexture(name);
                    } catch (Exception e) {
                        image = null;
                        Log.Exception(e);
                    }
                }
            }

            if ((wrapUp) || ((length.IsEnabled()) && (timeout < 0)) ||
                ((emitCount.IsEnabled() && (leftToEmit <= 0))))
            {
                if (particleCount == 0)
                {
                    completed = true;
                }
            }
            particleCount = 0;

            if (wrapUp)
            {
                return;
            }

            if (length.IsEnabled())
            {
                if (timeout < 0)
                {
                    return;
                }
                timeout -= delta;
            }
            if (emitCount.IsEnabled())
            {
                if (leftToEmit <= 0)
                {
                    return;
                }
            }

            nextSpawn -= delta;
            if (nextSpawn < 0)
            {
                nextSpawn = (int)spawnInterval.Random();
                int count = (int)spawnCount.Random();

                for (int i = 0; i < count; i++)
                {
                    Particle p = system.GetNewParticle(this, initialLife.Random());
                    p.SetSize(initialSize.Random());
                    p.SetPosition(x + xOffset.Random(), y + yOffset.Random());
                    p.SetVelocity(0, 0, 0);

                    float dist  = initialDistance.Random();
                    float power = speed.Random();
                    if ((dist != 0) || (power != 0))
                    {
                        float s   = spread.GetValue(0);
                        float ang = (s + angularOffset.GetValue(0) - (spread
                                                                      .GetValue() / 2)) - 90;
                        float xa = MathUtils.Cos(MathUtils.ToRadians(ang)) * dist;
                        float ya = MathUtils.Sin(MathUtils.ToRadians(ang)) * dist;
                        p.AdjustPosition(xa, ya);

                        float xv = MathUtils.Cos(MathUtils.ToRadians(ang));
                        float yv = MathUtils.Sin(MathUtils.ToRadians(ang));
                        p.SetVelocity(xv, yv, power * 0.001f);
                    }

                    if (image != null)
                    {
                        p.SetImage(image);
                    }

                    ColorRecord start = (ColorRecord)colors[0];
                    p.SetColor(start.col.r, start.col.g, start.col.b,
                               startAlpha.GetValue(0) / 255.0f);
                    p.SetUsePoint(usePoints);
                    p.SetOriented(useOriented);

                    if (emitCount.IsEnabled())
                    {
                        leftToEmit--;
                        if (leftToEmit <= 0)
                        {
                            break;
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        public void Update(ParticleSystem system, long delta)
        {
            this.engine = system;

            if (!adjust) {
            adjustx = 0;
            adjusty = 0;
            } else {
            adjust = false;
            }

            if (updateImage) {
            updateImage = false;
            string name = (relativePath + imageName).Trim();
            if (name.Length > 0) {
                try {
                    image = LTextures.LoadTexture(name);
                } catch (Exception e) {
                    image = null;
                    Log.Exception(e);
                }
            }
            }

            if ((wrapUp) || ((length.IsEnabled()) && (timeout < 0))
                || ((emitCount.IsEnabled() && (leftToEmit <= 0)))) {
            if (particleCount == 0) {
                completed = true;
            }
            }
            particleCount = 0;

            if (wrapUp) {
            return;
            }

            if (length.IsEnabled()) {
            if (timeout < 0) {
                return;
            }
            timeout -= delta;
            }
            if (emitCount.IsEnabled()) {
            if (leftToEmit <= 0) {
                return;
            }
            }

            nextSpawn -= delta;
            if (nextSpawn < 0) {
            nextSpawn = (int) spawnInterval.Random();
            int count = (int) spawnCount.Random();

            for (int i = 0; i < count; i++) {
                Particle p = system.GetNewParticle(this, initialLife.Random());
                p.SetSize(initialSize.Random());
                p.SetPosition(x + xOffset.Random(), y + yOffset.Random());
                p.SetVelocity(0, 0, 0);

                float dist = initialDistance.Random();
                float power = speed.Random();
                if ((dist != 0) || (power != 0)) {
                    float s = spread.GetValue(0);
                    float ang = (s + angularOffset.GetValue(0) - (spread
                            .GetValue() / 2)) - 90;
                    float xa = MathUtils.Cos(MathUtils.ToRadians(ang)) * dist;
                    float ya = MathUtils.Sin(MathUtils.ToRadians(ang)) * dist;
                    p.AdjustPosition(xa, ya);

                    float xv = MathUtils.Cos(MathUtils.ToRadians(ang));
                    float yv = MathUtils.Sin(MathUtils.ToRadians(ang));
                    p.SetVelocity(xv, yv, power * 0.001f);
                }

                if (image != null) {
                    p.SetImage(image);
                }

                ColorRecord start = (ColorRecord) colors[0];
                p.SetColor(start.col.r, start.col.g, start.col.b,
                        startAlpha.GetValue(0) / 255.0f);
                p.SetUsePoint(usePoints);
                p.SetOriented(useOriented);

                if (emitCount.IsEnabled()) {
                    leftToEmit--;
                    if (leftToEmit <= 0) {
                        break;
                    }
                }
            }
            }
        }