Compare commits
	
		
			No commits in common. "d9dba81c7eb4684be5694781235de89ea2de1b14" and "3f089caa33f49cfd479e445d396400f2a843167c" have entirely different histories.
		
	
	
		
			d9dba81c7e
			...
			3f089caa33
		
	
		
							
								
								
									
										
											BIN
										
									
								
								Content/Weapons/BP_ExampleWeapon.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Content/Weapons/BP_ExampleWeapon.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Content/Weapons/FireWand/BP_FireWandWeapon.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Content/Weapons/FireWand/BP_FireWandWeapon.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Content/Weapons/Knife/BP_KnifeWeapon.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Content/Weapons/Knife/BP_KnifeWeapon.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -79,11 +79,11 @@ UGoldComponent* APlayerCharacter::GetGoldComponent() | |||||||
| 
 | 
 | ||||||
| void APlayerCharacter::MovementCallback(const FInputActionInstance& Instance) | void APlayerCharacter::MovementCallback(const FInputActionInstance& Instance) | ||||||
| { | { | ||||||
| 	PreviousMovementDirection = Instance.GetValue().Get<FVector2D>(); | 	FVector2D vec2 = Instance.GetValue().Get<FVector2D>(); | ||||||
| 
 | 
 | ||||||
| 	if (PreviousMovementDirection.Size() != 0.0f) | 	if (vec2.Size() != 0.0f) | ||||||
| 	{ | 	{ | ||||||
| 		AddMovementInput({0.0f, 1.0f, 0.0f}, PreviousMovementDirection.Y); | 		AddMovementInput({0.0f, 1.0f, 0.0f}, vec2.Y); | ||||||
| 		AddMovementInput({1.0f, 0.0f, 0.0f}, PreviousMovementDirection.X); | 		AddMovementInput({1.0f, 0.0f, 0.0f}, vec2.X); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | |||||||
| @ -44,8 +44,6 @@ public: | |||||||
| 	UPROPERTY(EditAnywhere, BlueprintReadWrite) | 	UPROPERTY(EditAnywhere, BlueprintReadWrite) | ||||||
| 	UWeaponInventoryComponent* WeaponInventoryComponent; | 	UWeaponInventoryComponent* WeaponInventoryComponent; | ||||||
| 
 | 
 | ||||||
| 	FVector2D PreviousMovementDirection = FVector2d(1.0f, 0.0f); |  | ||||||
| 
 |  | ||||||
| private: | private: | ||||||
| 	FTimerHandle GarlicTimerHandle; | 	FTimerHandle GarlicTimerHandle; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -3,7 +3,8 @@ | |||||||
| 
 | 
 | ||||||
| #include "Projectile.h" | #include "Projectile.h" | ||||||
| 
 | 
 | ||||||
| #include "Weapons/ProjectileWeapon.h" | #include "EnemyCharacter.h" | ||||||
|  | #include "Weapons/MagicWandWeapon.h" | ||||||
| 
 | 
 | ||||||
| // Sets default values
 | // Sets default values
 | ||||||
| AProjectile::AProjectile() | AProjectile::AProjectile() | ||||||
| @ -12,7 +13,7 @@ AProjectile::AProjectile() | |||||||
| 	PrimaryActorTick.bCanEverTick = true; | 	PrimaryActorTick.bCanEverTick = true; | ||||||
| 
 | 
 | ||||||
| 	SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("Sphere Component")); | 	SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("Sphere Component")); | ||||||
| 	SetRootComponent(SphereComponent); | 	SphereComponent->SetupAttachment(RootComponent); | ||||||
| 	SphereComponent->SetSphereRadius(50.0f); | 	SphereComponent->SetSphereRadius(50.0f); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -20,8 +21,8 @@ AProjectile::AProjectile() | |||||||
| void AProjectile::BeginPlay() | void AProjectile::BeginPlay() | ||||||
| { | { | ||||||
| 	Super::BeginPlay(); | 	Super::BeginPlay(); | ||||||
| 	AProjectileWeapon* OwnerWeapon = Cast<AProjectileWeapon>(GetOwner());  | 	AMagicWandWeapon* OwnerWeapon = Cast<AMagicWandWeapon>(GetOwner());  | ||||||
| 	SphereComponent->OnComponentBeginOverlap.AddDynamic(OwnerWeapon, &AProjectileWeapon::OnProjectileBeginOverlap); | 	SphereComponent->OnComponentBeginOverlap.AddDynamic(OwnerWeapon, &AMagicWandWeapon::OnProjectileBeginOverlap); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Called every frame
 | // Called every frame
 | ||||||
|  | |||||||
| @ -1,39 +0,0 @@ | |||||||
| // Fill out your copyright notice in the Description page of Project Settings.
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| #include "FireWandWeapon.h" |  | ||||||
| 
 |  | ||||||
| #include "Kismet/KismetMathLibrary.h" |  | ||||||
| 
 |  | ||||||
| AFireWandWeapon::AFireWandWeapon() |  | ||||||
| { |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void AFireWandWeapon::BeginPlay() |  | ||||||
| { |  | ||||||
| 	Super::BeginPlay(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void AFireWandWeapon::FireWeaponAction_Implementation() |  | ||||||
| { |  | ||||||
| 	Super::FireWeaponAction_Implementation(); |  | ||||||
| 	 |  | ||||||
| 	if (IsValid(ProjectileTemplate) && OverlappedEnemies.Num() > 0) |  | ||||||
| 	{ |  | ||||||
| 		FActorSpawnParameters actorSpawnParameters; |  | ||||||
| 		actorSpawnParameters.Owner = this; |  | ||||||
| 		actorSpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; |  | ||||||
| 		actorSpawnParameters.TransformScaleMethod = ESpawnActorScaleMethod::MultiplyWithRoot; |  | ||||||
| 		 |  | ||||||
| 		AProjectile* projectile = GetWorld()->SpawnActor<AProjectile>(ProjectileTemplate, GetOwner()->GetTransform(), |  | ||||||
| 																	  actorSpawnParameters); |  | ||||||
| 
 |  | ||||||
| 		AActor* target = OverlappedEnemies[FMath::RandRange(0, OverlappedEnemies.Num() - 1)]; |  | ||||||
| 		FVector direction = UKismetMathLibrary::GetDirectionUnitVector( |  | ||||||
| 			GetActorLocation(), target->GetActorLocation()); |  | ||||||
| 		direction.Z = 0.0; |  | ||||||
| 		direction.Normalize(); |  | ||||||
| 
 |  | ||||||
| 		projectile->TargetDirection = direction; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -1,25 +0,0 @@ | |||||||
| // Fill out your copyright notice in the Description page of Project Settings.
 |  | ||||||
| 
 |  | ||||||
| #pragma once |  | ||||||
| 
 |  | ||||||
| #include "CoreMinimal.h" |  | ||||||
| #include "ProjectileWeapon.h" |  | ||||||
| #include "FireWandWeapon.generated.h" |  | ||||||
| 
 |  | ||||||
| /**
 |  | ||||||
|  *  |  | ||||||
|  */ |  | ||||||
| UCLASS() |  | ||||||
| class VAMPIRES_API AFireWandWeapon : public AProjectileWeapon |  | ||||||
| { |  | ||||||
| 	GENERATED_BODY() |  | ||||||
| 
 |  | ||||||
| public: |  | ||||||
| 	AFireWandWeapon(); |  | ||||||
| 
 |  | ||||||
| protected: |  | ||||||
| 	virtual void BeginPlay() override; |  | ||||||
| 
 |  | ||||||
| public: |  | ||||||
| 	virtual void FireWeaponAction_Implementation() override; |  | ||||||
| }; |  | ||||||
| @ -1,37 +0,0 @@ | |||||||
| // Fill out your copyright notice in the Description page of Project Settings.
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| #include "KnifeWeapon.h" |  | ||||||
| 
 |  | ||||||
| #include "Kismet/GameplayStatics.h" |  | ||||||
| #include "vampires/PlayerCharacter.h" |  | ||||||
| 
 |  | ||||||
| AKnifeWeapon::AKnifeWeapon() |  | ||||||
| { |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void AKnifeWeapon::BeginPlay() |  | ||||||
| { |  | ||||||
| 	Super::BeginPlay(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void AKnifeWeapon::FireWeaponAction_Implementation() |  | ||||||
| { |  | ||||||
| 	Super::FireWeaponAction_Implementation(); |  | ||||||
| 
 |  | ||||||
| 	APlayerCharacter* playerCharacter = Cast<APlayerCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0)); |  | ||||||
| 	if (IsValid(ProjectileTemplate) && playerCharacter) |  | ||||||
| 	{ |  | ||||||
| 		FActorSpawnParameters actorSpawnParameters; |  | ||||||
| 		actorSpawnParameters.Owner = this; |  | ||||||
| 		actorSpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; |  | ||||||
| 		actorSpawnParameters.TransformScaleMethod = ESpawnActorScaleMethod::MultiplyWithRoot; |  | ||||||
| 
 |  | ||||||
| 		AProjectile* projectile = GetWorld()->SpawnActor<AProjectile>(ProjectileTemplate, GetOwner()->GetTransform(), |  | ||||||
| 		                                                              actorSpawnParameters); |  | ||||||
| 
 |  | ||||||
| 		FVector direction = FVector(playerCharacter->PreviousMovementDirection, 0.0); |  | ||||||
| 		direction.Normalize(); |  | ||||||
| 		projectile->TargetDirection = direction; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -1,25 +0,0 @@ | |||||||
| // Fill out your copyright notice in the Description page of Project Settings.
 |  | ||||||
| 
 |  | ||||||
| #pragma once |  | ||||||
| 
 |  | ||||||
| #include "CoreMinimal.h" |  | ||||||
| #include "ProjectileWeapon.h" |  | ||||||
| #include "KnifeWeapon.generated.h" |  | ||||||
| 
 |  | ||||||
| /**
 |  | ||||||
|  *  |  | ||||||
|  */ |  | ||||||
| UCLASS() |  | ||||||
| class VAMPIRES_API AKnifeWeapon : public AProjectileWeapon |  | ||||||
| { |  | ||||||
| 	GENERATED_BODY() |  | ||||||
| 
 |  | ||||||
| public: |  | ||||||
| 	AKnifeWeapon(); |  | ||||||
| 
 |  | ||||||
| protected: |  | ||||||
| 	virtual void BeginPlay() override; |  | ||||||
| 
 |  | ||||||
| public: |  | ||||||
| 	virtual void FireWeaponAction_Implementation() override; |  | ||||||
| }; |  | ||||||
| @ -5,14 +5,20 @@ | |||||||
| 
 | 
 | ||||||
| #include "Kismet/GameplayStatics.h" | #include "Kismet/GameplayStatics.h" | ||||||
| #include "Kismet/KismetMathLibrary.h" | #include "Kismet/KismetMathLibrary.h" | ||||||
|  | #include "vampires/EnemyCharacter.h" | ||||||
| 
 | 
 | ||||||
| AMagicWandWeapon::AMagicWandWeapon() | AMagicWandWeapon::AMagicWandWeapon() | ||||||
| { | { | ||||||
|  | 	SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("Sphere Component")); | ||||||
|  | 	SphereComponent->SetupAttachment(RootComponent); | ||||||
|  | 	SphereComponent->SetSphereRadius(1000.0f); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void AMagicWandWeapon::BeginPlay() | void AMagicWandWeapon::BeginPlay() | ||||||
| { | { | ||||||
| 	Super::BeginPlay(); | 	Super::BeginPlay(); | ||||||
|  | 	SphereComponent->OnComponentBeginOverlap.AddDynamic(this, &AMagicWandWeapon::OnWeaponBeginOverlap); | ||||||
|  | 	SphereComponent->OnComponentEndOverlap.AddDynamic(this, &AMagicWandWeapon::OnWeaponEndOverlap); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void AMagicWandWeapon::FireWeaponAction_Implementation() | void AMagicWandWeapon::FireWeaponAction_Implementation() | ||||||
| @ -31,7 +37,7 @@ void AMagicWandWeapon::FireWeaponAction_Implementation() | |||||||
| 			actorSpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; | 			actorSpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; | ||||||
| 			actorSpawnParameters.TransformScaleMethod = ESpawnActorScaleMethod::MultiplyWithRoot; | 			actorSpawnParameters.TransformScaleMethod = ESpawnActorScaleMethod::MultiplyWithRoot; | ||||||
| 
 | 
 | ||||||
| 			AProjectile* projectile = GetWorld()->SpawnActor<AProjectile>(ProjectileTemplate, GetOwner()->GetTransform(), | 			AProjectile* projectile = GetWorld()->SpawnActor<AProjectile>(ProjectileTemplate, GetTransform(), | ||||||
| 			                                                              actorSpawnParameters); | 			                                                              actorSpawnParameters); | ||||||
| 			FVector direction = UKismetMathLibrary::GetDirectionUnitVector( | 			FVector direction = UKismetMathLibrary::GetDirectionUnitVector( | ||||||
| 				GetActorLocation(), nearestActor->GetActorLocation()); | 				GetActorLocation(), nearestActor->GetActorLocation()); | ||||||
| @ -41,3 +47,45 @@ void AMagicWandWeapon::FireWeaponAction_Implementation() | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | void AMagicWandWeapon::OnWeaponBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, | ||||||
|  |                                             UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, | ||||||
|  |                                             const FHitResult& SweepResult) | ||||||
|  | { | ||||||
|  | 	if (AEnemyCharacter* Enemy = Cast<AEnemyCharacter>(OtherActor)) | ||||||
|  | 	{ | ||||||
|  | 		OverlappedEnemies.Add(Enemy); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void AMagicWandWeapon::OnWeaponEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, | ||||||
|  |                                           UPrimitiveComponent* OtherComp, int32 OtherBodyIndex) | ||||||
|  | { | ||||||
|  | 	if (AEnemyCharacter* Enemy = Cast<AEnemyCharacter>(OtherActor)) | ||||||
|  | 	{ | ||||||
|  | 		OverlappedEnemies.Remove(Enemy); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void AMagicWandWeapon::OnProjectileBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, | ||||||
|  |                                                 UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, | ||||||
|  |                                                 const FHitResult& SweepResult) | ||||||
|  | { | ||||||
|  | 	if (AEnemyCharacter* Enemy = Cast<AEnemyCharacter>(OtherActor)) | ||||||
|  | 	{ | ||||||
|  | 		UHealthComponent* EnemyHealthComponent = Enemy->GetHealthComponent(); | ||||||
|  | 
 | ||||||
|  | 		if (!EnemyHealthComponent->GetIsDead()) | ||||||
|  | 		{ | ||||||
|  | 			AController* ownerController = nullptr; | ||||||
|  | 			if (AVampireCharacter* character = Cast<AVampireCharacter>(GetOwner())) | ||||||
|  | 			{ | ||||||
|  | 				ownerController = character->GetController(); | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			EnemyHealthComponent->TakeDamage(Enemy, Damage, nullptr, ownerController, this); | ||||||
|  | 
 | ||||||
|  | 			OverlappedComponent->GetAttachmentRootActor()->Destroy(); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | |||||||
| @ -3,17 +3,29 @@ | |||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include "CoreMinimal.h" | #include "CoreMinimal.h" | ||||||
| #include "ProjectileWeapon.h" | #include "../Weapon.h" | ||||||
|  | #include "Components/SphereComponent.h" | ||||||
|  | #include "vampires/Projectile.h" | ||||||
| #include "MagicWandWeapon.generated.h" | #include "MagicWandWeapon.generated.h" | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  *  |  *  | ||||||
|  */ |  */ | ||||||
| UCLASS() | UCLASS() | ||||||
| class VAMPIRES_API AMagicWandWeapon : public AProjectileWeapon | class VAMPIRES_API AMagicWandWeapon : public AWeapon | ||||||
| { | { | ||||||
| 	GENERATED_BODY() | 	GENERATED_BODY() | ||||||
| 
 | 
 | ||||||
|  | public: | ||||||
|  | 	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) | ||||||
|  | 	USphereComponent* SphereComponent = nullptr; | ||||||
|  | 
 | ||||||
|  | 	UPROPERTY(EditAnywhere, Category = "Weapon Properties") | ||||||
|  | 	TSubclassOf<AProjectile> ProjectileTemplate = nullptr; | ||||||
|  | 
 | ||||||
|  | private: | ||||||
|  | 	TArray<AActor*> OverlappedEnemies = TArray<AActor*>(); | ||||||
|  | 	 | ||||||
| public: | public: | ||||||
| 	AMagicWandWeapon(); | 	AMagicWandWeapon(); | ||||||
| 
 | 
 | ||||||
| @ -22,4 +34,17 @@ protected: | |||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
| 	virtual void FireWeaponAction_Implementation() override; | 	virtual void FireWeaponAction_Implementation() override; | ||||||
|  | 
 | ||||||
|  | 	UFUNCTION() | ||||||
|  | 	void OnWeaponBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, | ||||||
|  | 						UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, | ||||||
|  | 						const FHitResult& SweepResult); | ||||||
|  | 
 | ||||||
|  | 	UFUNCTION() | ||||||
|  | 	void OnWeaponEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, | ||||||
|  | 					  int32 OtherBodyIndex); | ||||||
|  | 	 | ||||||
|  | 	UFUNCTION() | ||||||
|  | 	void OnProjectileBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, | ||||||
|  | 	UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult); | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,60 +0,0 @@ | |||||||
| // Fill out your copyright notice in the Description page of Project Settings.
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| #include "ProjectileWeapon.h" |  | ||||||
| 
 |  | ||||||
| #include "vampires/EnemyCharacter.h" |  | ||||||
| 
 |  | ||||||
| AProjectileWeapon::AProjectileWeapon() |  | ||||||
| { |  | ||||||
| 	SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("Sphere Component")); |  | ||||||
| 	SphereComponent->SetupAttachment(RootComponent); |  | ||||||
| 	SphereComponent->SetSphereRadius(1000.0f); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void AProjectileWeapon::BeginPlay() |  | ||||||
| { |  | ||||||
| 	Super::BeginPlay(); |  | ||||||
| 	SphereComponent->OnComponentBeginOverlap.AddDynamic(this, &AProjectileWeapon::OnWeaponBeginOverlap); |  | ||||||
| 	SphereComponent->OnComponentEndOverlap.AddDynamic(this, &AProjectileWeapon::OnWeaponEndOverlap); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void AProjectileWeapon::OnWeaponBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, |  | ||||||
|                                              UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) |  | ||||||
| { |  | ||||||
| 	if (AEnemyCharacter* Enemy = Cast<AEnemyCharacter>(OtherActor)) |  | ||||||
| 	{ |  | ||||||
| 		OverlappedEnemies.Add(Enemy); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void AProjectileWeapon::OnWeaponEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, |  | ||||||
| 	UPrimitiveComponent* OtherComp, int32 OtherBodyIndex) |  | ||||||
| { |  | ||||||
| 	if (AEnemyCharacter* Enemy = Cast<AEnemyCharacter>(OtherActor)) |  | ||||||
| 	{ |  | ||||||
| 		OverlappedEnemies.Remove(Enemy); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void AProjectileWeapon::OnProjectileBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, |  | ||||||
| 	UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) |  | ||||||
| { |  | ||||||
| 	if (AEnemyCharacter* Enemy = Cast<AEnemyCharacter>(OtherActor)) |  | ||||||
| 	{ |  | ||||||
| 		UHealthComponent* EnemyHealthComponent = Enemy->GetHealthComponent(); |  | ||||||
| 
 |  | ||||||
| 		if (!EnemyHealthComponent->GetIsDead()) |  | ||||||
| 		{ |  | ||||||
| 			AController* ownerController = nullptr; |  | ||||||
| 			if (AVampireCharacter* character = Cast<AVampireCharacter>(GetOwner())) |  | ||||||
| 			{ |  | ||||||
| 				ownerController = character->GetController(); |  | ||||||
| 			} |  | ||||||
| 
 |  | ||||||
| 			EnemyHealthComponent->TakeDamage(Enemy, Damage, nullptr, ownerController, this); |  | ||||||
| 
 |  | ||||||
| 			OverlappedComponent->GetAttachmentRootActor()->Destroy(); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| @ -1,46 +0,0 @@ | |||||||
| // Fill out your copyright notice in the Description page of Project Settings.
 |  | ||||||
| 
 |  | ||||||
| #pragma once |  | ||||||
| 
 |  | ||||||
| #include "CoreMinimal.h" |  | ||||||
| #include "../Weapon.h" |  | ||||||
| #include "vampires/Projectile.h" |  | ||||||
| #include "ProjectileWeapon.generated.h" |  | ||||||
| 
 |  | ||||||
| /**
 |  | ||||||
|  *  |  | ||||||
|  */ |  | ||||||
| UCLASS() |  | ||||||
| class VAMPIRES_API AProjectileWeapon : public AWeapon |  | ||||||
| { |  | ||||||
| 	GENERATED_BODY() |  | ||||||
| public: |  | ||||||
| 	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) |  | ||||||
| 	USphereComponent* SphereComponent = nullptr; |  | ||||||
| 
 |  | ||||||
| 	UPROPERTY(EditAnywhere, Category = "Weapon Properties") |  | ||||||
| 	TSubclassOf<AProjectile> ProjectileTemplate = nullptr; |  | ||||||
| 
 |  | ||||||
| protected: |  | ||||||
| 	TArray<AActor*> OverlappedEnemies = TArray<AActor*>(); |  | ||||||
| 	 |  | ||||||
| public: |  | ||||||
| 	AProjectileWeapon(); |  | ||||||
| 	 |  | ||||||
| protected: |  | ||||||
| 	virtual void BeginPlay() override; |  | ||||||
| 	 |  | ||||||
| public: |  | ||||||
| 	UFUNCTION() |  | ||||||
| 	void OnWeaponBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, |  | ||||||
| 						UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, |  | ||||||
| 						const FHitResult& SweepResult); |  | ||||||
| 
 |  | ||||||
| 	UFUNCTION() |  | ||||||
| 	void OnWeaponEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, |  | ||||||
| 					  int32 OtherBodyIndex); |  | ||||||
| 	 |  | ||||||
| 	UFUNCTION() |  | ||||||
| 	void OnProjectileBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, |  | ||||||
| 	UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult); |  | ||||||
| }; |  | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user