Compare commits

..

No commits in common. "619c82bd016b241a8ee997803f862e04ec04d759" and "16a5b98945de792c1060e54836aefe93e6bd40fa" have entirely different histories.

4 changed files with 5 additions and 86 deletions

BIN
Content/Enemy/BT_Enemy.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Content/Player/BP_PlayerCharacter.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -7,7 +7,6 @@
#include "EnhancedInputComponent.h" #include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h" #include "EnhancedInputSubsystems.h"
#include "InputMappingContext.h" #include "InputMappingContext.h"
#include "Kismet/GameplayStatics.h"
APlayerCharacter::APlayerCharacter() APlayerCharacter::APlayerCharacter()
{ {
@ -30,20 +29,11 @@ APlayerCharacter::APlayerCharacter()
// Create EXP Component // Create EXP Component
EXPComponent = CreateDefaultSubobject<UEXPComponent>(TEXT("EXP Component")); EXPComponent = CreateDefaultSubobject<UEXPComponent>(TEXT("EXP Component"));
// Create Garlic Sphere Component
GarlicSphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("Garlic Sphere Component"));
GarlicSphereComponent->SetupAttachment(RootComponent);
GarlicSphereComponent->SetSphereRadius(150.0f);
} }
void APlayerCharacter::BeginPlay() void APlayerCharacter::BeginPlay()
{ {
Super::BeginPlay(); Super::BeginPlay();
GarlicSphereComponent->OnComponentBeginOverlap.AddDynamic(this, &APlayerCharacter::OnGarlicBeginOverlap);
GarlicSphereComponent->OnComponentEndOverlap.AddDynamic(this, &APlayerCharacter::OnGarlicEndOverlap);
GetWorldTimerManager().SetTimer(GarlicTimerHandle, this, &APlayerCharacter::GarlicUpdate, GarlicUpdateTime, true);
} }
void APlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) void APlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
@ -81,46 +71,3 @@ void APlayerCharacter::MovementCallback(const FInputActionInstance& Instance)
AddMovementInput({1.0f, 0.0f, 0.0f}, vec2.X); AddMovementInput({1.0f, 0.0f, 0.0f}, vec2.X);
} }
} }
void APlayerCharacter::OnGarlicBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep,
const FHitResult& SweepResult)
{
if (AEnemyCharacter* Enemy = Cast<AEnemyCharacter>(OtherActor))
{
OverlappedEnemies.Add(Enemy);
}
}
void APlayerCharacter::OnGarlicEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
if (AEnemyCharacter* Enemy = Cast<AEnemyCharacter>(OtherActor))
{
OverlappedEnemies.Remove(Enemy);
}
}
void APlayerCharacter::GarlicUpdate()
{
for (int i = 0; i < OverlappedEnemies.Num(); i++)
{
bool deadCheck = false;
UHealthComponent* EnemyHealthComponent = OverlappedEnemies[i]->GetHealthComponent();
if (!EnemyHealthComponent->GetIsDead())
{
if (EnemyHealthComponent->GetCurrentHealth() < GarlicDamage)
{
deadCheck = true;
}
EnemyHealthComponent->TakeDamage(OverlappedEnemies[i], GarlicDamage, nullptr, GetController(), this);
}
if (deadCheck)
{
i -= 1;
}
}
}

View File

@ -3,11 +3,9 @@
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "EnemyCharacter.h"
#include "EXPComponent.h" #include "EXPComponent.h"
#include "VampireCharacter.h" #include "VampireCharacter.h"
#include "Camera/CameraComponent.h" #include "Camera/CameraComponent.h"
#include "Components/SphereComponent.h"
#include "GameFramework/SpringArmComponent.h" #include "GameFramework/SpringArmComponent.h"
#include "PlayerCharacter.generated.h" #include "PlayerCharacter.generated.h"
@ -35,25 +33,11 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
UInputAction* MovementAction; UInputAction* MovementAction;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
float GarlicDamage = 51.0f;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
float GarlicUpdateTime = 1.0f;
protected: protected:
UPROPERTY() UPROPERTY()
UEXPComponent* EXPComponent; UEXPComponent* EXPComponent;
UPROPERTY(VisibleAnywhere)
USphereComponent* GarlicSphereComponent;
UPROPERTY()
TArray<AEnemyCharacter*> OverlappedEnemies;
private:
FTimerHandle GarlicTimerHandle;
public: public:
APlayerCharacter(); APlayerCharacter();
@ -66,16 +50,4 @@ public:
private: private:
UFUNCTION() UFUNCTION()
void MovementCallback(const FInputActionInstance& Instance); void MovementCallback(const FInputActionInstance& Instance);
UFUNCTION()
void OnGarlicBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep,
const FHitResult& SweepResult);
UFUNCTION()
void OnGarlicEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex);
UFUNCTION()
void GarlicUpdate();
}; };