IEnumerator Shoot() { shooting = true; yield return(new WaitForSeconds(.1f)); int shotTotal = 0; foreach (var enemyLockPair in enemyLocks) { DestroyableObject enemy = enemyLockPair.Key; for (int shotIdx = 0; shotIdx < enemyLockPair.Value.shots; shotIdx++) { if (enemy != null) { var newTrailPrefab = Instantiate(bulletTrailPrefab, transform.position, Quaternion.identity); newTrailPrefab.Init(enemy.transform); enemy.Damage(); AudioManager.Instance.PlayClip(false, shotTotal); bool lastShot = shotIdx + 1 == enemyLockPair.Value.shots; if (lastShot) { enemy.SetLockedLabelVisible(false); } else { yield return(new WaitForSeconds(.05f)); } shotTotal++; } } yield return(new WaitForSeconds(.1f)); } enemyLocks.Clear(); LockNumber = 0; shooting = false; }