Ejemplo n.º 1
0
        public void fireBullet()
        {
            // If the pickupWeapon has bullets, use it. Else use the default weapon.
            if (pickupWeapon != null && pickupWeapon.hasAmmunition())
            {
                currentWeapon = pickupWeapon;
            }
            else
            {
                currentWeapon = defaultWeapon;
            }

            if (!currentWeapon.isWaitingForFireDelay())
            {
                // Boolean for showing the weapon flash:
                isShooting = true;

                // Obtain a bullet from the current weapon. Notice how we pass the "owner" as argument.
                // when the bullet hits another player, we can give "points" to the ownerPlayer.
                Weapons.AbstractBullet tempBullet = currentWeapon.getBullet(ownerPlayer);

                // Add the aforehand created bullet to the bullet collection:
                allBullets.Add(tempBullet);

                if (currentWeapon is Weapons.Pistol)
                    audio.PlaySound("MachineGun_Fire", (ownerPlayer.ownerLevel.soundVolume/10)*4);
                else if (currentWeapon is Weapons.MachineGun)
                    audio.PlaySound("MachineGun_Fire", (ownerPlayer.ownerLevel.soundVolume / 10) * 4);
                else if (currentWeapon is Weapons.RocketLauncher)
                    audio.PlaySound("Rocket_Fire", (ownerPlayer.ownerLevel.soundVolume / 10) * 4);
                else if (currentWeapon is Weapons.GrenadeLauncher)
                    audio.PlaySound("Rocket_Fire", (ownerPlayer.ownerLevel.soundVolume / 10) * 4);
            }
        }
Ejemplo n.º 2
0
        private float shootingTimeElapsed = 0; // Internal counter, leave as-is.

        #endregion Fields

        #region Constructors

        public WeaponManager(AnimPlayer player)
        {
            this.ownerPlayer = player;
            audio = new Audio();
            // Create the collections which will hold our bullets fired/weapons. Mind the clever use of "generics"
            allBullets  = new List<Weapons.AbstractBullet>();

            //defaultWeapon = new Weapons.HeatSeeking();
            defaultWeapon = new Weapons.Pistol();
            //defaultWeapon = new Weapons.BouncyGun();
            pickupWeapon  = null;

            currentWeapon = defaultWeapon;
        }
Ejemplo n.º 3
0
 public void dropPickUpWeapon()
 {
     pickupWeapon = null;
 }
Ejemplo n.º 4
0
 public void setPickUpWeapon(Weapons.AbstractWeapon someWeapon)
 {
     // Pickup will always override the current pickup.
     pickupWeapon  = someWeapon;
     currentWeapon = pickupWeapon;
 }