Add Pickup classes
This commit is contained in:
		
							parent
							
								
									b576bb4a19
								
							
						
					
					
						commit
						9b0cfbecc3
					
				
							
								
								
									
										22
									
								
								Source/vampires/EXPPickup.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								Source/vampires/EXPPickup.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -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); | ||||||
|  | } | ||||||
							
								
								
									
										26
									
								
								Source/vampires/EXPPickup.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								Source/vampires/EXPPickup.h
									
									
									
									
									
										Normal file
									
								
							| @ -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; | ||||||
|  | }; | ||||||
							
								
								
									
										22
									
								
								Source/vampires/GoldPickup.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								Source/vampires/GoldPickup.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -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); | ||||||
|  | } | ||||||
							
								
								
									
										26
									
								
								Source/vampires/GoldPickup.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								Source/vampires/GoldPickup.h
									
									
									
									
									
										Normal file
									
								
							| @ -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; | ||||||
|  | }; | ||||||
							
								
								
									
										43
									
								
								Source/vampires/Pickup.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								Source/vampires/Pickup.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -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<USphereComponent>(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<APlayerCharacter>(OtherActor)) | ||||||
|  | 	{ | ||||||
|  | 		// TODO: Add extra functionality
 | ||||||
|  | 		Destroy(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
							
								
								
									
										33
									
								
								Source/vampires/Pickup.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								Source/vampires/Pickup.h
									
									
									
									
									
										Normal file
									
								
							| @ -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); | ||||||
|  | }; | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user