From 368326054c327c8a01dfff3fd19a79b22e102d9e Mon Sep 17 00:00:00 2001 From: Emilie Schott Date: Fri, 14 Mar 2025 11:58:41 +0100 Subject: [PATCH 1/2] Provisoire Range enemy behaviour tree --- Content/Legumix/Ennemy/MeleeEnemy/AI/BT_MeleeEnemy.uasset | 4 ++-- .../Ennemy/MeleeEnemy/AI/Task/BTTask_FindPlayer.uasset | 4 ++-- Content/Legumix/Ennemy/MeleeEnemy/BP_MeleeEnemy.uasset | 4 ++-- Content/Legumix/Ennemy/RangeEnemy/AI/BB_RangeEnnemy.uasset | 4 ++-- Content/Legumix/Ennemy/RangeEnemy/AI/BT_RangeEnnemy.uasset | 4 ++-- Content/Legumix/Ennemy/RangeEnemy/AI/EQC_Player.uasset | 4 ++-- Content/Legumix/Ennemy/RangeEnemy/AI/EQS_RangeEnnemy.uasset | 4 ++-- Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset | 4 ++-- Content/Legumix/Levels/LVL_GYM_00.umap | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Content/Legumix/Ennemy/MeleeEnemy/AI/BT_MeleeEnemy.uasset b/Content/Legumix/Ennemy/MeleeEnemy/AI/BT_MeleeEnemy.uasset index e0fea86..c7ee0a2 100644 --- a/Content/Legumix/Ennemy/MeleeEnemy/AI/BT_MeleeEnemy.uasset +++ b/Content/Legumix/Ennemy/MeleeEnemy/AI/BT_MeleeEnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d88f64e3bc9fa4a77c30a008d2863dfaf0c9240cd3504a4087bbe0869773b668 -size 16466 +oid sha256:6378b00a49eb22f5a0bf3fb8852860f903e69b3ceb022e0e8aaf6626b36dfc57 +size 16748 diff --git a/Content/Legumix/Ennemy/MeleeEnemy/AI/Task/BTTask_FindPlayer.uasset b/Content/Legumix/Ennemy/MeleeEnemy/AI/Task/BTTask_FindPlayer.uasset index 0084009..b7eee9f 100644 --- a/Content/Legumix/Ennemy/MeleeEnemy/AI/Task/BTTask_FindPlayer.uasset +++ b/Content/Legumix/Ennemy/MeleeEnemy/AI/Task/BTTask_FindPlayer.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2a0412b2e95fd7bdbd533064767291320dbe94fac3eb8bea850b0174a35f890f -size 45160 +oid sha256:edaad464ec81ca911c65d273d3976a6fa942791ec9ae70d2f82d6cb290999259 +size 30310 diff --git a/Content/Legumix/Ennemy/MeleeEnemy/BP_MeleeEnemy.uasset b/Content/Legumix/Ennemy/MeleeEnemy/BP_MeleeEnemy.uasset index 5678af1..656b8c7 100644 --- a/Content/Legumix/Ennemy/MeleeEnemy/BP_MeleeEnemy.uasset +++ b/Content/Legumix/Ennemy/MeleeEnemy/BP_MeleeEnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3c7c330680b3e82bac54eea66f15d92d777ff2fc61c18726ee6a4d72b10c1555 -size 145088 +oid sha256:c634f4ba06aa6330a9a86f64559900f00de09d8149add523a07d0bb2bdbfc806 +size 145418 diff --git a/Content/Legumix/Ennemy/RangeEnemy/AI/BB_RangeEnnemy.uasset b/Content/Legumix/Ennemy/RangeEnemy/AI/BB_RangeEnnemy.uasset index d5638c9..5e9a4ef 100644 --- a/Content/Legumix/Ennemy/RangeEnemy/AI/BB_RangeEnnemy.uasset +++ b/Content/Legumix/Ennemy/RangeEnemy/AI/BB_RangeEnnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3a0376357a9fbe6ba02fba3cfe8abdfabcdd92d026cd9b6938d3ab68a541d9ac -size 3049 +oid sha256:f986054c9d8609e68bb4ca0f591a85cada17a9a90f4045192d61c3414dce6b47 +size 3669 diff --git a/Content/Legumix/Ennemy/RangeEnemy/AI/BT_RangeEnnemy.uasset b/Content/Legumix/Ennemy/RangeEnemy/AI/BT_RangeEnnemy.uasset index 8b30010..5c8882e 100644 --- a/Content/Legumix/Ennemy/RangeEnemy/AI/BT_RangeEnnemy.uasset +++ b/Content/Legumix/Ennemy/RangeEnemy/AI/BT_RangeEnnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:69d08e5578791bc65b73d8ce68af096d078170177419fa466a459ac40a932f78 -size 13117 +oid sha256:1287a9243fb01d57578f28f7d6fa086b59c94db6798ebafbe7a802460e625117 +size 26167 diff --git a/Content/Legumix/Ennemy/RangeEnemy/AI/EQC_Player.uasset b/Content/Legumix/Ennemy/RangeEnemy/AI/EQC_Player.uasset index bee3e05..0ddcf34 100644 --- a/Content/Legumix/Ennemy/RangeEnemy/AI/EQC_Player.uasset +++ b/Content/Legumix/Ennemy/RangeEnemy/AI/EQC_Player.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5fc205f45998d3780314dfef90fd303689496684673cf4abec0dbcbd8552e7f6 -size 18213 +oid sha256:1ed98a50ac6921ff1d200706ccffbcf938989da7e9cac1570386c6bf3079c230 +size 27843 diff --git a/Content/Legumix/Ennemy/RangeEnemy/AI/EQS_RangeEnnemy.uasset b/Content/Legumix/Ennemy/RangeEnemy/AI/EQS_RangeEnnemy.uasset index 819abd7..7a52ae3 100644 --- a/Content/Legumix/Ennemy/RangeEnemy/AI/EQS_RangeEnnemy.uasset +++ b/Content/Legumix/Ennemy/RangeEnemy/AI/EQS_RangeEnnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7cd7879e10bad3961d3f6c2eecdb5ab99aa56ebfd311e9ae28f52d356af4ffdb -size 43921 +oid sha256:4f524225e689f9e6ab1661ac3c470dc3c61f471d25c51b4f96cef5bf278e0e83 +size 44012 diff --git a/Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset b/Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset index 84f4b12..4ea7a2c 100644 --- a/Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset +++ b/Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d3efe161fd0f1d377896c323389d06c9e546f298251d0874a778a3fc4d80cd0f -size 129890 +oid sha256:203ca7e51af57d0ce79a85114f04bda9c3f89e53346febbe05b3af57bdfcfcf0 +size 179528 diff --git a/Content/Legumix/Levels/LVL_GYM_00.umap b/Content/Legumix/Levels/LVL_GYM_00.umap index d3bdbc4..48d8ef6 100644 --- a/Content/Legumix/Levels/LVL_GYM_00.umap +++ b/Content/Legumix/Levels/LVL_GYM_00.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9e4fc7e9b5f6fd3b4b48308f2ee330f92192db06d662f41e8bd1933e1ad846f0 -size 994556 +oid sha256:f32629d6de36883982deddd5b59f414d2e55a1ced79b227ff98b91f86c4954f4 +size 994910 From 2695d6c3e9d4d487f660bd4fee34dba11f3e9921 Mon Sep 17 00:00:00 2001 From: sSebster Date: Fri, 14 Mar 2025 12:25:41 +0100 Subject: [PATCH 2/2] Added : New wave managing system --- Content/Legumix/Spawner/DT_WavePreset.uasset | 3 + Content/Legumix/Spawner/LVL_TestSpawn.umap | 4 +- .../LegumeMix/Private/Enemy/LMEnemyRatio.cpp | 3 + .../Private/Enemy/LMWaveStructure.cpp | 1 + Source/LegumeMix/Private/LMSpawnPosition.cpp | 22 ++++- Source/LegumeMix/Private/LMWaveManager.cpp | 99 +++++++++++++++++-- Source/LegumeMix/Public/Enemy/LMEnemyRatio.h | 17 ++++ Source/LegumeMix/Public/LMSpawnPosition.h | 11 ++- Source/LegumeMix/Public/LMWaveManager.h | 32 ++++-- Source/LegumeMix/Public/LMWaveStructure.h | 17 ++++ 10 files changed, 182 insertions(+), 27 deletions(-) create mode 100644 Content/Legumix/Spawner/DT_WavePreset.uasset create mode 100644 Source/LegumeMix/Private/Enemy/LMEnemyRatio.cpp create mode 100644 Source/LegumeMix/Private/Enemy/LMWaveStructure.cpp create mode 100644 Source/LegumeMix/Public/Enemy/LMEnemyRatio.h create mode 100644 Source/LegumeMix/Public/LMWaveStructure.h diff --git a/Content/Legumix/Spawner/DT_WavePreset.uasset b/Content/Legumix/Spawner/DT_WavePreset.uasset new file mode 100644 index 0000000..69cfca0 --- /dev/null +++ b/Content/Legumix/Spawner/DT_WavePreset.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c4dc980d10370e54247d6d2b0bd1cd609110484abbbff020f22414b7261c5777 +size 2889 diff --git a/Content/Legumix/Spawner/LVL_TestSpawn.umap b/Content/Legumix/Spawner/LVL_TestSpawn.umap index 9fd5345..babf3e9 100644 --- a/Content/Legumix/Spawner/LVL_TestSpawn.umap +++ b/Content/Legumix/Spawner/LVL_TestSpawn.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5c66f6a8227ba03137a1a9a32451b8be1b400d73f51ce06f8c532dc0aee38fd0 -size 79804 +oid sha256:bcb5b01b681fff1a03e31833c07c4f3f7d7201fc37d0f0216cbc4714a96d1526 +size 81157 diff --git a/Source/LegumeMix/Private/Enemy/LMEnemyRatio.cpp b/Source/LegumeMix/Private/Enemy/LMEnemyRatio.cpp new file mode 100644 index 0000000..3647fa0 --- /dev/null +++ b/Source/LegumeMix/Private/Enemy/LMEnemyRatio.cpp @@ -0,0 +1,3 @@ +#include "Enemy/LMEnemyRatio.h" +#include "Enemy/LMEnemy.h" + diff --git a/Source/LegumeMix/Private/Enemy/LMWaveStructure.cpp b/Source/LegumeMix/Private/Enemy/LMWaveStructure.cpp new file mode 100644 index 0000000..f724e7b --- /dev/null +++ b/Source/LegumeMix/Private/Enemy/LMWaveStructure.cpp @@ -0,0 +1 @@ +#include "LMWaveStructure.h" diff --git a/Source/LegumeMix/Private/LMSpawnPosition.cpp b/Source/LegumeMix/Private/LMSpawnPosition.cpp index 0715e59..6aaa7ec 100644 --- a/Source/LegumeMix/Private/LMSpawnPosition.cpp +++ b/Source/LegumeMix/Private/LMSpawnPosition.cpp @@ -16,7 +16,7 @@ ALMSpawnPosition::ALMSpawnPosition() bool ALMSpawnPosition::CanSpawn() const { - return !IsPlayerVisible(); + return !IsPlayerVisible() && !IsOnCooldow; } // Called when the game starts or when spawned @@ -30,7 +30,7 @@ void ALMSpawnPosition::BeginPlay() void ALMSpawnPosition::Tick(float DeltaTime) { Super::Tick(DeltaTime); - UE_LOG(LogTemp, Warning, TEXT("CanSpawn: %s"), CanSpawn() ? TEXT("true") : TEXT("false")); + //UE_LOG(LogTemp, Warning, TEXT("CanSpawn: %s"), CanSpawn() ? TEXT("true") : TEXT("false")); } bool ALMSpawnPosition::IsPlayerVisible() const @@ -54,15 +54,27 @@ bool ALMSpawnPosition::IsPlayerVisible() const ); // Debug trace - DrawDebugLine(GetWorld(), Start, End, bHit ? FColor::Red : FColor::Green, false, 2.0f); + //DrawDebugLine(GetWorld(), Start, End, bHit ? FColor::Red : FColor::Green, false, 2.0f); if (bHit) { - UE_LOG(LogTemp, Warning, TEXT("LineTrace Hit: %s"), *HitResult.GetActor()->GetName()); + //UE_LOG(LogTemp, Warning, TEXT("LineTrace Hit: %s"), *HitResult.GetActor()->GetName()); return HitResult.GetActor() == Player; // Retourne true uniquement si l'acteur touché est le joueur } - UE_LOG(LogTemp, Warning, TEXT("LineTrace: No Hit")); + //UE_LOG(LogTemp, Warning, TEXT("LineTrace: No Hit")); return false; // Aucun obstacle, le joueur est visible } +void ALMSpawnPosition::StarCooldown() +{ + IsOnCooldow = true; + GetWorld()->GetTimerManager().SetTimer(ProcessCooldown, this, &ALMSpawnPosition::EndCooldown, TimerCooldown, false); +} + +void ALMSpawnPosition::EndCooldown() +{ + IsOnCooldow = false; +} + + diff --git a/Source/LegumeMix/Private/LMWaveManager.cpp b/Source/LegumeMix/Private/LMWaveManager.cpp index 85e8155..c2228b2 100644 --- a/Source/LegumeMix/Private/LMWaveManager.cpp +++ b/Source/LegumeMix/Private/LMWaveManager.cpp @@ -1,6 +1,9 @@ // Fill out your copyright notice in the Description page of Project Settings. #include "LMWaveManager.h" + +#include "IPropertyTable.h" +#include "Components/CapsuleComponent.h" #include "Enemy/LMEnemy.h" // Sets default values @@ -18,16 +21,40 @@ void ALMWaveManager::BeginPlay() StartWave(); } -void ALMWaveManager::SpawnEnemy(ALMSpawnPosition* spawnPosition, TSubclassOf enemyToSpawn) +void ALMWaveManager::SpawnEnemy(ALMSpawnPosition* spawnPosition) { - //Spawn sur une position - ALMEnemy* tempEnemy = GetWorld()->SpawnActor(enemyToSpawn, spawnPosition->GetActorLocation(), FRotator::ZeroRotator); + int RandomIndex = FMath::RandRange(0, AllEnemyType.Num()-1); + while(EnemiesPerType[RandomIndex] <= 0 ) + { + RandomIndex = FMath::RandRange(0, AllEnemyType.Num()-1); + } + //Choisis un ennemis à spawn random + TSubclassOf enemyToSpawn = AllEnemyType[RandomIndex]; + //Spawn sur une position + FActorSpawnParameters SpawnParameters; + SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn; + ALMEnemy* tempEnemy = GetWorld()->SpawnActor(enemyToSpawn, spawnPosition->GetActorLocation(), FRotator::ZeroRotator); + + if (!tempEnemy) + { + UE_LOG(LogTemp, Error, TEXT("Failed to spawn enemy!")); + return; + } + spawnPosition->StarCooldown(); + float tailleCapsule = tempEnemy->GetCapsuleComponent()->GetScaledCapsuleHalfHeight(); + FVector newPosition = tempEnemy->GetActorLocation(); + tempEnemy->SetActorLocation(FVector(newPosition.X,newPosition.Y,newPosition.Z + tailleCapsule)); + //ajoute l'ennemis à la liste des ennemis vivants EnemyAliveList.Add(tempEnemy); - + //bind la method ennemydead à la death de l'ennemis - tempEnemy->OnEnemyDeath.AddUniqueDynamic(this, &ALMWaveManager::EnemyDead); + tempEnemy->OnEnemyDeath.AddDynamic(this, &ALMWaveManager::EnemyDead); + UE_LOG(LogTemp, Error, TEXT("Succes to spawn and bind on death method")); + + EnemySpawned++; + EnemiesPerType[RandomIndex]--; } void ALMWaveManager::EnemyDead(ALMEnemy* enemyToRemoveFromLife) @@ -39,8 +66,15 @@ void ALMWaveManager::EnemyDead(ALMEnemy* enemyToRemoveFromLife) bool ALMWaveManager::RemainsEnemyToSpawn() { + int TotalEnemies = 0; + + for (int EnemyCount : EnemiesPerType) + { + TotalEnemies += EnemyCount; + } + bool stillToSpawn = TotalEnemies !=0; bool no = EnemyAliveList.Num() < MaxEnemyInstantiate; - return EnemyNumberInWave != EnemySpawned && no; + return EnemyNumberInWave != EnemySpawned && no && stillToSpawn; } void ALMWaveManager::CheckForSpawnerOK() @@ -55,6 +89,54 @@ void ALMWaveManager::CheckForSpawnerOK() } } +void ALMWaveManager::GetRandomDataWaveRow() +{ + TArray RowNames = WaveDatePreset->GetRowNames(); + int RandomIndex = FMath::RandRange(0, RowNames.Num() - 1);; + + FName WaveName = RowNames[RandomIndex]; + + CurrentWaveName = WaveName.ToString(); + FLMWaveStructure* InfoWaveRow = WaveDatePreset->FindRow(WaveName, ""); + + //InternalEnemyRatio = InfoWaveRow->WaveComposition; + EnemyNumberInWave = InfoWaveRow->EnemyCount; + MaxEnemyInstantiate = InfoWaveRow->MaxEnemyCount; + + for (const FLMEnemyRatio& EnemyRatio : InfoWaveRow->WaveComposition) + { + // Ajoute chaque EnemyType à la liste + AllEnemyType.Add(EnemyRatio.EnemyType); + } + + // Récupère les ratios (NbEnemy) et calcule leur somme + int32 TotalRatio = 0; + for (const FLMEnemyRatio& EnemyRatio : InfoWaveRow->WaveComposition) + { + TotalRatio += EnemyRatio.NbEnemy; + } + + // Sécurité : Si le total est 0, évite la division par zéro + if (TotalRatio == 0) return; + + // Répartit les ennemis proportionnellement + int32 RemainingEnemies = EnemyNumberInWave; + for (const FLMEnemyRatio& EnemyRatio : InfoWaveRow->WaveComposition) + { + // Calcul proportionnel arrondi + int32 Count = FMath::RoundToInt((float(EnemyRatio.NbEnemy) / TotalRatio) * EnemyNumberInWave); + + EnemiesPerType.Add(Count); + RemainingEnemies -= Count; + } + + // Ajuste les arrondis pour respecter exactement EnemyNumberInWave + for (int32 i = 0; i < RemainingEnemies; ++i) + { + EnemiesPerType[i % EnemiesPerType.Num()]++; + } +} + // Called every frame void ALMWaveManager::Tick(float DeltaTime) { @@ -66,7 +148,7 @@ void ALMWaveManager::Tick(float DeltaTime) { //Choose spawnpoint to spawn int32 RandomIndex = FMath::RandRange(0, SpawnPositionsOK.Num() - 1); - SpawnEnemy(SpawnPositionsOK[RandomIndex],TypeOfEnemy); + SpawnEnemy(SpawnPositionsOK[RandomIndex]); EnemySpawned++; } } @@ -81,5 +163,6 @@ void ALMWaveManager::Tick(float DeltaTime) void ALMWaveManager::StartWave() { - + GetRandomDataWaveRow(); + EnemySpawned = 0; } diff --git a/Source/LegumeMix/Public/Enemy/LMEnemyRatio.h b/Source/LegumeMix/Public/Enemy/LMEnemyRatio.h new file mode 100644 index 0000000..8995697 --- /dev/null +++ b/Source/LegumeMix/Public/Enemy/LMEnemyRatio.h @@ -0,0 +1,17 @@ +#pragma once + +#include "LMEnemyRatio.generated.h" + + +class ALMEnemy; + +USTRUCT(BlueprintType) +struct FLMEnemyRatio : public FTableRowBase +{ + GENERATED_BODY() + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix") + TSubclassOf EnemyType; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix", meta = (ClampMin = 0)) + int NbEnemy; +}; diff --git a/Source/LegumeMix/Public/LMSpawnPosition.h b/Source/LegumeMix/Public/LMSpawnPosition.h index b3dd41e..3a118c3 100644 --- a/Source/LegumeMix/Public/LMSpawnPosition.h +++ b/Source/LegumeMix/Public/LMSpawnPosition.h @@ -17,15 +17,22 @@ public: // Méthode pour vérifier si le spawn est possible bool CanSpawn() const; - + UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix") + float TimerCooldown = 1.5; + void StarCooldown(); + protected: // Called when the game starts or when spawned virtual void BeginPlay() override; - + + virtual void EndCooldown(); + public: // Called every frame virtual void Tick(float DeltaTime) override; private: bool IsPlayerVisible() const; + FTimerHandle ProcessCooldown; + bool IsOnCooldow; }; diff --git a/Source/LegumeMix/Public/LMWaveManager.h b/Source/LegumeMix/Public/LMWaveManager.h index 48fb0c9..83ec789 100644 --- a/Source/LegumeMix/Public/LMWaveManager.h +++ b/Source/LegumeMix/Public/LMWaveManager.h @@ -5,6 +5,7 @@ #include "CoreMinimal.h" #include "GameFramework/Actor.h" #include "LMSpawnPosition.h" +#include "LMWaveStructure.h" #include "LMWaveManager.generated.h" class ALMEnemy; @@ -17,34 +18,45 @@ class LEGUMEMIX_API ALMWaveManager : public AActor public: // Sets default values for this actor's properties ALMWaveManager(); - UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix") - TArray EnemyAliveList; // Liste des ennemis + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"), Category = "Legumix") + FString CurrentWaveName; // Name of the current wave + UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix") TArray SpawnPositionsList; // Liste des ennemis + + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"), Category = "Legumix") + TArray EnemyAliveList; // Liste des ennemis - UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix") + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"), Category = "Legumix") int EnemyNumberInWave; // Nombre d'ennemis dans la wave - UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix") + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"), Category = "Legumix") int MaxEnemyInstantiate; // Nombre d'ennemis max spawnés - UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix") - TSubclassOf TypeOfEnemy; // Type d'ennemis to spawn - UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix") float BreakTime; // Nombre d'ennemis dans la wave + UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix") + UDataTable* WaveDatePreset; + + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix") + TArray> AllEnemyType; + + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix") + TArray EnemiesPerType; + protected: // Called when the game starts or when spawned virtual void BeginPlay() override; virtual void StartWave(); - virtual void SpawnEnemy(ALMSpawnPosition* spawnPosition, TSubclassOf enemyToSpawn); + virtual void SpawnEnemy(ALMSpawnPosition* spawnPosition); UFUNCTION() virtual void EnemyDead(ALMEnemy* enemyToRemoveFromLife); virtual bool RemainsEnemyToSpawn(); virtual void CheckForSpawnerOK(); - + + virtual void GetRandomDataWaveRow(); public: // Called every frame @@ -52,7 +64,7 @@ public: private: TArray SpawnPositionsOK; - int EnemySpawned; + int EnemySpawned = 0; FTimerHandle BreakTimer; }; diff --git a/Source/LegumeMix/Public/LMWaveStructure.h b/Source/LegumeMix/Public/LMWaveStructure.h new file mode 100644 index 0000000..6da4520 --- /dev/null +++ b/Source/LegumeMix/Public/LMWaveStructure.h @@ -0,0 +1,17 @@ +#pragma once + +#include "Enemy/LMEnemyRatio.h" +#include "LMWaveStructure.generated.h" + +USTRUCT(BlueprintType) +struct FLMWaveStructure : public FTableRowBase +{ + GENERATED_BODY() + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix") + TArray WaveComposition; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix", meta = (ClampMin = 0)) + int EnemyCount; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix", meta = (ClampMin = 0)) + int MaxEnemyCount; +};