public Projectile Shoot(Projectile.ProjectileType pt, Direction d)
        {
            Point projectileLocation = new Point(Sprite.Location.X + (Sprite.Width / 2), Sprite.Location.Y + (Sprite.Height / 2));
            Projectile pr = new Projectile();
            switch (pt)
            {
                case Projectile.ProjectileType.Bullet:
                    pr = new Bullet(this, projectileLocation);
                    pr.Direction = d;
                    pr.SetController(controller);
                    pr.StartMoving();
                    break;

                case Projectile.ProjectileType.Laser:
                    if (d != Direction.Stop)
                    {
                        pr = new Laser(this, projectileLocation, d);
                        pr.SetController(controller);
                        pr.StartMoving();
                    }
                    break;

                //case Projectile.ProjectileType.Missile:
                //    pr = new Missile(this, projectileLocation, GetRandomEnemy(this));
                //    pr.SetController(controller);
                //    pr.StartMoving();
                //    break;
            }
            return pr;
        }
Example #2
0
 private void AddProjectile(Vector2 position)
 {
     Laser projectile = new Laser();
     projectile.Initialize(GraphicsDevice.Viewport, projectileTexture, position);
     projectiles.Add(projectile);
 }
Example #3
0
        /// <summary>
        /// Add a laser on the screen
        /// </summary>
        private void AddLaser()
        {
            Animation laserAnimation = new Animation();

            //initialize animation
            laserAnimation.Initialize(
                laserTexture,
                player.Position,
                46, 16,
                1,
                30,
                Color.White,
                1f,
                true);

            //Get player position and offset with cannon image position
            Vector2 laserPosition = player.Position;
            laserPosition.X += 37;

            //Initialize the laser and add it to the list
            Laser laser = new Laser();
            laser.Initialize(laserAnimation, laserPosition);
            laserBeams.Add(laser);
        }