コード例 #1
0
    public void Reload()
    {
        if (character.GetAmmo(weaponData.GetAmmoType()) > 0 && ammoCount != weaponData.GetAmmoClip())
        {
            int addedAmmo = Mathf.Clamp(weaponData.GetAmmoClip() - ammoCount, 0, Player.Instance.GetAmmo(weaponData.GetAmmoType()));

            ammoCount = ammoCount + addedAmmo;
            Player.Instance.SetAmmo(weaponData.GetAmmoType(), Player.Instance.GetAmmo(weaponData.GetAmmoType()) - addedAmmo);

            audioSource.clip = weaponData.GetReloadSound();
            audioSource.Play();

            UIController.Instance.GetHUD().ChangeAmmo(ammoCount);
        }
    }