DoubleLaserWeapon.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // DoubleLaserWeapon.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 double stream of laser projectiles.
  17. /// </summary>
  18. public class DoubleLaserWeapon : LaserWeapon
  19. {
  20. #region Constants
  21. /// <summary>
  22. /// The distance that the laser bolts are moved off of the owner's position.
  23. /// </summary>
  24. const float laserSpread = 8f;
  25. #endregion
  26. #region Initialization Methods
  27. /// <summary>
  28. /// Constructs a new double-laser weapon.
  29. /// </summary>
  30. /// <param name="owner">The ship that owns this weapon.</param>
  31. public DoubleLaserWeapon(Ship owner)
  32. : base(owner) { }
  33. #endregion
  34. #region Interaction Methods
  35. /// <summary>
  36. /// Create and spawn the projectile(s) from a firing from this weapon.
  37. /// </summary>
  38. /// <param name="direction">The direction that the projectile will move.</param>
  39. protected override void CreateProjectiles(Vector2 direction)
  40. {
  41. // calculate the spread of the laser bolts
  42. Vector2 cross = Vector2.Multiply(new Vector2(-direction.Y, direction.X),
  43. laserSpread);
  44. // create the new projectile
  45. LaserProjectile projectile = new LaserProjectile(owner,
  46. direction);
  47. projectile.Initialize();
  48. owner.Projectiles.Add(projectile);
  49. // adjust the position for the laser spread
  50. projectile.Position += cross;
  51. // create the second projectile
  52. projectile = new LaserProjectile(owner, direction);
  53. projectile.Initialize();
  54. owner.Projectiles.Add(projectile);
  55. // adjust the position for the laser spread
  56. projectile.Position -= cross;
  57. }
  58. #endregion
  59. }
  60. }