void Shoot() { if (Time.time > nextShotTime && ammoRemaining > 0) { if (fireMode == FireMode.Burst) { if (shotsRemainingInBurst == 0) { return; } shotsRemainingInBurst--; } else if (fireMode == FireMode.Single) { if (!triggerReleasedSinceLastShot) { return; } } for (int i = 0; i < projectileSpawn.Length; i++) { if (ammoRemaining == 0) { break; } ammoRemaining--; if (ammoRemaining == 0) { DamagePopup popupInstance = Instantiate(ammoPopup, transform.position + Vector3.up * 2f, Quaternion.AngleAxis(70, Vector3.right)) as DamagePopup; popupInstance.JustStart(2f, transform.position + Vector3.up * 2f); } nextShotTime = Time.time + RateOfFire / 1000; Projectiles newBullet = Instantiate(bullet, projectileSpawn[i].position, projectileSpawn[i].rotation) as Projectiles; newBullet.SetSpeed(muzzleVel); newBullet.SetDamage(bulletDamage + (int)Random.Range(-damageVariance, damageVariance)); } if (UpdateAmmo != null) { UpdateAmmo(); } Instantiate(shell, shellEjection.position, shellEjection.rotation); muzzleFlash.Activate(); transform.localPosition -= Vector3.forward * .2f; recoilAngle += recoilPerShot; recoilAngle = Mathf.Clamp(recoilAngle, 0, maxRecoilAngle); AudioManager.instance.PlaySound(shootAudio, transform.position); } }