Пример #1
0
    public void ReloadWeapon(bool ignoreAmmo = false)
    {
        if (rWeapon == null)
        {
            return;
        }
        UpdateTotalAmmo();
        if (!ignoreAmmo && (rWeapon.ammoCount >= rWeapon.clipSize || !WeaponHasAmmo()))
        {
            return;
        }
        onReloadWeapon.Invoke(rWeapon);
        var needAmmo = rWeapon.clipSize - rWeapon.ammoCount;

        if (!ignoreAmmo && WeaponAmmo().count < needAmmo)
        {
            needAmmo = WeaponAmmo().count;
        }

        rWeapon.AddAmmo(needAmmo);
        if (!ignoreAmmo)
        {
            WeaponAmmo().count -= needAmmo;
        }
        if (animator)
        {
            animator.SetInteger("ReloadID", GetReloadID());
            animator.SetTrigger("Reload");
        }

        rWeapon.ReloadEffect();
        UpdateTotalAmmo();
    }
Пример #2
0
    public void ReloadWeapon(vShooterWeapon weapon)
    {
        if (weapon.ammoCount >= weapon.clipSize)
        {
            return;
        }
        var ammoItem = ammoItems.FindAll(item => item.id == weapon.ammoID);

        for (int i = 0; i < ammoItem.Count; i++)
        {
            if (weapon.ammoCount >= weapon.clipSize)
            {
                break;
            }
            var needAmmo = weapon.clipSize - weapon.ammoCount;
            if (ammoItem[i].amount < needAmmo)
            {
                needAmmo = ammoItem[i].amount;
            }

            weapon.AddAmmo(needAmmo);
            if (itemManager)
            {
                itemManager.LeaveItem(ammoItem[i], needAmmo);
            }
        }
    }
        protected void ReloadWeaponAuto(vShooterWeapon weapon, bool secundaryWeapon = false)
        {
            if (!weapon || !weapon.gameObject.activeSelf)
            {
                return;
            }

            if (!((weapon.ammoCount >= weapon.clipSize)))
            {
                var needAmmo = weapon.clipSize - weapon.ammoCount;
                weapon.AddAmmo(needAmmo);
            }
        }
Пример #4
0
    protected void ReloadWeaponAuto(vShooterWeapon weapon, bool ignoreAmmo, bool secundaryWeapon = false)
    {
        if (!weapon)
        {
            return;
        }
        UpdateTotalAmmo();

        if (!(!ignoreAmmo && (weapon.ammoCount >= weapon.clipSize || !WeaponHasAmmo(secundaryWeapon))))
        {
            var needAmmo = weapon.clipSize - weapon.ammoCount;

            if (!ignoreAmmo && WeaponAmmo(weapon).count < needAmmo)
            {
                needAmmo = WeaponAmmo(weapon).count;
            }

            weapon.AddAmmo(needAmmo);
            if (!ignoreAmmo)
            {
                WeaponAmmo(weapon).Use(needAmmo);
            }
        }
    }