public ParticleSystem(LTexture defaultSprite, int maxParticles) { this.maxParticlesPerEmitter = maxParticles; sprite = defaultSprite; dummy = CreateParticle(this); }
public ParticleSystem(string defaultSpriteRef, int maxParticles, LColor mask) { this.maxParticlesPerEmitter = maxParticles; this.mask = mask; SetDefaultImageName(defaultSpriteRef); dummy = CreateParticle(this); }
public void UpdateParticle(Particle particle, long delta) { if (particle.GetLife() > 600) { particle.AdjustSize(0.07f * delta); } else { particle.AdjustSize(-0.04f * delta * (size / 40.0f)); } float c = 0.002f * delta; particle.AdjustColor(0, -c / 2, -c * 2, -c / 4); }
public void UpdateParticle(Particle particle, long delta) { particleCount++; particle.x += adjustx; particle.y += adjusty; particle.AdjustVelocity(windFactor.GetValue(0) * 0.00005f * delta, gravityFactor.GetValue(0) * 0.00005f * delta); float offset = particle.GetLife() / particle.GetOriginalLife(); float inv = 1 - offset; float colOffset = 0; float colInv = 1; LColor startColor = null; LColor endColor = null; for (int i = 0; i < colors.Count - 1; i++) { ColorRecord rec1 = (ColorRecord) colors[i]; ColorRecord rec2 = (ColorRecord) colors[i + 1]; if ((inv >= rec1.pos) && (inv <= rec2.pos)) { startColor = rec1.col; endColor = rec2.col; float step = rec2.pos - rec1.pos; colOffset = inv - rec1.pos; colOffset /= step; colOffset = 1 - colOffset; colInv = 1 - colOffset; } } if (startColor != null) { float r = (startColor.r * colOffset) + (endColor.r * colInv); float g = (startColor.g * colOffset) + (endColor.g * colInv); float b = (startColor.b * colOffset) + (endColor.b * colInv); float a; if (alpha.IsActive()) { a = alpha.GetValue(inv) / 255.0f; } else { a = ((startAlpha.GetValue(0) / 255.0f) * offset) + ((endAlpha.GetValue(0) / 255.0f) * inv); } particle.SetColor(r, g, b, a); } if (size.IsActive()) { float s = size.GetValue(inv); particle.SetSize(s); } else { particle.AdjustSize(delta * growthFactor.GetValue(0) * 0.001f); } if (velocity.IsActive()) { particle.SetSpeed(velocity.GetValue(inv)); } if (scaleY.IsActive()) { particle.SetScaleY(scaleY.GetValue(inv)); } }
public void Release(Particle particle) { if (particle != dummy) { ParticlePool pool = (ParticlePool)CollectionUtils.Get(particlesByEmitter, particle .GetEmitter()); pool.available.Add(particle); } }