ExplosionSmokeParticleSystem.cs 2.6 KB

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