#region File Description
//-----------------------------------------------------------------------------
// DoubleLaserWeapon.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion
#region Using Statements
using System;
using Microsoft.Xna.Framework;
#endregion
namespace NetRumble
{
///
/// A weapon that shoots a double stream of laser projectiles.
///
public class DoubleLaserWeapon : LaserWeapon
{
#region Constants
///
/// The distance that the laser bolts are moved off of the owner's position.
///
const float laserSpread = 8f;
#endregion
#region Initialization Methods
///
/// Constructs a new double-laser weapon.
///
/// The ship that owns this weapon.
public DoubleLaserWeapon(Ship owner)
: base(owner) { }
#endregion
#region Interaction Methods
///
/// Create and spawn the projectile(s) from a firing from this weapon.
///
/// The direction that the projectile will move.
protected override void CreateProjectiles(Vector2 direction)
{
// calculate the spread of the laser bolts
Vector2 cross = Vector2.Multiply(new Vector2(-direction.Y, direction.X),
laserSpread);
// create the new projectile
LaserProjectile projectile = new LaserProjectile(owner,
direction);
projectile.Initialize();
owner.Projectiles.Add(projectile);
// adjust the position for the laser spread
projectile.Position += cross;
// create the second projectile
projectile = new LaserProjectile(owner, direction);
projectile.Initialize();
owner.Projectiles.Add(projectile);
// adjust the position for the laser spread
projectile.Position -= cross;
}
#endregion
}
}