Added : WaveManagement + Fix : RangeEnemy (un peu)
This commit is contained in:
parent
dc0abe0e0b
commit
fbe2340f05
BIN
Content/Legumix/Ennemy/DistantEnemy/AIC_DistantEnnemy.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Ennemy/DistantEnemy/AIC_DistantEnnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Ennemy/DistantEnemy/BP_DistantEnemy.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Ennemy/DistantEnemy/BP_DistantEnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Ennemy/MeleeEnemy/BP_MeleeEnemy.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Ennemy/MeleeEnemy/BP_MeleeEnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Ennemy/Range/BT_RangeEnnemy.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Ennemy/Range/BT_RangeEnnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Ennemy/Range/EQC_DistantEnemy.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Ennemy/Range/EQC_DistantEnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Ennemy/Range/EQS_RangeEnnemy.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Ennemy/Range/EQS_RangeEnnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Spawner/BP_SpawnPosition.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Legumix/Spawner/BP_SpawnPosition.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Legumix/Spawner/BP_WaveManager.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Legumix/Spawner/BP_WaveManager.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Legumix/Spawner/LVL_TestSpawn.umap
(Stored with Git LFS)
Normal file
BIN
Content/Legumix/Spawner/LVL_TestSpawn.umap
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "LMSpawnPosition.h"
|
#include "LMSpawnPosition.h"
|
||||||
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
#include "Engine/World.h"
|
||||||
|
#include "DrawDebugHelpers.h"
|
||||||
|
|
||||||
// Sets default values
|
// Sets default values
|
||||||
ALMSpawnPosition::ALMSpawnPosition()
|
ALMSpawnPosition::ALMSpawnPosition()
|
||||||
@ -11,6 +14,11 @@ ALMSpawnPosition::ALMSpawnPosition()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ALMSpawnPosition::CanSpawn() const
|
||||||
|
{
|
||||||
|
return !IsPlayerVisible();
|
||||||
|
}
|
||||||
|
|
||||||
// Called when the game starts or when spawned
|
// Called when the game starts or when spawned
|
||||||
void ALMSpawnPosition::BeginPlay()
|
void ALMSpawnPosition::BeginPlay()
|
||||||
{
|
{
|
||||||
@ -22,6 +30,39 @@ void ALMSpawnPosition::BeginPlay()
|
|||||||
void ALMSpawnPosition::Tick(float DeltaTime)
|
void ALMSpawnPosition::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
Super::Tick(DeltaTime);
|
Super::Tick(DeltaTime);
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("CanSpawn: %s"), CanSpawn() ? TEXT("true") : TEXT("false"));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ALMSpawnPosition::IsPlayerVisible() const
|
||||||
|
{
|
||||||
|
AActor* Player = UGameplayStatics::GetPlayerPawn(GetWorld(), 0);
|
||||||
|
if (!Player) return false;
|
||||||
|
|
||||||
|
FVector Start = GetActorLocation();
|
||||||
|
FVector End = Player->GetActorLocation();
|
||||||
|
|
||||||
|
FHitResult HitResult;
|
||||||
|
FCollisionQueryParams Params;
|
||||||
|
Params.AddIgnoredActor(this);
|
||||||
|
|
||||||
|
bool bHit = GetWorld()->LineTraceSingleByChannel(
|
||||||
|
HitResult,
|
||||||
|
Start,
|
||||||
|
End,
|
||||||
|
ECC_Visibility,
|
||||||
|
Params
|
||||||
|
);
|
||||||
|
|
||||||
|
// Debug trace
|
||||||
|
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());
|
||||||
|
return HitResult.GetActor() == Player; // Retourne true uniquement si l'acteur touché est le joueur
|
||||||
|
}
|
||||||
|
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("LineTrace: No Hit"));
|
||||||
|
return false; // Aucun obstacle, le joueur est visible
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
#include "LMWaveManager.h"
|
#include "LMWaveManager.h"
|
||||||
|
#include "Enemy/LMEnemy.h"
|
||||||
|
|
||||||
// Sets default values
|
// Sets default values
|
||||||
ALMWaveManager::ALMWaveManager()
|
ALMWaveManager::ALMWaveManager()
|
||||||
@ -15,13 +15,71 @@ ALMWaveManager::ALMWaveManager()
|
|||||||
void ALMWaveManager::BeginPlay()
|
void ALMWaveManager::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
StartWave();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ALMWaveManager::SpawnEnemy(ALMSpawnPosition* spawnPosition, TSubclassOf<ALMEnemy> enemyToSpawn)
|
||||||
|
{
|
||||||
|
//Spawn sur une position
|
||||||
|
ALMEnemy* tempEnemy = GetWorld()->SpawnActor<ALMEnemy>(enemyToSpawn, spawnPosition->GetActorLocation(), FRotator::ZeroRotator);
|
||||||
|
|
||||||
|
//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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ALMWaveManager::EnemyDead(ALMEnemy* enemyToRemoveFromLife)
|
||||||
|
{
|
||||||
|
//remove l'ennemis de la liste des ennemis vivants
|
||||||
|
enemyToRemoveFromLife->OnEnemyDeath.RemoveDynamic(this,&ALMWaveManager::EnemyDead);
|
||||||
|
EnemyAliveList.Remove(enemyToRemoveFromLife);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ALMWaveManager::RemainsEnemyToSpawn()
|
||||||
|
{
|
||||||
|
bool no = EnemyAliveList.Num() < MaxEnemyInstantiate;
|
||||||
|
return EnemyNumberInWave != EnemySpawned && no;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ALMWaveManager::CheckForSpawnerOK()
|
||||||
|
{
|
||||||
|
SpawnPositionsOK.Empty();
|
||||||
|
for (ALMSpawnPosition* spawnPosition : SpawnPositionsList)
|
||||||
|
{
|
||||||
|
if(spawnPosition->CanSpawn())
|
||||||
|
{
|
||||||
|
SpawnPositionsOK.Add(spawnPosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every frame
|
// Called every frame
|
||||||
void ALMWaveManager::Tick(float DeltaTime)
|
void ALMWaveManager::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
Super::Tick(DeltaTime);
|
Super::Tick(DeltaTime);
|
||||||
|
if(RemainsEnemyToSpawn())
|
||||||
|
{
|
||||||
|
CheckForSpawnerOK();
|
||||||
|
if(SpawnPositionsOK.Num() > 0)
|
||||||
|
{
|
||||||
|
//Choose spawnpoint to spawn
|
||||||
|
int32 RandomIndex = FMath::RandRange(0, SpawnPositionsOK.Num() - 1);
|
||||||
|
SpawnEnemy(SpawnPositionsOK[RandomIndex],TypeOfEnemy);
|
||||||
|
EnemySpawned++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//lauch break time
|
||||||
|
// Lance un timer de 3 secondes avant d'appeler StartWave()
|
||||||
|
GetWorld()->GetTimerManager().SetTimer(BreakTimer, this, &ALMWaveManager::StartWave, BreakTime, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ALMWaveManager::StartWave()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -18,11 +18,16 @@ class LEGUMEMIX_API ALMEnemy : public ACharacter
|
|||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnEnnemyDeathSignature, ALMEnemy*, pleasefonctionne);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ALMEnemy();
|
ALMEnemy();
|
||||||
virtual void Tick(float DeltaTime) override;
|
virtual void Tick(float DeltaTime) override;
|
||||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintCallable, BlueprintAssignable, Category = "Legumix")
|
||||||
|
FOnEnnemyDeathSignature OnEnemyDeath;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
@ -15,6 +15,9 @@ public:
|
|||||||
// Sets default values for this actor's properties
|
// Sets default values for this actor's properties
|
||||||
ALMSpawnPosition();
|
ALMSpawnPosition();
|
||||||
|
|
||||||
|
// Méthode pour vérifier si le spawn est possible
|
||||||
|
bool CanSpawn() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Called when the game starts or when spawned
|
// Called when the game starts or when spawned
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
@ -23,4 +26,6 @@ public:
|
|||||||
// Called every frame
|
// Called every frame
|
||||||
virtual void Tick(float DeltaTime) override;
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool IsPlayerVisible() const;
|
||||||
};
|
};
|
||||||
|
@ -4,8 +4,11 @@
|
|||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "GameFramework/Actor.h"
|
#include "GameFramework/Actor.h"
|
||||||
|
#include "LMSpawnPosition.h"
|
||||||
#include "LMWaveManager.generated.h"
|
#include "LMWaveManager.generated.h"
|
||||||
|
|
||||||
|
class ALMEnemy;
|
||||||
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class LEGUMEMIX_API ALMWaveManager : public AActor
|
class LEGUMEMIX_API ALMWaveManager : public AActor
|
||||||
{
|
{
|
||||||
@ -14,13 +17,42 @@ class LEGUMEMIX_API ALMWaveManager : public AActor
|
|||||||
public:
|
public:
|
||||||
// Sets default values for this actor's properties
|
// Sets default values for this actor's properties
|
||||||
ALMWaveManager();
|
ALMWaveManager();
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix")
|
||||||
|
TArray<ALMEnemy*> EnemyAliveList; // Liste des ennemis
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix")
|
||||||
|
TArray<ALMSpawnPosition*> SpawnPositionsList; // Liste des ennemis
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix")
|
||||||
|
int EnemyNumberInWave; // Nombre d'ennemis dans la wave
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix")
|
||||||
|
int MaxEnemyInstantiate; // Nombre d'ennemis max spawnés
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix")
|
||||||
|
TSubclassOf<ALMEnemy> TypeOfEnemy; // Type d'ennemis to spawn
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix")
|
||||||
|
float BreakTime; // Nombre d'ennemis dans la wave
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Called when the game starts or when spawned
|
// Called when the game starts or when spawned
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
virtual void StartWave();
|
||||||
|
virtual void SpawnEnemy(ALMSpawnPosition* spawnPosition, TSubclassOf<ALMEnemy> enemyToSpawn);
|
||||||
|
UFUNCTION()
|
||||||
|
virtual void EnemyDead(ALMEnemy* enemyToRemoveFromLife);
|
||||||
|
virtual bool RemainsEnemyToSpawn();
|
||||||
|
virtual void CheckForSpawnerOK();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Called every frame
|
// Called every frame
|
||||||
virtual void Tick(float DeltaTime) override;
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
TArray<ALMSpawnPosition*> SpawnPositionsOK;
|
||||||
|
int EnemySpawned;
|
||||||
|
|
||||||
|
FTimerHandle BreakTimer;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user