MineWeapon.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // MineWeapon.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 fires a single mine on a long timer.
  17. /// </summary>
  18. public class MineWeapon : Weapon
  19. {
  20. #region Constants
  21. /// <summary>
  22. /// The distance that the mine spawns behind the ship.
  23. /// </summary>
  24. const float mineSpawnDistance = 8f;
  25. #endregion
  26. #region Initialization Methods
  27. /// <summary>
  28. /// Constructs a new mine-laying weapon.
  29. /// </summary>
  30. /// <param name="owner">The ship that owns this weapon.</param>
  31. public MineWeapon(Ship owner)
  32. : base(owner)
  33. {
  34. fireDelay = 2f;
  35. }
  36. #endregion
  37. #region Interaction Methods
  38. /// <summary>
  39. /// Create and spawn the projectile(s) from a firing from this weapon.
  40. /// </summary>
  41. /// <param name="direction">The direction that the projectile will move.</param>
  42. protected override void CreateProjectiles(Vector2 direction)
  43. {
  44. // create the new projectile
  45. MineProjectile projectile = new MineProjectile(owner, direction);
  46. projectile.Initialize();
  47. owner.Projectiles.Add(projectile);
  48. // move the mine out from the ship
  49. projectile.Position = owner.Position +
  50. direction * (owner.Radius + projectile.Radius + mineSpawnDistance);
  51. }
  52. #endregion
  53. }
  54. }