Added : Attack function for enemies, callable in blueprint and overridable
This commit is contained in:
parent
7bb1926af2
commit
3b1d4c86e5
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.
@ -13,6 +13,11 @@ void ALMDistantEnemy::BeginPlay()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ALMDistantEnemy::Attack(const APawn* TargetedPawn)
|
||||||
|
{
|
||||||
|
Super::Attack(TargetedPawn);
|
||||||
|
}
|
||||||
|
|
||||||
void ALMDistantEnemy::Tick(float DeltaTime)
|
void ALMDistantEnemy::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
Super::Tick(DeltaTime);
|
Super::Tick(DeltaTime);
|
||||||
|
@ -13,6 +13,13 @@ void ALMEnemy::BeginPlay()
|
|||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ALMEnemy::Attack(const APawn* TargetedPawn)
|
||||||
|
{
|
||||||
|
// TO DO
|
||||||
|
FString Debug = FString::Printf(TEXT("Enemy %s attack %s !"), *GetName(), *TargetedPawn->GetName());
|
||||||
|
GEngine->AddOnScreenDebugMessage(1, 2.f, FColor::Cyan, Debug);
|
||||||
|
}
|
||||||
|
|
||||||
double ALMEnemy::GetDistanceToTarget(const AActor* TargetedActor)
|
double ALMEnemy::GetDistanceToTarget(const AActor* TargetedActor)
|
||||||
{
|
{
|
||||||
return (TargetedActor->GetActorLocation() - GetActorLocation()).Length();
|
return (TargetedActor->GetActorLocation() - GetActorLocation()).Length();
|
||||||
|
@ -14,6 +14,11 @@ void ALMMeleeEnemy::BeginPlay()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ALMMeleeEnemy::Attack(const APawn* TargetedPawn)
|
||||||
|
{
|
||||||
|
Super::Attack(TargetedPawn);
|
||||||
|
}
|
||||||
|
|
||||||
void ALMMeleeEnemy::Tick(float DeltaTime)
|
void ALMMeleeEnemy::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
Super::Tick(DeltaTime);
|
Super::Tick(DeltaTime);
|
||||||
|
@ -18,5 +18,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
virtual void Attack(const APawn* TargetedPawn) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix")
|
||||||
EEnemyState EnemyState;
|
EEnemyState EnemyState;
|
||||||
|
|
||||||
@ -39,4 +39,12 @@ protected:
|
|||||||
*/
|
*/
|
||||||
UFUNCTION(BlueprintCallable, Category="Legumix", meta=(ReturnDisplayName="Distance", DefaultToSelf="TargetedActor"))
|
UFUNCTION(BlueprintCallable, Category="Legumix", meta=(ReturnDisplayName="Distance", DefaultToSelf="TargetedActor"))
|
||||||
double GetDistanceToTarget(const AActor* TargetedActor);
|
double GetDistanceToTarget(const AActor* TargetedActor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the distance between the enemy and a target.
|
||||||
|
* @param TargetedPawn
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
UFUNCTION(BlueprintCallable, Category="Legumix", meta=(DefaultToSelf="TargetedPawn"))
|
||||||
|
virtual void Attack(const APawn* TargetedPawn);
|
||||||
};
|
};
|
||||||
|
@ -18,5 +18,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
virtual void Attack(const APawn* TargetedPawn) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user