// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "GameFramework/GameModeBase.h" #include "GameplayTagAssetInterface.h" #include "MGameMode.generated.h" UENUM(BlueprintType) enum class EWaveState : uint8 { WaitingToStart, WaveInProgress, WaitingToComplete, // All the enemies have been spawned and we're waiting for them to be destroyed or for the player to die to move to next state WaveComplete, GameOver, LevelComplete }; DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnActorKilledSignature, AActor*, VictimActor, AActor*, KillerActor, AController*, KillerController); UCLASS() class MECHDEFENCE_API AMGameMode : public AGameModeBase { GENERATED_BODY() protected: UPROPERTY(EditDefaultsOnly, Category = "GameMode") TSubclassOf SpectatingViewPointClass; UPROPERTY(EditDefaultsOnly, Category = "GameMode") float LevelEndViewTargetBlendTime; UPROPERTY(EditDefaultsOnly, Category = "GameMode") float TimeBetweenWaves; UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "GameMode") int WaveCount; UPROPERTY(EditDefaultsOnly, Category = "GameMode") int MaxEnemiesInWave; UPROPERTY(EditDefaultsOnly, Category = "GameMode") int MinEnemiesInWave; UPROPERTY(EditDefaultsOnly, meta = (Tooltip = "These are the tags that are used to check how many enemies spawned in the current wave remain in the level"), Category = "GameMode") FGameplayTagContainer SpawnedEnemyTags; virtual void StartPlay() override; UFUNCTION(BlueprintCallable) void HandlePlayerKilled(); UFUNCTION(BlueprintCallable) void HandlePlayerVehicleDestroyed(AActor* Vehicle); UFUNCTION(BlueprintCallable) void GameOver(); UFUNCTION(BlueprintCallable) void LevelCompleted(); UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, Category = "GameMode") void SpawnNewEnemy(); UFUNCTION(BlueprintImplementableEvent, Category = "GameMode") void WaveStateChanged(EWaveState NewState, EWaveState OldState); UFUNCTION(BlueprintCallable, Category = "GameMode") void StartWave(); void PrepareForNextWave(); void EndWave(); void CheckWaveState(); void SetWaveState(EWaveState NewWaveState); void SpawnEnemyTimerElapsed(); int NumEnemiesToSpawn; FTimerHandle TimerHandle_NextWaveStart; FTimerHandle TimerHandle_EnemySpawn; EWaveState WaveState; public: UPROPERTY(BlueprintAssignable, Category = "GameMode") FOnActorKilledSignature OnActorKilled; UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "GameMode") int NumEnemiesKilled; void Tick(float DeltaSeconds) override; AMGameMode(); };