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 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/Content/Legumix/Weapon/Revolver/BP_Revolver.uasset b/Content/Legumix/Weapon/Revolver/BP_Revolver.uasset index 8448106..92a847a 100644 --- a/Content/Legumix/Weapon/Revolver/BP_Revolver.uasset +++ b/Content/Legumix/Weapon/Revolver/BP_Revolver.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5a698d15bf0250c193bf03a6dc921c8fd1944998b466396be5e2dbda4b808704 -size 40517 +oid sha256:d1eee27429be23ec90a0198461a714754f31e35522fb90cfed1b36418035628d +size 41121 diff --git a/Content/Legumix/Weapon/Revolver/FireAnimationTest/ABP_Arms.uasset b/Content/Legumix/Weapon/Revolver/FireAnimationTest/ABP_Arms.uasset index 59db029..468d017 100644 --- a/Content/Legumix/Weapon/Revolver/FireAnimationTest/ABP_Arms.uasset +++ b/Content/Legumix/Weapon/Revolver/FireAnimationTest/ABP_Arms.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1a2934af8c4e92c7a9788ac1ddb1ee22c47d49ba872ab4bb485ccd4c46cce262 -size 160494 +oid sha256:660660989145273d76392d392e98276adb3f1caf9bf73162192fe27d41807b4a +size 76529 diff --git a/Content/Legumix/Weapon/Revolver/FireAnimationTest/ABP_Revolver.uasset b/Content/Legumix/Weapon/Revolver/FireAnimationTest/ABP_Revolver.uasset new file mode 100644 index 0000000..caad70c --- /dev/null +++ b/Content/Legumix/Weapon/Revolver/FireAnimationTest/ABP_Revolver.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5dd7c7ecac9a88dd8728bc4fdf389b99638c2cd118cbe0c5207b7732ebda8e1e +size 36743 diff --git a/Content/Legumix/Weapon/Revolver/FireAnimationTest/AM_Arms_Fire.uasset b/Content/Legumix/Weapon/Revolver/FireAnimationTest/AM_Arms_Fire.uasset new file mode 100644 index 0000000..a39d0b1 --- /dev/null +++ b/Content/Legumix/Weapon/Revolver/FireAnimationTest/AM_Arms_Fire.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:855d73bcfa5e25367347516a9224bc10fb96d76093e8dc3ef17925998557fed8 +size 11228 diff --git a/Content/Legumix/Weapon/Revolver/FireAnimationTest/AM_Gun.uasset b/Content/Legumix/Weapon/Revolver/FireAnimationTest/AM_Gun.uasset index 6d9ffc5..d5d95a6 100644 --- a/Content/Legumix/Weapon/Revolver/FireAnimationTest/AM_Gun.uasset +++ b/Content/Legumix/Weapon/Revolver/FireAnimationTest/AM_Gun.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f15bd7d85ec19fe87fad5c95d77f483321dcc6d38e8c3643538ea21df70a66b6 -size 9576 +oid sha256:e34c543af60f3f480cbe17bbf9cc7a32b621eed6f9e5dcca617e732085f7b294 +size 1600 diff --git a/Content/Legumix/Weapon/Revolver/FireAnimationTest/AM_Revolver_Fire.uasset b/Content/Legumix/Weapon/Revolver/FireAnimationTest/AM_Revolver_Fire.uasset new file mode 100644 index 0000000..69b73bb --- /dev/null +++ b/Content/Legumix/Weapon/Revolver/FireAnimationTest/AM_Revolver_Fire.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cd11587ecdf7670c85147fab8c54c9eed9458d7f6bde32729ffddb5b59a39c4d +size 9654 diff --git a/Content/Legumix/Weapon/Revolver/FireAnimationTest/A_Arms_Fire.uasset b/Content/Legumix/Weapon/Revolver/FireAnimationTest/A_Arms_Fire.uasset index 15b4c08..44f3da3 100644 --- a/Content/Legumix/Weapon/Revolver/FireAnimationTest/A_Arms_Fire.uasset +++ b/Content/Legumix/Weapon/Revolver/FireAnimationTest/A_Arms_Fire.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:55c3a9d78986af215df04e27201d8c93e1af7a62a385e8dc6c663c5f7cdc4dcc -size 145934 +oid sha256:e51a3169fed13015291075e20885aaa237d125c1881d1eff454de6f83c73c523 +size 148284 diff --git a/Content/Legumix/Weapon/Revolver/FireAnimationTest/A_Gun_Fire.uasset b/Content/Legumix/Weapon/Revolver/FireAnimationTest/A_Gun_Fire.uasset index 4971e08..b1868cc 100644 --- a/Content/Legumix/Weapon/Revolver/FireAnimationTest/A_Gun_Fire.uasset +++ b/Content/Legumix/Weapon/Revolver/FireAnimationTest/A_Gun_Fire.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:40214c77facf325902d09ffa38c727d72cd9e992bb8d5c1fb08bfd66b361b3a8 -size 65921 +oid sha256:e904422ebe79ab4f0ce1a25fa8f6f128b0dad4bbab04d035413fbbe13100bcd7 +size 65922 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/Private/Player/LMPlayer.cpp b/Source/LegumeMix/Private/Player/LMPlayer.cpp index e527479..b2e7309 100644 --- a/Source/LegumeMix/Private/Player/LMPlayer.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayer.cpp @@ -131,6 +131,11 @@ void ALMPlayer::SetWeaponManager(ULMWeaponManager* Manager) void ALMPlayer::PlayAnimation(UAnimMontage* Animation) { + UAnimInstance* AnimInstance = GetArms()->GetAnimInstance(); + if (AnimInstance && Animation) + { + AnimInstance->Montage_Play(Animation); + } } void ALMPlayer::FireBullets(const FLMBulletInfo Settings) diff --git a/Source/LegumeMix/Private/Weapon/LMRevolver.cpp b/Source/LegumeMix/Private/Weapon/LMRevolver.cpp index 3c20818..994d261 100644 --- a/Source/LegumeMix/Private/Weapon/LMRevolver.cpp +++ b/Source/LegumeMix/Private/Weapon/LMRevolver.cpp @@ -29,10 +29,10 @@ void ALMRevolver::PrimaryFire() } return; } - PlayEvent(FireEvent); PlayAnimation(PrimaryFireAnimation); + Player->PlayAnimation(PrimaryFireArmsAnimation); const FVector Origin = Player->GetWeaponFiringOrigin(); const FVector Direction = Player->GetAimVector(); diff --git a/Source/LegumeMix/Private/Weapon/LMWeaponBase.cpp b/Source/LegumeMix/Private/Weapon/LMWeaponBase.cpp index bb66721..cbb8d8d 100644 --- a/Source/LegumeMix/Private/Weapon/LMWeaponBase.cpp +++ b/Source/LegumeMix/Private/Weapon/LMWeaponBase.cpp @@ -77,7 +77,7 @@ void ALMWeaponBase::PlayEvent(UFMODEvent* Event) const void ALMWeaponBase::PlayAnimation(UAnimMontage* Animation) { UAnimInstance* AnimInstance = WeaponMesh->GetAnimInstance(); - + if (Animation && AnimInstance) { AnimInstance->Montage_Play(Animation); 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; +}; diff --git a/Source/LegumeMix/Public/Weapon/LMWeaponBase.h b/Source/LegumeMix/Public/Weapon/LMWeaponBase.h index f1694ef..6742944 100644 --- a/Source/LegumeMix/Public/Weapon/LMWeaponBase.h +++ b/Source/LegumeMix/Public/Weapon/LMWeaponBase.h @@ -85,11 +85,15 @@ protected: /* Weapon Data */ UPROPERTY(EditAnywhere, BlueprintReadWrite,Category="Legumix|Sounds") TObjectPtr EquipSound; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Animations", meta=(AllowPrivateAccess=true)) + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Animations|Fire", meta=(AllowPrivateAccess=true)) TObjectPtr PrimaryFireAnimation; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Animations|Fire", meta=(AllowPrivateAccess=true)) + TObjectPtr PrimaryFireArmsAnimation; - UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Legumix|Animations", meta=(AllowPrivateAccess=true)) + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Legumix|Animations|Reload", meta=(AllowPrivateAccess=true)) TObjectPtr ReloadAnimation; + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Legumix|Animations|Reload", meta=(AllowPrivateAccess=true)) + TObjectPtr ReloadArmsAnimation; /** The number of seconds before being able to fire again. */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true))