/// <summary> /// Emits a single particle, as long as one is available in the emitter group. /// </summary> /// <returns>True if a particle was emitted, false if not.</returns> public bool EmitParticle() { _currentParticle = GetFirstAvailable() as GenParticle; if (_currentParticle != null) { // Give the particle a random x and y position, keeping the center of the particle's bounding box within the bounding box of the emitter. _currentParticle.X = GenU.Random((int)(_bounds.Left - _currentParticle.Bounds.HalfWidth), (int)(_bounds.Right + _currentParticle.Bounds.HalfWidth + 1)); _currentParticle.Y = GenU.Random((int)(_bounds.Top - _currentParticle.Bounds.HalfHeight), (int)(_bounds.Bottom + _currentParticle.Bounds.HalfHeight + 1)); _currentParticle.Velocity.X = GenU.Random(MinParticleSpeedX, MaxParticleSpeedX + 1); _currentParticle.Velocity.Y = GenU.Random(MinParticleSpeedY, MaxParticleSpeedY + 1); if ((Parent != null) && InheritVelocity) _currentParticle.Velocity += Parent.Velocity; _currentParticle.Rotation = GenU.Random(MinRotation, MaxRotation + 1); _currentParticle.RotationSpeed = GenU.Random(MinRotationSpeed, MaxRotationSpeed + 1); _currentParticle.Color = (Colors.Count > 0) ? Colors[0] : Color.White; _currentParticle.Alpha = StartAlpha; _currentParticle.Scale.X = _currentParticle.Scale.Y = StartScale; _currentParticle.Reset(); return true; } return false; }
/// <summary> /// Adds a particle to the emitter group to be used be the emitter. /// </summary> /// <param name="particle">The particle to add to the emitter group.</param> /// <returns>The particle that was added to the emitter group.</returns> public GenParticle Add(GenParticle particle) { particle.Kill(); base.Add(particle); return particle; }