示例#1
0
 public void Fire()
 {
     if (_weapon.CanShoot())
     {
         _weapon.CurrentAmmoInClip--;
         var hit = _rayProvider.CheckRay(_rayProvider.CreateRay());
         if (hit.collider != null)
         {
             _healthProvider = hit.collider.GetComponent <IHealthProvider>();
             _healthProvider?.TakeDamage(_weapon.damage);
             _weapon.CurrentFireRate = _weapon.fireRate;
         }
     }
     else if (!_weapon.CanShoot())
     {
         _weapon.CurrentFireRate -= Time.deltaTime;
     }
     Reload();
 }
示例#2
0
 public void Fire()
 {
     AmmoUI();
     if (_weapon.CanShoot() && _inputProvider.Shoot)
     {
         _weapon.CurrentAmmoInClip--;
         _weapon.CurrentFireRate = _weapon.fireRate;
         _bulletFlashParticleSystem.Play();
         var hit = _rayProvider.CheckRay(_rayProvider.CreateRay());
         if (hit.collider != null)
         {
             _healthProvider = hit.collider.GetComponent <IHealthProvider>();
             _healthProvider?.TakeDamage(_weapon.damage);
         }
     }
     else if (!_weapon.CanShoot())
     {
         _weapon.CurrentFireRate -= Time.deltaTime;
     }
 }