예제 #1
0
    public int GetAmmo(Gun.categories ammoType)
    {
        //Checks primary weapon's total ammo to update the corresponding weapon ammo
        bool usingWeapon = (primaryWeapon.weaponCategory == ammoType) || (secondaryWeapon.weaponCategory == ammoType);

        if (ammoType == Gun.categories.Shotgun)
        {
            if (usingWeapon)
            {
                shotgunAmmo = primaryWeapon.totalAmmo;
            }
            return(shotgunAmmo);
        }
        else if (ammoType == Gun.categories.Rifle)
        {
            if (usingWeapon)
            {
                rifleAmmo = primaryWeapon.totalAmmo;
            }
            return(rifleAmmo);
        }
        else if (ammoType == Gun.categories.Pistol)
        {
            if (usingWeapon)
            {
                pistolAmmo = secondaryWeapon.totalAmmo;
            }
            return(pistolAmmo);
        }
        else
        {
            return(-1);
        }
    }
예제 #2
0
 public bool AddAmmo(int amount, Gun.categories ammoType)
 {
     //Will update the primary weapon's ammo whenever called because the amount shown to the shotgun only changes when you add
     if (primaryWeapon.CanPickupAmmo(ammoType))
     {
         primaryWeapon.AddAmmo(amount);
         return(true);
     }
     else if (secondaryWeapon.CanPickupAmmo(ammoType))
     {
         secondaryWeapon.AddAmmo(amount);
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #3
0
 public bool CanPickupAmmo(Gun.categories ammoType)
 {
     return(totalAmmo < maxAmmo && ammoType == weaponCategory);
 }