diff --git a/Source/vampires/EXPPickup.cpp b/Source/vampires/EXPPickup.cpp new file mode 100644 index 0000000..5f2aa36 --- /dev/null +++ b/Source/vampires/EXPPickup.cpp @@ -0,0 +1,22 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "EXPPickup.h" + +void AEXPPickup::BeginPlay() +{ + Super::BeginPlay(); +} + +void AEXPPickup::Tick(float DeltaSeconds) +{ + Super::Tick(DeltaSeconds); +} + +void AEXPPickup::OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, + UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) +{ + // TODO: Add EXP to player EXP component + + Super::OnBeginOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult); +} diff --git a/Source/vampires/EXPPickup.h b/Source/vampires/EXPPickup.h new file mode 100644 index 0000000..9241e69 --- /dev/null +++ b/Source/vampires/EXPPickup.h @@ -0,0 +1,26 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Pickup.h" +#include "EXPPickup.generated.h" + +/** + * + */ +UCLASS() +class VAMPIRES_API AEXPPickup : public APickup +{ + GENERATED_BODY() + +protected: + virtual void BeginPlay() override; + +public: + virtual void Tick(float DeltaSeconds) override; + + virtual void OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, + UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, + const FHitResult& SweepResult) override; +}; diff --git a/Source/vampires/GoldPickup.cpp b/Source/vampires/GoldPickup.cpp new file mode 100644 index 0000000..03319ef --- /dev/null +++ b/Source/vampires/GoldPickup.cpp @@ -0,0 +1,22 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "GoldPickup.h" + +void AGoldPickup::BeginPlay() +{ + Super::BeginPlay(); +} + +void AGoldPickup::Tick(float DeltaSeconds) +{ + Super::Tick(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); +} diff --git a/Source/vampires/GoldPickup.h b/Source/vampires/GoldPickup.h new file mode 100644 index 0000000..fc2b354 --- /dev/null +++ b/Source/vampires/GoldPickup.h @@ -0,0 +1,26 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Pickup.h" +#include "GoldPickup.generated.h" + +/** + * + */ +UCLASS() +class VAMPIRES_API AGoldPickup : public APickup +{ + GENERATED_BODY() + +protected: + virtual void BeginPlay() override; + +public: + virtual void Tick(float DeltaSeconds) override; + + virtual void OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, + UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, + const FHitResult& SweepResult) override; +}; diff --git a/Source/vampires/Pickup.cpp b/Source/vampires/Pickup.cpp new file mode 100644 index 0000000..480da64 --- /dev/null +++ b/Source/vampires/Pickup.cpp @@ -0,0 +1,43 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Pickup.h" + +#include "PlayerCharacter.h" + +// Sets default values +APickup::APickup() +{ + // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. + PrimaryActorTick.bCanEverTick = false; + + // Create Sphere Component + SphereComponent = CreateDefaultSubobject(TEXT("Sphere Component")); + SphereComponent->SetupAttachment(RootComponent); + SphereComponent->SetSphereRadius(25.0f); +} + +// Called when the game starts or when spawned +void APickup::BeginPlay() +{ + Super::BeginPlay(); + SphereComponent->OnComponentBeginOverlap.AddDynamic(this, &APickup::OnBeginOverlap); +} + +void APickup::Tick(float DeltaSeconds) +{ + Super::Tick(DeltaSeconds); + + // TODO: Move actor towards player when in range +} + +void APickup::OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, + UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) +{ + if (APlayerCharacter* PlayerCharacter = Cast(OtherActor)) + { + // TODO: Add extra functionality + Destroy(); + } +} + diff --git a/Source/vampires/Pickup.h b/Source/vampires/Pickup.h new file mode 100644 index 0000000..7dbb269 --- /dev/null +++ b/Source/vampires/Pickup.h @@ -0,0 +1,33 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Components/SphereComponent.h" +#include "GameFramework/Actor.h" +#include "Pickup.generated.h" + +UCLASS() +class VAMPIRES_API APickup : public AActor +{ + GENERATED_BODY() + +private: + UPROPERTY() + USphereComponent* SphereComponent; + +public: + // Sets default values for this actor's properties + APickup(); + +protected: + // Called when the game starts or when spawned + virtual void BeginPlay() override; + +public: + virtual void Tick(float DeltaSeconds) override; + + virtual void OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, + UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, + const FHitResult& SweepResult); +};