Make sure max enemies applies properly
This commit is contained in:
@@ -138,6 +138,14 @@ void ASpaceShooterGameMode::SpawnEnemy()
|
|||||||
|
|
||||||
void ASpaceShooterGameMode::SpawnEnemyWave()
|
void ASpaceShooterGameMode::SpawnEnemyWave()
|
||||||
{
|
{
|
||||||
|
// Count current enemies
|
||||||
|
TArray<AActor*> FoundEnemies;
|
||||||
|
UGameplayStatics::GetAllActorsOfClass(GetWorld(), AEnemySpaceship::StaticClass(), FoundEnemies);
|
||||||
|
|
||||||
|
// Only spawn if we haven't reached the maximum
|
||||||
|
if (FoundEnemies.Num() < MaxEnemies)
|
||||||
|
{
|
||||||
|
|
||||||
UWorld* World = GetWorld();
|
UWorld* World = GetWorld();
|
||||||
if (!World || !EnemyClass)
|
if (!World || !EnemyClass)
|
||||||
return;
|
return;
|
||||||
@@ -190,10 +198,19 @@ void ASpaceShooterGameMode::SpawnEnemyWave()
|
|||||||
CurrentPattern = ESpawnPattern::Random;
|
CurrentPattern = ESpawnPattern::Random;
|
||||||
CurrentWaveCount = 0;
|
CurrentWaveCount = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASpaceShooterGameMode::SpawnEnemyFormation()
|
void ASpaceShooterGameMode::SpawnEnemyFormation()
|
||||||
{
|
{
|
||||||
|
// Count current enemies
|
||||||
|
TArray<AActor*> FoundEnemies;
|
||||||
|
UGameplayStatics::GetAllActorsOfClass(GetWorld(), AEnemySpaceship::StaticClass(), FoundEnemies);
|
||||||
|
|
||||||
|
// Only spawn if we haven't reached the maximum
|
||||||
|
if (FoundEnemies.Num() < MaxEnemies)
|
||||||
|
{
|
||||||
|
|
||||||
UWorld* World = GetWorld();
|
UWorld* World = GetWorld();
|
||||||
if (!World || !EnemyClass)
|
if (!World || !EnemyClass)
|
||||||
return;
|
return;
|
||||||
@@ -283,10 +300,19 @@ void ASpaceShooterGameMode::SpawnEnemyFormation()
|
|||||||
|
|
||||||
// Switch back to random pattern after a formation spawn
|
// Switch back to random pattern after a formation spawn
|
||||||
CurrentPattern = ESpawnPattern::Random;
|
CurrentPattern = ESpawnPattern::Random;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASpaceShooterGameMode::SpawnEnemyFlanking()
|
void ASpaceShooterGameMode::SpawnEnemyFlanking()
|
||||||
{
|
{
|
||||||
|
// Count current enemies
|
||||||
|
TArray<AActor*> FoundEnemies;
|
||||||
|
UGameplayStatics::GetAllActorsOfClass(GetWorld(), AEnemySpaceship::StaticClass(), FoundEnemies);
|
||||||
|
|
||||||
|
// Only spawn if we haven't reached the maximum
|
||||||
|
if (FoundEnemies.Num() < MaxEnemies)
|
||||||
|
{
|
||||||
|
|
||||||
UWorld* World = GetWorld();
|
UWorld* World = GetWorld();
|
||||||
if (!World || !EnemyClass)
|
if (!World || !EnemyClass)
|
||||||
return;
|
return;
|
||||||
@@ -336,6 +362,7 @@ void ASpaceShooterGameMode::SpawnEnemyFlanking()
|
|||||||
|
|
||||||
// Return to random spawning
|
// Return to random spawning
|
||||||
CurrentPattern = ESpawnPattern::Random;
|
CurrentPattern = ESpawnPattern::Random;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FVector ASpaceShooterGameMode::GetScreenEdgeSpawnLocation()
|
FVector ASpaceShooterGameMode::GetScreenEdgeSpawnLocation()
|
||||||
|
|||||||
Reference in New Issue
Block a user