IEnumerator ShootRoutine() { while (shotCount > 0) { shootable?.FireShot(); --shotCount; yield return(new WaitForSeconds(shotFrequency)); } }
private void Update() { bool willBeDestroyed = destructible != null && destructible.WillBeDestroyed; if (!willBeDestroyed) { if (enableShooting) { if (Time.time - lastShotTime >= shotFrequency && currentShotCount < maxShotCount) { shootable?.FireShot(); lastShotTime = Time.time; ++currentShotCount; } } movable?.Move(Time.deltaTime); } }