Ejemplo n.º 1
0
    public IEnumerator Reload()
    {
        int currentTotalAmmo = weaponData.GetInventoryAmmo();

        if (weaponData.GetClipAmmo() < weaponData.GetMaxClipAmmo() && !isReloading && currentTotalAmmo > 0)
        {
            int ammoSpent = weaponData.GetMaxClipAmmo() - weaponData.GetClipAmmo();
            isReloading = true;
            animator.SetBool("reload", true);
            Debug.Log("Reloading");
            //Debug.Log(m_CurrentClipInfo.Length);
            yield return(new WaitForSeconds(reloadTime));

            int clipAmmo = (weaponData.GetMaxClipAmmo() <= currentTotalAmmo + weaponData.GetClipAmmo()) ? weaponData.GetMaxClipAmmo() : (weaponData.GetClipAmmo() + currentTotalAmmo) % weaponData.GetMaxClipAmmo();

            if (this is HitScan)
            {
                HitScan temp = (HitScan)this;
                temp.ResetBulletSpread();
            }
            weaponData.SetClipAmmo(clipAmmo);
            weaponData.ChangeInventoryAmmo(-ammoSpent);
            Debug.Log("Done reloading");
            animator.SetBool("reload", false);
            UpdateAmmoInfo();
        }
        isReloading = false;
    }