LaserWeapon.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // LaserWeapon.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 single stream of laser projectiles.
  17. /// </summary>
  18. public class LaserWeapon : Weapon
  19. {
  20. #region Initialization Methods
  21. /// <summary>
  22. /// Constructs a new laser weapon.
  23. /// </summary>
  24. /// <param name="owner">The ship that owns this weapon.</param>
  25. public LaserWeapon(Ship owner)
  26. : base(owner)
  27. {
  28. fireDelay = 0.15f;
  29. // Pick one of the laser sound variations for this instance.
  30. switch (RandomMath.Random.Next(3))
  31. {
  32. case 0:
  33. fireSoundEffect = "fire_laser1";
  34. break;
  35. case 1:
  36. fireSoundEffect = "fire_laser2";
  37. break;
  38. case 2:
  39. fireSoundEffect = "fire_laser3";
  40. break;
  41. }
  42. }
  43. #endregion
  44. #region Interaction Methods
  45. /// <summary>
  46. /// Create and spawn the projectile(s) from a firing from this weapon.
  47. /// </summary>
  48. /// <param name="direction">The direction that the projectile will move.</param>
  49. protected override void CreateProjectiles(Vector2 direction)
  50. {
  51. // create the new projectile
  52. LaserProjectile projectile = new LaserProjectile(owner, direction);
  53. projectile.Initialize();
  54. owner.Projectiles.Add(projectile);
  55. }
  56. #endregion
  57. }
  58. }