public void DestroyEnemyEntity(Guid enemyGuid) { if (!_enemiesInWave.TryGetValue(enemyGuid, out var enemyEntity)) { return; } var columnIndex = enemyEntity.EnemyColumnPositionIndexes.x; _waveColumns[columnIndex].Remove(enemyGuid); _enemiesInWave.Remove(enemyGuid); OnEnemyEntityDestroyed?.Invoke(enemyGuid, enemyEntity.EnemyScore); if (_enemiesInWave.Count == 0) { OnEnemiesWaveCleared?.Invoke(); return; } RecalculateWaveVerticalHeight(); if (columnIndex == _leftColumnIndex || columnIndex == _rightColumnIndex) { RecalculateWaveHorizontalBorders(); } }
public void ClearWave() { foreach (var enemyEntity in _enemiesInWave) { OnEnemyEntityDestroyed?.Invoke(enemyEntity.Key, 0); } _waveColumns.Clear(); _enemiesInWave.Clear(); _enemiesAbleToShoot.Clear(); _waveVerticalPositionIndex = 0; WavePosition = new Vector3(0f, 0f, WaveVerticalPosition); WaveOffset = Vector2.zero; OnEnemiesWaveMoved?.Invoke(EntityGuid, WaveCombinedPosition); }