RocketWeapon.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // RocketWeapon.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. #endregion
  13. namespace NetRumble
  14. {
  15. /// <summary>
  16. /// A weapon that shoots a rockets.
  17. /// </summary>
  18. public class RocketWeapon : Weapon
  19. {
  20. #region Initialization Methods
  21. /// <summary>
  22. /// Constructs a new rocket-launching weapon.
  23. /// </summary>
  24. /// <param name="owner">The ship that owns this weapon.</param>
  25. public RocketWeapon(Ship owner)
  26. : base(owner)
  27. {
  28. fireDelay = 0.5f;
  29. // Pick one of the rocket sound variations for this instance.
  30. if (RandomMath.Random.Next(2) == 0)
  31. fireSoundEffect = "fire_rocket1";
  32. else
  33. fireSoundEffect = "fire_rocket2";
  34. }
  35. #endregion
  36. #region Interaction Methods
  37. /// <summary>
  38. /// Create and spawn the projectile(s) from a firing from this weapon.
  39. /// </summary>
  40. /// <param name="direction">The direction that the projectile will move.</param>
  41. protected override void CreateProjectiles(Vector2 direction)
  42. {
  43. // create the new projectile
  44. RocketProjectile projectile = new RocketProjectile(owner, direction);
  45. projectile.Initialize();
  46. owner.Projectiles.Add(projectile);
  47. }
  48. #endregion
  49. }
  50. }