// Randomizes some properties for a particle, then calls Initialize on it. // This can be overriden by subclasses if they want to modify the way particles // are created. For example, SmokePlumeParticleSystem overrides this function // make all particles accelerate to the right, simulating wind. protected virtual void InitializeParticle(Particle particle, Vector2 where) { // First, call PickRandomDirection to figure out which way the particle // will be moving. Velocity and acceleration values will come from this. Vector2 direction = PickRandomDirection(); // Pick some random values for our particle. float velocity = Utils.RandomBetween(minInitialSpeed, maxInitialSpeed); float acceleration = Utils.RandomBetween(minAcceleration, maxAcceleration); float lifetime = Utils.RandomBetween(minLifetime, maxLifetime); float scale = Utils.RandomBetween(minScale, maxScale); float rotationSpeed = Utils.RandomBetween(minRotationSpeed, maxRotationSpeed); // Then initialize the particle with these random values. particle.Initialize(where, velocity * direction, acceleration * direction, lifetime, scale, rotationSpeed); }