/// <summary> /// Initializes the particle system. /// </summary> public void InitializeParticleSystem(ParticleSettingsComponent particleSettingsComponent) { //There should only exist one particleSettingsComponent, so we can safely get the first one from the dict settings = particleSettingsComponent; // Allocate the particle array, and fill in the corner fields (which never change). if (settings != null) { particles = new ParticleVertex[settings.MaximumParticles * 4]; for (int i = 0; i < settings.MaximumParticles; i++) { particles[i * 4 + 0].Corner = new Vector2(-1, -1); particles[i * 4 + 1].Corner = new Vector2(1, -1); particles[i * 4 + 2].Corner = new Vector2(1, 1); particles[i * 4 + 3].Corner = new Vector2(-1, 1); } } LoadContent(); }
public static Entity NewParticleSettingsEntity(Entity player, int maxParticles, float lifeSpan, string textureName) { Entity particles = player; ParticleSettingsComponent particleSettingsComponent = new ParticleSettingsComponent(particles) { AlphaBlendState = BlendState.Additive, EmitterVelocitySensitivity = 1, GravityDirection = Vector3.Up, MaximumParticles = maxParticles, MaxVelocity = 10, MinVelocity = 0, MinColor = new Color(255, 255, 255, 100), MaxColor = new Color(255, 255, 255, 100), ParticleLifeSpan = TimeSpan.FromSeconds(lifeSpan), MaxSize = 100, MinSize = 100, TextureName = textureName }; ComponentManager.Instance.AddComponentToEntity(particles, particleSettingsComponent); return(particles); }