コード例 #1
0
ファイル: LaserWeapon.cs プロジェクト: Nailz/MonoGame-Samples
 /// <summary>
 /// Create and spawn the projectile(s) from a firing from this weapon.
 /// </summary>
 /// <param name="direction">The direction that the projectile will move.</param>
 protected override void CreateProjectiles(Vector2 direction)
 {
     // create the new projectile
     LaserProjectile projectile = new LaserProjectile(owner, direction);
     projectile.Initialize();
     owner.Projectiles.Add(projectile);
 }
コード例 #2
0
        /// <summary>
        /// Create and spawn the projectile(s) from a firing from this weapon.
        /// </summary>
        /// <param name="direction">The direction that the projectile will move.</param>
        protected override void CreateProjectiles(Vector2 direction)
        {
            // calculate the direction vectors for the second and third projectiles
            float rotation = (float)Math.Acos(Vector2.Dot(new Vector2(0f, -1f),
                                                          direction));

            rotation *= (Vector2.Dot(new Vector2(0f, -1f),
                                     new Vector2(direction.Y, -direction.X)) > 0f) ? 1f : -1f;
            Vector2 direction2 = new Vector2(
                (float)Math.Sin(rotation - laserSpreadRadians),
                -(float)Math.Cos(rotation - laserSpreadRadians));
            Vector2 direction3 = new Vector2(
                (float)Math.Sin(rotation + laserSpreadRadians),
                -(float)Math.Cos(rotation + laserSpreadRadians));

            // create the first projectile
            LaserProjectile projectile = new LaserProjectile(owner,
                                                             direction);

            projectile.Initialize();
            owner.Projectiles.Add(projectile);

            // create the second projectile
            projectile = new LaserProjectile(owner, direction2);
            projectile.Initialize();
            owner.Projectiles.Add(projectile);

            // create the third projectile
            projectile = new LaserProjectile(owner, direction3);
            projectile.Initialize();
            owner.Projectiles.Add(projectile);
        }
コード例 #3
0
        /// <summary>
        /// Create and spawn the projectile(s) from a firing from this weapon.
        /// </summary>
        /// <param name="direction">The direction that the projectile will move.</param>
        protected override void CreateProjectiles(Vector2 direction)
        {
            // calculate the direction vectors for the second and third projectiles
            float rotation = (float)Math.Acos(Vector2.Dot(new Vector2(0f, -1f), 
                direction));
            rotation *= (Vector2.Dot(new Vector2(0f, -1f), 
                new Vector2(direction.Y, -direction.X)) > 0f) ? 1f : -1f;
            Vector2 direction2 = new Vector2(
                 (float)Math.Sin(rotation - laserSpreadRadians), 
                -(float)Math.Cos(rotation - laserSpreadRadians));
            Vector2 direction3 = new Vector2(
                 (float)Math.Sin(rotation + laserSpreadRadians), 
                -(float)Math.Cos(rotation + laserSpreadRadians));

            // create the first projectile
            LaserProjectile projectile = new LaserProjectile(owner,
                direction);
            projectile.Initialize();
            owner.Projectiles.Add(projectile);

            // create the second projectile
            projectile = new LaserProjectile(owner, direction2);
            projectile.Initialize();
            owner.Projectiles.Add(projectile);

            // create the third projectile
            projectile = new LaserProjectile(owner, direction3);
            projectile.Initialize();
            owner.Projectiles.Add(projectile);
        }
コード例 #4
0
        /// <summary>
        /// Create and spawn the projectile(s) from a firing from this weapon.
        /// </summary>
        /// <param name="direction">The direction that the projectile will move.</param>
        protected override void CreateProjectiles(Vector2 direction)
        {
            // create the new projectile
            LaserProjectile projectile = new LaserProjectile(owner, direction);

            projectile.Initialize();
            owner.Projectiles.Add(projectile);
        }
コード例 #5
0
        /// <summary>
        /// Create and spawn the projectile(s) from a firing from this weapon.
        /// </summary>
        /// <param name="direction">The direction that the projectile will move.</param>
        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;
        }
コード例 #6
0
        /// <summary>
        /// Create and spawn the projectile(s) from a firing from this weapon.
        /// </summary>
        /// <param name="direction">The direction that the projectile will move.</param>
        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;
        }