public void AddFractionalParticle(Vector2 position, Particle prototype) { Particle particle = prototype.Clone(); particle.Position = position; particle.Angle = particle.Direction; particles.Add(particle); }
public void AddParticle(Vector2 position, Particle prototype, ParticleTextureType textureType) { Particle particle = prototype.Clone(); particle.Texture = particleTextures[textureType]; particle.Position = position; particle.Angle = particle.Direction; particles.Add(particle); }
public void LoadContent() { #region Load textures Texture2D tempParticle = OGE.Content.Load<Texture2D>(@"Graphics\Particles\BlurParticle"); particleTextures.Add(ParticleTextureType.BlurredCircle, tempParticle); tempParticle = OGE.Content.Load<Texture2D>(@"Graphics\Particles\FireParticle"); particleTextures.Add(ParticleTextureType.BlurredFire, tempParticle); tempParticle = OGE.Content.Load<Texture2D>(@"Graphics\Particles\LineParticle"); particleTextures.Add(ParticleTextureType.BlurredLine, tempParticle); tempParticle = OGE.Content.Load<Texture2D>(@"Graphics\Particles\BlurSquare"); particleTextures.Add(ParticleTextureType.BlurredSquare, tempParticle); #endregion #region Load Patterns ParticlePattern doubleCircleDoubleLayerPattern = new ParticlePattern(100); ParticlePattern doubleLayerCirclePattern = new ParticlePattern(100); ParticlePattern circlePattern = new ParticlePattern(100); ParticlePattern doubleCirclePattern = new ParticlePattern(100); Particle temp; Particle cloneTemp; float direction; for (int i = 0; i < 25; i++) { direction = random.Next(360); temp = new Particle(); temp.Direction = direction; temp.Angle = direction; temp.DeltaSpeed = -0.5f; temp.DeltaScale = -0.02f; doubleCircleDoubleLayerPattern.Particles[2 * i] = temp; doubleCircleDoubleLayerPattern.Particles[2 * i + 1] = temp; doubleLayerCirclePattern.Particles[2 * i] = temp; doubleLayerCirclePattern.Particles[2 * i + 1] = temp; direction = random.Next(360); cloneTemp = temp.Clone(); cloneTemp.Direction = direction; cloneTemp.Angle = direction; circlePattern.Particles[2 * i] = temp; circlePattern.Particles[2 * i + 1] = cloneTemp; doubleCirclePattern.Particles[2 * i] = temp; doubleCirclePattern.Particles[2 * i + 1] = cloneTemp; } for (int i = 25; i < 50; i++) { direction = random.Next(360); temp = new Particle(); temp.Position.X = (float)(50 * Math.Cos(MathHelper.ToRadians(direction))); temp.Position.Y = (float)(50 * Math.Sin(MathHelper.ToRadians(direction))); temp.Direction = direction; temp.Angle = direction; temp.DeltaSpeed = -0.4f; temp.DeltaScale = -0.02f; doubleCircleDoubleLayerPattern.Particles[2 * i] = temp; doubleCircleDoubleLayerPattern.Particles[2 * i + 1] = temp; cloneTemp = temp.Clone(); cloneTemp.Position.X = 0; cloneTemp.Position.Y = 0; doubleLayerCirclePattern.Particles[2 * i] = cloneTemp; doubleLayerCirclePattern.Particles[2 * i + 1] = cloneTemp; circlePattern.Particles[2 * i] = cloneTemp; direction = random.Next(360); cloneTemp = temp.Clone(); cloneTemp.Direction = direction; cloneTemp.Angle = direction; doubleCirclePattern.Particles[2 * i] = temp; doubleCirclePattern.Particles[2 * i + 1] = cloneTemp; cloneTemp = cloneTemp.Clone(); cloneTemp.Position.X = 0; cloneTemp.Position.Y = 0; circlePattern.Particles[2 * i + 1] = cloneTemp; } patterns.Add(ParticlePatternType.DoubleCircleDoubleLayerCirclePattern, doubleCircleDoubleLayerPattern); patterns.Add(ParticlePatternType.DoubleLayerCirclePattern, doubleLayerCirclePattern); patterns.Add(ParticlePatternType.CirclePattern, circlePattern); patterns.Add(ParticlePatternType.DoubleCirclePattern, doubleCirclePattern); #endregion }