Exemplo n.º 1
0
        /// <summary>
        /// Called when an Alien is able to launch a bomb. Sets the position of the bomb according to the
        /// alien's position then adds it to the list of Projectiles.
        /// </summary>
        /// <param name="alien">The Alien that will launch the bomb.</param>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Launch(Rectangle alien, GameTime gameTime)
        {
            int xCoordinate             = alien.X + (alien.Width / 2);
            int yCoordinate             = alien.Bottom + 1;
            ProjectileSprite projectile = new ProjectileSprite(game, bombImage, false, 6F);

            projectile.Initialize();
            projectile.SetPosition(xCoordinate, yCoordinate);
            bullets.Add(projectile);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called when a Player is able to launch a laser. Sets the position of the laser according to the
        /// Players's position then adds it to the list of Projectiles. Controls how rapidly a player
        /// can fire a laser through throttling.
        /// </summary>
        /// <param name="player">The border of the player object</param>
        /// <param name="gameTime">Provides a snapshot of timing values</param>
        public override void Launch(Rectangle player, GameTime gameTime)
        {
            int yCoordinate = player.Top - 1 - imageLaser.Height;
            int xCoordinate = player.X + (player.Width / 2 - 1);

            if (gameTime.TotalGameTime - previousLaunchTime > tolerance)
            {
                projectile = new ProjectileSprite(game, imageLaser, true, 8F);
                projectile.Initialize();
                projectile.SetPosition(xCoordinate, yCoordinate);
                bullets.Add(projectile);
                previousLaunchTime = gameTime.TotalGameTime;
                laserSound.Play();
            }
        }