FireParticleSystem.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // FireParticleSystem.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 Microsoft.Xna.Framework;
  12. using Microsoft.Xna.Framework.Content;
  13. using Microsoft.Xna.Framework.Graphics;
  14. #endregion
  15. namespace Particle3DSample
  16. {
  17. /// <summary>
  18. /// Custom particle system for creating a flame effect.
  19. /// </summary>
  20. class FireParticleSystem : ParticleSystem
  21. {
  22. public FireParticleSystem(Game game, ContentManager content)
  23. : base(game, content)
  24. { }
  25. protected override void InitializeSettings(ParticleSettings settings)
  26. {
  27. settings.TextureName = "fire";
  28. settings.MaxParticles = 2400;
  29. settings.Duration = TimeSpan.FromSeconds(2);
  30. settings.DurationRandomness = 1;
  31. settings.MinHorizontalVelocity = 0;
  32. settings.MaxHorizontalVelocity = 15;
  33. settings.MinVerticalVelocity = -10;
  34. settings.MaxVerticalVelocity = 10;
  35. // Set gravity upside down, so the flames will 'fall' upward.
  36. settings.Gravity = new Vector3(0, 15, 0);
  37. settings.MinColor = new Color(255, 255, 255, 10);
  38. settings.MaxColor = new Color(255, 255, 255, 40);
  39. settings.MinStartSize = 5;
  40. settings.MaxStartSize = 10;
  41. settings.MinEndSize = 10;
  42. settings.MaxEndSize = 40;
  43. // Use additive blending.
  44. settings.BlendState = BlendState.Additive;
  45. }
  46. }
  47. }