WeaponManager.Reload C# (CSharp) Method

Reload() public method

public Reload ( ) : void
return void
    public void Reload()
    {
        if (isReloading)
            return;

        StartCoroutine(Reload_Coroutine());
    }

Usage Example

Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        _currentWeapon = _weaponManager.GetCurrentWeapon();

        if (Input.GetButtonDown("Reload") && _currentWeapon.currentAmmo != _currentWeapon.maxAmmo)
        {
            _weaponManager.Reload();
            return;
        }

        if (_currentWeapon.fireRate <= 0f)
        {
            if (Input.GetButtonDown("Fire1"))
            {
                Shoot();
            }
        }
        else
        {
            if (Input.GetButtonDown("Fire1"))
            {
                InvokeRepeating("Shoot", 0f, 1f / _currentWeapon.fireRate);
            }
            else if (Input.GetButtonUp("Fire1"))
            {
                CancelInvoke(nameof(Shoot));
            }
        }
    }
All Usage Examples Of WeaponManager::Reload