Compare commits
4 Commits
e8d7c49a4e
...
cafb8206e5
Author | SHA1 | Date |
---|---|---|
baz | cafb8206e5 | |
baz | 7f6e41cb50 | |
baz | 2d078ec48c | |
baz | 0092c3831f |
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include "EXPPickup.h"
|
#include "EXPPickup.h"
|
||||||
|
|
||||||
|
#include "PlayerCharacter.h"
|
||||||
|
|
||||||
void AEXPPickup::BeginPlay()
|
void AEXPPickup::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
@ -16,7 +18,9 @@ void AEXPPickup::Tick(float DeltaSeconds)
|
||||||
void AEXPPickup::OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
void AEXPPickup::OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
||||||
{
|
{
|
||||||
// TODO: Add EXP to player EXP component
|
if (APlayerCharacter* PlayerCharacter = Cast<APlayerCharacter>(OtherActor))
|
||||||
|
{
|
||||||
Super::OnBeginOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult);
|
PlayerCharacter->GetEXPComponent()->IncrementEXP(EXP);
|
||||||
|
Super::OnBeginOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,9 @@ class VAMPIRES_API AEXPPickup : public APickup
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
int EXP = 1;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
@ -21,6 +24,6 @@ public:
|
||||||
virtual void Tick(float DeltaSeconds) override;
|
virtual void Tick(float DeltaSeconds) override;
|
||||||
|
|
||||||
virtual void OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
virtual void OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep,
|
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep,
|
||||||
const FHitResult& SweepResult) override;
|
const FHitResult& SweepResult) override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
|
|
||||||
#include "GoldPickup.h"
|
#include "GoldPickup.h"
|
||||||
|
|
||||||
|
#include "PlayerCharacter.h"
|
||||||
|
|
||||||
|
class APlayerCharacter;
|
||||||
|
|
||||||
void AGoldPickup::BeginPlay()
|
void AGoldPickup::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
@ -16,7 +20,9 @@ void AGoldPickup::Tick(float DeltaSeconds)
|
||||||
void AGoldPickup::OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
void AGoldPickup::OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
||||||
{
|
{
|
||||||
// TODO: Add Gold to player Gold component
|
if (APlayerCharacter* PlayerCharacter = Cast<APlayerCharacter>(OtherActor))
|
||||||
|
{
|
||||||
Super::OnBeginOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult);
|
PlayerCharacter->GetGoldComponent()->IncrementGold(Gold);
|
||||||
|
Super::OnBeginOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,11 @@ class VAMPIRES_API AGoldPickup : public APickup
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
|
int Gold = 1;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,16 @@ void APlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UEXPComponent* APlayerCharacter::GetEXPComponent()
|
||||||
|
{
|
||||||
|
return EXPComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
UGoldComponent* APlayerCharacter::GetGoldComponent()
|
||||||
|
{
|
||||||
|
return GoldComponent;
|
||||||
|
}
|
||||||
|
|
||||||
void APlayerCharacter::MovementCallback(const FInputActionInstance& Instance)
|
void APlayerCharacter::MovementCallback(const FInputActionInstance& Instance)
|
||||||
{
|
{
|
||||||
FVector2D vec2 = Instance.GetValue().Get<FVector2D>();
|
FVector2D vec2 = Instance.GetValue().Get<FVector2D>();
|
||||||
|
|
|
@ -67,6 +67,10 @@ protected:
|
||||||
public:
|
public:
|
||||||
virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override;
|
virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override;
|
||||||
|
|
||||||
|
UEXPComponent* GetEXPComponent();
|
||||||
|
|
||||||
|
UGoldComponent* GetGoldComponent();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void MovementCallback(const FInputActionInstance& Instance);
|
void MovementCallback(const FInputActionInstance& Instance);
|
||||||
|
|
Loading…
Reference in New Issue