Пример #1
0
        private void DoShootingActivity(PositionedObject target)
        {
            if (CurrentBehavior == Behavior.Shooting &&
                FlatRedBall.Screens.ScreenManager.CurrentScreen.PauseAdjustedSecondsSince(lastFireShotTime) >
                (1 / FireShotsPerSecond)
                )
            {
                // Rotate the aiming vector to the farthest angle counterclockwise. (Positive)
                // For each increment rotate clockwise. (Negative)
                Vector3 currentAimingVector = RotateVector(aimingVector, BulletSpreadHalfAngle);
                float   spreadIncremet      = -(BulletSpreadHalfAngle * 2) / Math.Max((BulletsToFire - 1), 1);

                for (int i = 0; i < BulletsToFire; i++)
                {
                    var bullet = Factories.BulletFactory.CreateNew(this.X, this.Y);
                    bullet.Z = this.Z - 1;
                    bullet.CurrentDataCategoryState = Bullet.DataCategory.EnemyBullet;
                    bullet.Velocity = bullet.BulletSpeed * currentAimingVector;
                    //bullet.SetAnimationChainFromVelocity(TopDownDirectionExtensions.FromDirection(currentAimingVector, PossibleDirections), Weapon.ShootingFire);

                    currentAimingVector = RotateVector(currentAimingVector, spreadIncremet);
                }
                shootingAnimationLayer.PlayOnce(GetChainName(PrimaryActions.shoot, SecondaryActions.Shooting));
                lastFireShotTime = FlatRedBall.Screens.ScreenManager.CurrentScreen.PauseAdjustedCurrentTime;
                PlayWeaponShotSound();
                shotsLeftInClip--;
            }
        }
Пример #2
0
        private void DoShootingFireActivity(Bullet.DataCategory bulletData)
        {
            var direction = aimingVector;

            var bullet = Factories.BulletFactory.CreateNew(this.X, this.Y);

            bullet.Owner = this;
            bullet.CurrentDataCategoryState = bulletData;
            bullet.Velocity = bullet.BulletSpeed * direction;
            bullet.SetAnimationChainFromVelocity(TopDownDirectionExtensions.FromDirection(aimingVector, PossibleDirections), EquippedWeapon);

            CurrentEnergy -= ModifyEnergyDrain(bulletData.EnergyUsePerShot);

            shootingLayer.PlayOnce(GetChainName(currentPrimaryAction, SecondaryActions.Shooting));

            lastFireShotTime = FlatRedBall.Screens.ScreenManager.CurrentScreen.PauseAdjustedCurrentTime;
            if (bulletData == Bullet.DataCategory.PlayerFire)
            {
                FlatRedBall.Audio.AudioManager.Play(PlayerFlameShot);
            }
            else if (bulletData == Bullet.DataCategory.PlayerSkull)
            {
                switch (FlatRedBallServices.Random.Next(0, 3))
                {
                case 0: FlatRedBall.Audio.AudioManager.Play(PlayerShotSkull1); break;

                case 1: FlatRedBall.Audio.AudioManager.Play(PlayerShotSkull2); break;

                case 2: FlatRedBall.Audio.AudioManager.Play(PlayerShotSkull3); break;
                }
            }
        }