Esempio n. 1
0
        /// <summary>
        /// Finds out if a laser can be shot. If so, a new laser object is created and is shot.
        /// </summary>
        /// <param name="elapsedGameTime">The elapsed game time.</param>
        /// <param name="overSeeingGame">The over seeing game.</param>
        public override void ShootProjectile(TimeSpan elapsedGameTime, MajorLeagueGamingAsteroids overSeeingGame)
        {
            Lasers newLaser = new Lasers();
            newLaser.Initialize(overSeeingGame.GetTexture(MajorLeagueGamingAsteroids.TextureType.UNFRIENDLY_LASER), Position);

            newLaser.RotationAngle = CalculateAngleToPlayer();
            if (RandomManager.RandomTrueFalse())
            {
                newLaser.RotationAngle += RandomManager.RandomAngleFromZeroToMany(MAXIMUM_INACCURACY);
            }
            else
            {
                newLaser.RotationAngle -= RandomManager.RandomAngleFromZeroToMany(MAXIMUM_INACCURACY);
            }
            newLaser.AccelerateObject(Lasers.LASER_SPEED);
            newLaser.ObjectType = GAME_OBJECT_TYPE.UNFRIENDLY_LASER;
            lastProjectileLaunch = elapsedGameTime;
            overSeeingGame.AddGameObject(newLaser);
        }
Esempio n. 2
0
        /// <summary>
        /// Finds out if a laser can be shot. If so, a new laser object is created and is shot.
        /// </summary>
        /// <param name="elapsedGameTime">The elapsed game time.</param>
        /// <param name="overSeeingGame">The over seeing game.</param>
        public override void ShootProjectile(TimeSpan elapsedGameTime, MajorLeagueGamingAsteroids overSeeingGame)
        {
            TimeSpan delayToUse;
            if (fastFire)
            {
                delayToUse = LASER_DELAY_FAST_FIRE;
                if (SHOOTING_MODIFIER_DURATION < elapsedGameTime - lastFastFireActivated) fastFire = false;
            }
            else
            {
                delayToUse = LASER_DELAY_STANDARD;
            }

            if (SHOOTING_MODIFIER_DURATION < elapsedGameTime - lastBigLaserActivated) shootBigLasers = false;

            if (lastLaserShot == null || elapsedGameTime - lastLaserShot >= delayToUse)
            {
                Lasers newLaser = new Lasers();
                if (shootBigLasers) newLaser.Initialize(overSeeingGame.GetTexture(MajorLeagueGamingAsteroids.TextureType.BIG_LASERS), Position);
                else newLaser.Initialize(overSeeingGame.GetTexture(MajorLeagueGamingAsteroids.TextureType.FRIENDLY_LASER), Position);

                newLaser.RotationAngle = this.RotationAngle;
                newLaser.AccelerateObject(Lasers.LASER_SPEED);
                newLaser.ObjectType = GAME_OBJECT_TYPE.FRIENDLY_LASER;
                lastLaserShot = elapsedGameTime;
                overSeeingGame.AddGameObject(newLaser);

                overSeeingGame.soundEffect.Play();
            }
        }