Beispiel #1
0
 /// <summary>
 /// Called when a bullet was fired.
 /// </summary>
 public void OnFiredSingleShot()
 {
     --remainingBullets;
     NetworkWeaponAnimator.OnSingleShotFired();
     FMODUtil.PlayOnTransform(weapon.WeaponSoundModel.ShootSound, transform);
     BulletCountChanged?.Invoke(remainingBullets);
 }
Beispiel #2
0
 public void AddBullet()
 {
     _currentBullets++;
     if (BulletCountChanged != null)
     {
         BulletCountChanged.Invoke();
     }
 }
Beispiel #3
0
 /// <summary>
 /// Called when the weapon has reloaded.
 /// </summary>
 public void OnReloaded()
 {
     remainingBullets = weapon.MagazineSize;
     NetworkWeaponAnimator.OnStoppedReload();
     if (isLocalPlayer)
     {
         FMODUtil.PlayOnTransform(weapon.WeaponSoundModel.ReloadSound, transform);
     }
     BulletCountChanged?.Invoke(remainingBullets);
 }
Beispiel #4
0
    private void Fire()
    {
        Instantiate(_bulletPrefab, transform.position + transform.up * 0.4f, transform.rotation);
        _currentBullets--;
        if (BulletCountChanged != null)
        {
            BulletCountChanged.Invoke();
        }

        if (_fireAudioSource != null)
        {
            _fireAudioSource.Play();
        }
    }