#pragma once #include "CoreMinimal.h" #include "GameFramework/GameModeBase.h" #include "SpaceShooterGameMode.generated.h" // Enum for different spawn patterns UENUM(BlueprintType) enum class ESpawnPattern : uint8 { Random, // Randomly at screen edges Wave, // Groups of enemies from one direction Formation, // Specific formations (V-shape, line, etc.) Flanking // Enemies from multiple sides simultaneously }; // Struct to define a spawn point/zone USTRUCT(BlueprintType) struct FSpawnZone { GENERATED_BODY() UPROPERTY(EditAnywhere, BlueprintReadWrite) FVector Location; UPROPERTY(EditAnywhere, BlueprintReadWrite) float Radius = 100.0f; UPROPERTY(EditAnywhere, BlueprintReadWrite) float SpawnWeight = 1.0f; UPROPERTY(EditAnywhere, BlueprintReadWrite) bool bActive = true; }; UCLASS() class MYPROJECT3_API ASpaceShooterGameMode : public AGameModeBase { GENERATED_BODY() public: ASpaceShooterGameMode(); virtual void StartPlay() override; virtual void Tick(float DeltaTime) override; protected: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawning") TSubclassOf EnemyClass; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawning") float BaseEnemySpawnInterval = 2.0f; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawning") int32 MaxEnemies = 10; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawning") float ScreenSpawnMargin = 100.0f; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawning") TArray SpawnZones; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawning") TArray SpawnPatterns; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawning") int32 WaveSize = 3; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawning") float FormationSpacing = 150.0f; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawning|Difficulty") float DifficultyScaling = 0.95f; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spawning|Difficulty") int32 DifficultyInterval = 30; private: FTimerHandle EnemySpawnTimer; FTimerHandle DifficultyTimer; float CurrentSpawnInterval; ESpawnPattern CurrentPattern; int32 CurrentWaveCount; float GameTime; void SpawnEnemy(); void SpawnEnemyWave(); void SpawnEnemyFormation(); void SpawnEnemyFlanking(); FVector GetScreenEdgeSpawnLocation(); FVector GetSpawnZoneLocation(); void UpdateDifficulty(); FVector GetPlayerLocation(); TArray GetScreenBounds(); void RotateTowardsPlayer(AEnemySpaceship* Enemy, const FVector& PlayerLocation); };