Esempio n. 1
0
 void Update()
 {
     ammoDisplay.text = $"{ammoStockpile.GetCurrentMag(ammoStockpile.ammoType)} | {ammoStockpile.GetStockpile(ammoStockpile.ammoType)}";
 }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (reloadTimer > 0)
        {
            canUseWeapon = false;
        }
        else
        {
            canUseWeapon = true;
        }

        if (Input.GetKeyDown(KeyCode.R) && ammoStockpile.GetCurrentMag(ammoStockpile.ammoType) < m_scriptableWeapon.maxAmmo && canUseWeapon == true && ammoStockpile.GetStockpile(ammoStockpile.ammoType) > 0 && canFireTimer < 0)
        {
            if (m_scriptableWeapon.reloadType == ScriptableWeapons.ReloadType.Magazine)
            {
                ReloadWeapon();
            }
            else if (m_scriptableWeapon.reloadType == ScriptableWeapons.ReloadType.Single && isReloading == false)
            {
                StartCoroutine("ReloadSingle");
            }
        }

        // Checks if the script can run the FireWeapon(); method
        if (canInput == true && ammoStockpile.GetCurrentMag(ammoStockpile.ammoType) > 0 && canUseWeapon == true)
        {
            if (m_scriptableWeapon.automatic == false)
            {
                if (Input.GetMouseButtonDown(0) && canFireTimer <= 0)
                {
                    FireWeapon();
                }
            }
            else
            {
                if (Input.GetMouseButton(0) && canFireTimer <= 0)
                {
                    FireWeapon();
                }
            }
        }
    }