diff --git a/Source/vampires/GoldPickup.cpp b/Source/vampires/GoldPickup.cpp index 03319ef..a51bef5 100644 --- a/Source/vampires/GoldPickup.cpp +++ b/Source/vampires/GoldPickup.cpp @@ -3,6 +3,10 @@ #include "GoldPickup.h" +#include "PlayerCharacter.h" + +class APlayerCharacter; + void AGoldPickup::BeginPlay() { Super::BeginPlay(); @@ -16,7 +20,9 @@ void AGoldPickup::Tick(float DeltaSeconds) void AGoldPickup::OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) { - // TODO: Add Gold to player Gold component - - Super::OnBeginOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult); + if (APlayerCharacter* PlayerCharacter = Cast(OtherActor)) + { + PlayerCharacter->GetGoldComponent()->IncrementGold(Gold); + Super::OnBeginOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult); + } } diff --git a/Source/vampires/GoldPickup.h b/Source/vampires/GoldPickup.h index fc2b354..6fdf37f 100644 --- a/Source/vampires/GoldPickup.h +++ b/Source/vampires/GoldPickup.h @@ -14,6 +14,11 @@ class VAMPIRES_API AGoldPickup : public APickup { GENERATED_BODY() +public: + + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + int Gold = 1; + protected: virtual void BeginPlay() override;