RocketWeapon.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //-----------------------------------------------------------------------------
  2. // RocketWeapon.cs
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. using System;
  8. using Microsoft.Xna.Framework;
  9. namespace NetRumble
  10. {
  11. /// <summary>
  12. /// A weapon that shoots a rockets.
  13. /// </summary>
  14. public class RocketWeapon : Weapon
  15. {
  16. /// <summary>
  17. /// Constructs a new rocket-launching weapon.
  18. /// </summary>
  19. /// <param name="owner">The ship that owns this weapon.</param>
  20. public RocketWeapon(Ship owner)
  21. : base(owner)
  22. {
  23. fireDelay = 0.5f;
  24. // Pick one of the rocket sound variations for this instance.
  25. if (RandomMath.Random.Next(2) == 0)
  26. fireSoundEffect = "fire_rocket1";
  27. else
  28. fireSoundEffect = "fire_rocket2";
  29. }
  30. /// <summary>
  31. /// Create and spawn the projectile(s) from a firing from this weapon.
  32. /// </summary>
  33. /// <param name="direction">The direction that the projectile will move.</param>
  34. protected override void CreateProjectiles(Vector2 direction)
  35. {
  36. // create the new projectile
  37. RocketProjectile projectile = new RocketProjectile(owner, direction);
  38. projectile.Initialize();
  39. owner.Projectiles.Add(projectile);
  40. }
  41. }
  42. }