C# Class TuneBlaster_.ParticleSystem

ParticleSystem is an abstract class that provides the basic functionality to create a particle effect.
Inheritance: Microsoft.Xna.Framework.DrawableGameComponent
Datei anzeigen Open project: kiniry-teaching/UCD

Protected Properties

Property Type Description
maxAcceleration float
maxInitialSpeed float
maxLifetime float
maxNumParticles int
maxRotationSpeed float
maxScale float
minAcceleration float
minInitialSpeed float
minLifetime float
minNumParticles int
minRotationSpeed float
minScale float
spriteBlendMode SpriteBlendMode
textureFilename string

Public Methods

Method Description
AddParticles ( Vector2 where ) : void

AddParticles's job is to add an effect somewhere on the screen. If there aren't enough particles in the freeParticles queue, it will use as many as it can. This means that if there not enough particles available, calling AddParticles will have no effect.

Draw ( GameTime gameTime ) : void

overriden from DrawableGameComponent, Draw will use Engine's sprite batch to render all of the active particles.

Initialize ( ) : void

override the base class's Initialize to do some additional work; we want to call InitializeConstants to let subclasses set the constants that will be used. also, the particle array and freeParticles queue are set up here.

Update ( GameTime gameTime ) : void

overriden from DrawableGameComponent, Update will update all of the active particles.

Protected Methods

Method Description
InitializeConstants ( ) : void
InitializeParticle ( Particle p, Vector2 where ) : void
LoadContent ( ) : void

Override the base class LoadContent to load the texture. once it's loaded, calculate the origin.

ParticleSystem ( Engine game, int howManyEffects ) : System

Constructs a new ParticleSystem.

PickRandomDirection ( ) : Vector2

PickRandomDirection is used by InitializeParticles to decide which direction particles will move. The default implementation is a random vector in a circular pattern.

Method Details

AddParticles() public method

AddParticles's job is to add an effect somewhere on the screen. If there aren't enough particles in the freeParticles queue, it will use as many as it can. This means that if there not enough particles available, calling AddParticles will have no effect.
public AddParticles ( Vector2 where ) : void
where Vector2 where the particle effect should be created
return void

Draw() public method

overriden from DrawableGameComponent, Draw will use Engine's sprite batch to render all of the active particles.
public Draw ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime
return void

Initialize() public method

override the base class's Initialize to do some additional work; we want to call InitializeConstants to let subclasses set the constants that will be used. also, the particle array and freeParticles queue are set up here.
public Initialize ( ) : void
return void

InitializeConstants() protected abstract method

protected abstract InitializeConstants ( ) : void
return void

InitializeParticle() protected method

protected InitializeParticle ( Particle p, Vector2 where ) : void
p Particle the particle to initialize
where Vector2 the position on the screen that the particle should be ///
return void

LoadContent() protected method

Override the base class LoadContent to load the texture. once it's loaded, calculate the origin.
protected LoadContent ( ) : void
return void

ParticleSystem() protected method

Constructs a new ParticleSystem.
protected ParticleSystem ( Engine game, int howManyEffects ) : System
game Engine The host for this particle system. The game keeps the /// content manager and sprite batch for us.
howManyEffects int the maximum number of particle effects that /// are expected on screen at once.
return System

PickRandomDirection() protected method

PickRandomDirection is used by InitializeParticles to decide which direction particles will move. The default implementation is a random vector in a circular pattern.
protected PickRandomDirection ( ) : Vector2
return Vector2

Update() public method

overriden from DrawableGameComponent, Update will update all of the active particles.
public Update ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime
return void

Property Details

maxAcceleration protected_oe property

protected float maxAcceleration
return float

maxInitialSpeed protected_oe property

protected float maxInitialSpeed
return float

maxLifetime protected_oe property

protected float maxLifetime
return float

maxNumParticles protected_oe property

protected int maxNumParticles
return int

maxRotationSpeed protected_oe property

protected float maxRotationSpeed
return float

maxScale protected_oe property

protected float maxScale
return float

minAcceleration protected_oe property

minAcceleration and maxAcceleration are used to control the acceleration of the particles. The particle's acceleration will be a random number between these two. By default, the direction of acceleration is the same as the direction of the initial velocity.
protected float minAcceleration
return float

minInitialSpeed protected_oe property

minInitialSpeed and maxInitialSpeed are used to control the initial velocity of the particles. The particle's initial speed will be a random number between these two. The direction is determined by the function PickRandomDirection, which can be overriden.
protected float minInitialSpeed
return float

minLifetime protected_oe property

minLifetime and maxLifetime are used to control the lifetime. Each particle's lifetime will be a random number between these two. Lifetime is used to determine how long a particle "lasts." Also, in the base implementation of Draw, lifetime is also used to calculate alpha and scale values to avoid particles suddenly "popping" into view
protected float minLifetime
return float

minNumParticles protected_oe property

minNumParticles and maxNumParticles control the number of particles that are added when AddParticles is called. The number of particles will be a random number between minNumParticles and maxNumParticles.
protected int minNumParticles
return int

minRotationSpeed protected_oe property

minRotationSpeed and maxRotationSpeed control the particles' angular velocity: the speed at which particles will rotate. Each particle's rotation speed will be a random number between minRotationSpeed and maxRotationSpeed. Use smaller numbers to make particle systems look calm and wispy, and large numbers for more violent effects.
protected float minRotationSpeed
return float

minScale protected_oe property

to get some additional variance in the appearance of the particles, we give them all random scales. the scale is a value between minScale and maxScale, and is additionally affected by the particle's lifetime to avoid particles "popping" into view.
protected float minScale
return float

spriteBlendMode protected_oe property

different effects can use different blend modes. fire and explosions work well with additive blending, for example.
protected SpriteBlendMode spriteBlendMode
return SpriteBlendMode

textureFilename protected_oe property

this controls the texture that the particle system uses. It will be used as an argument to ContentManager.Load.
protected string textureFilename
return string