Beispiel #1
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;
                }
            }
        }
Beispiel #2
0
        private void DoShootingActivity()
        {
            Bullet.DataCategory bulletData = null;
            if (isPrimaryInputDown)
            {
                if (EquippedWeapon == Weapon.ShootingFire)
                {
                    CurrentSecondaryAction = SecondaryActions.Shooting;
                    bulletData             = Bullet.DataCategory.PlayerFire;
                }
                else if (EquippedWeapon == Weapon.ShootingLightning && CurrentEnergy > 0)
                {
                    CurrentSecondaryAction = SecondaryActions.Shooting;
                }
                else if (EquippedWeapon == Weapon.ShootingSkulls)
                {
                    CurrentSecondaryAction = SecondaryActions.Shooting;
                    bulletData             = Bullet.DataCategory.PlayerSkull;
                }
                else
                {
                    CurrentSecondaryAction = SecondaryActions.None;
                }
            }
            else
            {
                CurrentSecondaryAction = SecondaryActions.None;
            }

            if (CurrentSecondaryAction == SecondaryActions.Shooting &&
                bulletData != null &&
                FlatRedBall.Screens.ScreenManager.CurrentScreen.PauseAdjustedSecondsSince(lastFireShotTime) >
                1 / bulletData.ShotsPerSecond &&
                CurrentEnergy > ModifyEnergyDrain(bulletData.EnergyUsePerShot)
                )
            {
                DoShootingFireActivity(bulletData);
            }
            else if (CurrentSecondaryAction == SecondaryActions.Shooting && EquippedWeapon == Weapon.ShootingLightning)
            {
                CurrentEnergy -= ModifyEnergyDrain(LightningEnergyUsePerSecond) * TimeManager.SecondDifference;
            }
            else if (isPrimaryInputDown == false)
            {
                CurrentEnergy += EnergyRecoveryRate * TimeManager.SecondDifference;
            }
            else
            {
                if (emptyClipSoundEffectInstance?.State != SoundState.Playing)
                {
                    emptyClipSoundEffectInstance?.Play();
                }
            }

            CurrentEnergy = System.Math.Min(CurrentEnergy, MaxEnergy);
            CurrentEnergy = System.Math.Max(CurrentEnergy, 0);

            if (DebuggingVariables.PlayersHaveInfiniteEnergy)
            {
                CurrentEnergy = MaxEnergy;
            }
        }