ExplosionSmokeParticleSystem.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //-----------------------------------------------------------------------------
  2. // ExplosionSmokeParticleSystem.cs
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. using Microsoft.Xna.Framework;
  11. using Microsoft.Xna.Framework.Graphics;
  12. namespace ParticleSample
  13. {
  14. /// <summary>
  15. /// ExplosionSmokeParticleSystem is a specialization of ParticleSystem which
  16. /// creates a circular pattern of smoke. It should be combined with
  17. /// ExplosionParticleSystem for best effect.
  18. /// </summary>
  19. public class ExplosionSmokeParticleSystem : ParticleSystem
  20. {
  21. public ExplosionSmokeParticleSystem(ParticleSampleGame game, int howManyEffects)
  22. : base(game, howManyEffects)
  23. {
  24. }
  25. /// <summary>
  26. /// Set up the constants that will give this particle system its behavior and
  27. /// properties.
  28. /// </summary>
  29. protected override void InitializeConstants()
  30. {
  31. textureFilename = "smoke";
  32. // less initial speed than the explosion itself
  33. minInitialSpeed = 20;
  34. maxInitialSpeed = 200;
  35. // acceleration is negative, so particles will accelerate away from the
  36. // initial velocity. this will make them slow down, as if from wind
  37. // resistance. we want the smoke to linger a bit and feel wispy, though,
  38. // so we don't stop them completely like we do ExplosionParticleSystem
  39. // particles.
  40. minAcceleration = -10;
  41. maxAcceleration = -50;
  42. // explosion smoke lasts for longer than the explosion itself, but not
  43. // as long as the plumes do.
  44. minLifetime = 1.0f;
  45. maxLifetime = 2.5f;
  46. minScale = 1.0f;
  47. maxScale = 2.0f;
  48. // we need to reduce the number of particles on Windows Phone in order to keep
  49. // a good framerate
  50. #if WINDOWS_PHONE
  51. minNumParticles = 5;
  52. maxNumParticles = 10;
  53. #else
  54. minNumParticles = 10;
  55. maxNumParticles = 20;
  56. #endif
  57. minRotationSpeed = -MathHelper.PiOver4;
  58. maxRotationSpeed = MathHelper.PiOver4;
  59. blendState = BlendState.AlphaBlend;
  60. DrawOrder = AlphaBlendDrawOrder;
  61. }
  62. }
  63. }