Final weapons quick refactor
This commit is contained in:
parent
eb4ce4cb79
commit
8d8da3ddc1
@ -27,7 +27,10 @@ void AFireWandWeapon::FireWeaponAction_Implementation()
|
||||
|
||||
bool AFireWandWeapon::UpgradeWeapon_Implementation()
|
||||
{
|
||||
if (!Super::UpgradeWeapon_Implementation()) return false;
|
||||
if (!Super::UpgradeWeapon_Implementation())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (CurrentLevel)
|
||||
{
|
||||
@ -67,26 +70,26 @@ void AFireWandWeapon::FireProjectile()
|
||||
{
|
||||
if (ProjectileTemplate && OverlappedEnemies.Num() > 0)
|
||||
{
|
||||
AGameModeBase* gamemode = UGameplayStatics::GetGameMode(GetWorld());
|
||||
AGameModeBase* Gamemode = UGameplayStatics::GetGameMode(GetWorld());
|
||||
|
||||
if (UKismetSystemLibrary::DoesImplementInterface(gamemode, UPools::StaticClass()))
|
||||
if (UKismetSystemLibrary::DoesImplementInterface(Gamemode, UPools::StaticClass()))
|
||||
{
|
||||
if (AObjectPoolManager* objectPoolManager = IPools::Execute_GetProjectileObjectPoolManager(gamemode))
|
||||
if (AObjectPoolManager* ObjectPoolManager = IPools::Execute_GetProjectileObjectPoolManager(Gamemode))
|
||||
{
|
||||
AActor* projectile = objectPoolManager->GetObject();
|
||||
AActor* Projectile = ObjectPoolManager->GetObject();
|
||||
|
||||
if (UKismetSystemLibrary::DoesImplementInterface(projectile, UProjectilable::StaticClass()))
|
||||
if (UKismetSystemLibrary::DoesImplementInterface(Projectile, UProjectilable::StaticClass()))
|
||||
{
|
||||
IProjectilable::Execute_LoadDataFromDataAsset(projectile, ProjectileTemplate);
|
||||
projectile->SetOwner(this);
|
||||
IProjectilable::Execute_LoadDataFromDataAsset(Projectile, ProjectileTemplate);
|
||||
Projectile->SetOwner(this);
|
||||
|
||||
AActor* target = OverlappedEnemies[FMath::RandRange(0, OverlappedEnemies.Num() - 1)];
|
||||
FVector direction = UKismetMathLibrary::GetDirectionUnitVector(
|
||||
GetActorLocation(), target->GetActorLocation());
|
||||
direction.Z = 0.0;
|
||||
direction.Normalize();
|
||||
AActor* Target = OverlappedEnemies[FMath::RandRange(0, OverlappedEnemies.Num() - 1)];
|
||||
FVector Direction = UKismetMathLibrary::GetDirectionUnitVector(
|
||||
GetActorLocation(), Target->GetActorLocation());
|
||||
Direction.Z = 0.0;
|
||||
Direction.Normalize();
|
||||
|
||||
IProjectilable::Execute_SetTargetDirection(projectile, direction);
|
||||
IProjectilable::Execute_SetTargetDirection(Projectile, Direction);
|
||||
}
|
||||
|
||||
Super::FireProjectile();
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include "GarlicWeapon.h"
|
||||
|
||||
#include "MovieSceneTracksComponentTypes.h"
|
||||
#include "Components/SphereComponent.h"
|
||||
#include "vampires/EnemyCharacter.h"
|
||||
#include "vampires/HealthComponent.h"
|
||||
@ -20,7 +19,8 @@ AGarlicWeapon::AGarlicWeapon()
|
||||
|
||||
VisualEffectMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Visual Layout Mesh Component"));
|
||||
VisualEffectMeshComponent->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
|
||||
VisualEffectMeshComponent->SetWorldScale3D(FVector(3.0f, 3.0f, 3.0f)); // This is to match the size of our sphere component
|
||||
// This is to match the size of our sphere component
|
||||
VisualEffectMeshComponent->SetWorldScale3D(FVector(3.0f, 3.0f, 3.0f));
|
||||
VisualEffectMeshComponent->SetCollisionProfileName("NoCollision");
|
||||
}
|
||||
|
||||
@ -41,15 +41,14 @@ void AGarlicWeapon::OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AAc
|
||||
{
|
||||
if (AEnemyCharacter* Enemy = Cast<AEnemyCharacter>(OtherActor))
|
||||
{
|
||||
FOverlappedEnemy overlappedEnemy = FOverlappedEnemy(Enemy);
|
||||
FOverlappedEnemy OverlappedEnemy = FOverlappedEnemy(Enemy);
|
||||
|
||||
|
||||
GetWorldTimerManager().SetTimer(overlappedEnemy.OverlappedTimerHandle,
|
||||
GetWorldTimerManager().SetTimer(OverlappedEnemy.OverlappedTimerHandle,
|
||||
FTimerDelegate::CreateUObject(this, &AGarlicWeapon::GarlicFireWeaponAction,
|
||||
overlappedEnemy),
|
||||
OverlappedEnemy),
|
||||
WeaponCooldown,
|
||||
true);
|
||||
GarlicOverlappedEnemies.Add(overlappedEnemy);
|
||||
GarlicOverlappedEnemies.Add(OverlappedEnemy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,22 +78,22 @@ void AGarlicWeapon::GarlicFireWeaponAction(FOverlappedEnemy EnemyCharacter)
|
||||
return;
|
||||
}
|
||||
|
||||
AController* ownerController = nullptr;
|
||||
if (AVampireCharacter* character = Cast<AVampireCharacter>(GetOwner()))
|
||||
AController* OwnerController = nullptr;
|
||||
if (AVampireCharacter* Character = Cast<AVampireCharacter>(GetOwner()))
|
||||
{
|
||||
ownerController = character->GetController();
|
||||
OwnerController = Character->GetController();
|
||||
}
|
||||
|
||||
EnemyHealthComponent->TakeDamage(EnemyCharacter.OverlappedEnemyCharacter, Damage, nullptr,
|
||||
ownerController, this);
|
||||
OwnerController, this);
|
||||
|
||||
if (!EnemyHealthComponent->GetIsDead())
|
||||
{
|
||||
FVector Direction = EnemyCharacter.OverlappedEnemyCharacter->GetActorLocation() - this->GetActorLocation();
|
||||
Direction.Normalize();
|
||||
Direction.Z = 0.0f;
|
||||
float distance = SphereComponent->GetScaledSphereRadius();
|
||||
Direction *= distance;
|
||||
float Distance = SphereComponent->GetScaledSphereRadius();
|
||||
Direction *= Distance;
|
||||
EnemyCharacter.OverlappedEnemyCharacter->SetActorLocation(
|
||||
EnemyCharacter.OverlappedEnemyCharacter->GetActorLocation() + Direction);
|
||||
}
|
||||
@ -102,48 +101,55 @@ void AGarlicWeapon::GarlicFireWeaponAction(FOverlappedEnemy EnemyCharacter)
|
||||
|
||||
bool AGarlicWeapon::UpgradeWeapon_Implementation()
|
||||
{
|
||||
if (!Super::UpgradeWeapon_Implementation()) return false;
|
||||
if (!Super::UpgradeWeapon_Implementation())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (CurrentLevel)
|
||||
{
|
||||
case 1:
|
||||
Range *= 1.4f;
|
||||
SphereComponent->SetSphereRadius(Range);
|
||||
Damage += 2.0f;
|
||||
VisualEffectMeshComponent->SetWorldScale3D(VisualEffectMeshComponent->GetComponentTransform().GetScale3D() * 1.4f);
|
||||
break;
|
||||
case 2:
|
||||
WeaponCooldown -= 0.1f;
|
||||
Damage += 1;
|
||||
break;
|
||||
case 3:
|
||||
Range *= 1.2f;
|
||||
SphereComponent->SetSphereRadius(Range);
|
||||
Damage += 1.0f;
|
||||
VisualEffectMeshComponent->SetWorldScale3D(VisualEffectMeshComponent->GetComponentTransform().GetScale3D() * 1.2f);
|
||||
break;
|
||||
case 4:
|
||||
WeaponCooldown -= 0.1f;
|
||||
Damage += 2;
|
||||
break;
|
||||
case 5:
|
||||
Range *= 1.2f;
|
||||
SphereComponent->SetSphereRadius(Range);
|
||||
Damage += 1.0f;
|
||||
VisualEffectMeshComponent->SetWorldScale3D(VisualEffectMeshComponent->GetComponentTransform().GetScale3D() * 1.2f);
|
||||
break;
|
||||
case 6:
|
||||
WeaponCooldown -= 0.1f;
|
||||
Damage += 1;
|
||||
break;
|
||||
case 7:
|
||||
Range *= 1.2f;
|
||||
SphereComponent->SetSphereRadius(Range);
|
||||
Damage += 1.0f;
|
||||
VisualEffectMeshComponent->SetWorldScale3D(VisualEffectMeshComponent->GetComponentTransform().GetScale3D() * 1.2f);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
case 1:
|
||||
Range *= 1.4f;
|
||||
SphereComponent->SetSphereRadius(Range);
|
||||
Damage += 2.0f;
|
||||
VisualEffectMeshComponent->SetWorldScale3D(
|
||||
VisualEffectMeshComponent->GetComponentTransform().GetScale3D() * 1.4f);
|
||||
break;
|
||||
case 2:
|
||||
WeaponCooldown -= 0.1f;
|
||||
Damage += 1;
|
||||
break;
|
||||
case 3:
|
||||
Range *= 1.2f;
|
||||
SphereComponent->SetSphereRadius(Range);
|
||||
Damage += 1.0f;
|
||||
VisualEffectMeshComponent->SetWorldScale3D(
|
||||
VisualEffectMeshComponent->GetComponentTransform().GetScale3D() * 1.2f);
|
||||
break;
|
||||
case 4:
|
||||
WeaponCooldown -= 0.1f;
|
||||
Damage += 2;
|
||||
break;
|
||||
case 5:
|
||||
Range *= 1.2f;
|
||||
SphereComponent->SetSphereRadius(Range);
|
||||
Damage += 1.0f;
|
||||
VisualEffectMeshComponent->SetWorldScale3D(
|
||||
VisualEffectMeshComponent->GetComponentTransform().GetScale3D() * 1.2f);
|
||||
break;
|
||||
case 6:
|
||||
WeaponCooldown -= 0.1f;
|
||||
Damage += 1;
|
||||
break;
|
||||
case 7:
|
||||
Range *= 1.2f;
|
||||
SphereComponent->SetSphereRadius(Range);
|
||||
Damage += 1.0f;
|
||||
VisualEffectMeshComponent->SetWorldScale3D(
|
||||
VisualEffectMeshComponent->GetComponentTransform().GetScale3D() * 1.2f);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
ResetWeaponTimer();
|
||||
|
@ -27,7 +27,8 @@ UCLASS()
|
||||
class VAMPIRES_API AGarlicWeapon : public AWeapon
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
protected:
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"), Category = "Weapon | Garlic")
|
||||
TObjectPtr<USphereComponent> SphereComponent;
|
||||
|
||||
@ -38,6 +39,7 @@ public:
|
||||
|
||||
private:
|
||||
float Range;
|
||||
|
||||
public:
|
||||
AGarlicWeapon();
|
||||
|
||||
|
@ -29,7 +29,10 @@ void AGunWeapon::FireWeaponAction_Implementation()
|
||||
|
||||
bool AGunWeapon::UpgradeWeapon_Implementation()
|
||||
{
|
||||
if (!Super::UpgradeWeapon_Implementation()) return false;
|
||||
if (!Super::UpgradeWeapon_Implementation())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (CurrentLevel)
|
||||
{
|
||||
@ -67,11 +70,11 @@ void AGunWeapon::FireProjectile()
|
||||
{
|
||||
if (ProjectileTemplate && OverlappedEnemies.Num() > 0)
|
||||
{
|
||||
AGameModeBase* gamemode = UGameplayStatics::GetGameMode(GetWorld());
|
||||
AGameModeBase* Gamemode = UGameplayStatics::GetGameMode(GetWorld());
|
||||
|
||||
if (UKismetSystemLibrary::DoesImplementInterface(gamemode, UPools::StaticClass()))
|
||||
if (UKismetSystemLibrary::DoesImplementInterface(Gamemode, UPools::StaticClass()))
|
||||
{
|
||||
if (AObjectPoolManager* objectPoolManager = IPools::Execute_GetProjectileObjectPoolManager(gamemode))
|
||||
if (AObjectPoolManager* ObjectPoolManager = IPools::Execute_GetProjectileObjectPoolManager(Gamemode))
|
||||
{
|
||||
FVector2d ViewportSize;
|
||||
GEngine->GameViewport->GetViewportSize(ViewportSize);
|
||||
@ -92,20 +95,20 @@ void AGunWeapon::FireProjectile()
|
||||
PlayerController->DeprojectScreenPositionToWorld(ViewportSize.X, ViewportSize.Y, BottomRight,
|
||||
BottomRightDir);
|
||||
|
||||
FVector actorLocation = GetActorLocation();
|
||||
TopLeft.Z = actorLocation.Z;
|
||||
TopRight.Z = actorLocation.Z;
|
||||
BottomLeft.Z = actorLocation.Z;
|
||||
BottomRight.Z = actorLocation.Z;
|
||||
FVector ActorLocation = GetActorLocation();
|
||||
TopLeft.Z = ActorLocation.Z;
|
||||
TopRight.Z = ActorLocation.Z;
|
||||
BottomLeft.Z = ActorLocation.Z;
|
||||
BottomRight.Z = ActorLocation.Z;
|
||||
|
||||
AActor* projectile = objectPoolManager->GetObject();
|
||||
SpawnProjectile(projectile, UKismetMathLibrary::GetDirectionUnitVector(actorLocation, TopLeft));
|
||||
projectile = objectPoolManager->GetObject();
|
||||
SpawnProjectile(projectile, UKismetMathLibrary::GetDirectionUnitVector(actorLocation, TopRight));
|
||||
projectile = objectPoolManager->GetObject();
|
||||
SpawnProjectile(projectile, UKismetMathLibrary::GetDirectionUnitVector(actorLocation, BottomLeft));
|
||||
projectile = objectPoolManager->GetObject();
|
||||
SpawnProjectile(projectile, UKismetMathLibrary::GetDirectionUnitVector(actorLocation, BottomRight));
|
||||
AActor* projectile = ObjectPoolManager->GetObject();
|
||||
SpawnProjectile(projectile, UKismetMathLibrary::GetDirectionUnitVector(ActorLocation, TopLeft));
|
||||
projectile = ObjectPoolManager->GetObject();
|
||||
SpawnProjectile(projectile, UKismetMathLibrary::GetDirectionUnitVector(ActorLocation, TopRight));
|
||||
projectile = ObjectPoolManager->GetObject();
|
||||
SpawnProjectile(projectile, UKismetMathLibrary::GetDirectionUnitVector(ActorLocation, BottomLeft));
|
||||
projectile = ObjectPoolManager->GetObject();
|
||||
SpawnProjectile(projectile, UKismetMathLibrary::GetDirectionUnitVector(ActorLocation, BottomRight));
|
||||
|
||||
Super::FireProjectile();
|
||||
}
|
||||
@ -113,12 +116,12 @@ void AGunWeapon::FireProjectile()
|
||||
}
|
||||
}
|
||||
|
||||
void AGunWeapon::SpawnProjectile(AActor* projectile, FVector direction)
|
||||
void AGunWeapon::SpawnProjectile(AActor* Projectile, const FVector& Direction)
|
||||
{
|
||||
if (UKismetSystemLibrary::DoesImplementInterface(projectile, UProjectilable::StaticClass()))
|
||||
if (UKismetSystemLibrary::DoesImplementInterface(Projectile, UProjectilable::StaticClass()))
|
||||
{
|
||||
IProjectilable::Execute_LoadDataFromDataAsset(projectile, ProjectileTemplate);
|
||||
projectile->SetOwner(this);
|
||||
IProjectilable::Execute_SetTargetDirection(projectile, direction);
|
||||
IProjectilable::Execute_LoadDataFromDataAsset(Projectile, ProjectileTemplate);
|
||||
Projectile->SetOwner(this);
|
||||
IProjectilable::Execute_SetTargetDirection(Projectile, Direction);
|
||||
}
|
||||
}
|
||||
|
@ -29,5 +29,5 @@ protected:
|
||||
virtual void FireProjectile() override;
|
||||
|
||||
private:
|
||||
void SpawnProjectile(AActor* projectile, FVector direction);
|
||||
void SpawnProjectile(AActor* Projectile, const FVector& Direction);
|
||||
};
|
||||
|
@ -27,35 +27,38 @@ void AKnifeWeapon::FireWeaponAction_Implementation()
|
||||
|
||||
bool AKnifeWeapon::UpgradeWeapon_Implementation()
|
||||
{
|
||||
if (!Super::UpgradeWeapon_Implementation()) return false;
|
||||
if (!Super::UpgradeWeapon_Implementation())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (CurrentLevel)
|
||||
{
|
||||
case 1:
|
||||
ProjectilesPerActivation++;
|
||||
break;
|
||||
case 2:
|
||||
ProjectilesPerActivation++;
|
||||
Damage += 5.0f;
|
||||
break;
|
||||
case 3:
|
||||
ProjectilesPerActivation++;
|
||||
break;
|
||||
case 4:
|
||||
ProjectileTemplate->DamageableEnemies++;
|
||||
break;
|
||||
case 5:
|
||||
ProjectilesPerActivation++;
|
||||
break;
|
||||
case 6:
|
||||
ProjectilesPerActivation++;
|
||||
Damage += 5.0f;
|
||||
break;
|
||||
case 7:
|
||||
ProjectileTemplate->DamageableEnemies++;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
case 1:
|
||||
ProjectilesPerActivation++;
|
||||
break;
|
||||
case 2:
|
||||
ProjectilesPerActivation++;
|
||||
Damage += 5.0f;
|
||||
break;
|
||||
case 3:
|
||||
ProjectilesPerActivation++;
|
||||
break;
|
||||
case 4:
|
||||
ProjectileTemplate->DamageableEnemies++;
|
||||
break;
|
||||
case 5:
|
||||
ProjectilesPerActivation++;
|
||||
break;
|
||||
case 6:
|
||||
ProjectilesPerActivation++;
|
||||
Damage += 5.0f;
|
||||
break;
|
||||
case 7:
|
||||
ProjectileTemplate->DamageableEnemies++;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -67,24 +70,24 @@ void AKnifeWeapon::FireProjectile()
|
||||
{
|
||||
if (ProjectileTemplate && OverlappedEnemies.Num() > 0)
|
||||
{
|
||||
AGameModeBase* gamemode = UGameplayStatics::GetGameMode(GetWorld());
|
||||
AGameModeBase* Gamemode = UGameplayStatics::GetGameMode(GetWorld());
|
||||
|
||||
if (UKismetSystemLibrary::DoesImplementInterface(gamemode, UPools::StaticClass()))
|
||||
if (UKismetSystemLibrary::DoesImplementInterface(Gamemode, UPools::StaticClass()))
|
||||
{
|
||||
if (AObjectPoolManager* objectPoolManager = IPools::Execute_GetProjectileObjectPoolManager(gamemode))
|
||||
if (AObjectPoolManager* ObjectPoolManager = IPools::Execute_GetProjectileObjectPoolManager(Gamemode))
|
||||
{
|
||||
AActor* projectile = objectPoolManager->GetObject();
|
||||
AActor* Projectile = ObjectPoolManager->GetObject();
|
||||
|
||||
if (UKismetSystemLibrary::DoesImplementInterface(projectile, UProjectilable::StaticClass()))
|
||||
if (UKismetSystemLibrary::DoesImplementInterface(Projectile, UProjectilable::StaticClass()))
|
||||
{
|
||||
IProjectilable::Execute_LoadDataFromDataAsset(projectile, ProjectileTemplate);
|
||||
projectile->SetOwner(this);
|
||||
IProjectilable::Execute_LoadDataFromDataAsset(Projectile, ProjectileTemplate);
|
||||
Projectile->SetOwner(this);
|
||||
|
||||
FVector direction = FVector(IInputable::Execute_Input_GetPreviousMovementDirection(GetOwner()),
|
||||
FVector Direction = FVector(IInputable::Execute_Input_GetPreviousMovementDirection(GetOwner()),
|
||||
0.0);
|
||||
direction.Normalize();
|
||||
Direction.Normalize();
|
||||
|
||||
IProjectilable::Execute_SetTargetDirection(projectile, direction);
|
||||
IProjectilable::Execute_SetTargetDirection(Projectile, Direction);
|
||||
}
|
||||
|
||||
Super::FireProjectile();
|
||||
|
@ -21,40 +21,40 @@ void ALightningRingWeapon::FireWeaponAction_Implementation()
|
||||
{
|
||||
Super::FireWeaponAction_Implementation();
|
||||
|
||||
TArray<AActor*> targetableEnemies = OverlappedEnemies;
|
||||
TArray<AActor*> TargetableEnemies = OverlappedEnemies;
|
||||
|
||||
for (int i = 0; i < LightningBolts && targetableEnemies.Num() > 0; i++)
|
||||
for (int i = 0; i < LightningBolts && TargetableEnemies.Num() > 0; i++)
|
||||
{
|
||||
AActor* target = targetableEnemies[FMath::RandRange(0, targetableEnemies.Num() - 1)];
|
||||
AActor* Target = TargetableEnemies[FMath::RandRange(0, TargetableEnemies.Num() - 1)];
|
||||
|
||||
TArray<TEnumAsByte<EObjectTypeQuery>> traceObjectTypes;
|
||||
traceObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECC_Pawn));
|
||||
|
||||
TArray<AActor*> actorsToIgnore = TArray<AActor*>({GetOwner()});
|
||||
TArray<AActor*> ActorsToIgnore = TArray<AActor*>({GetOwner()});
|
||||
|
||||
TArray<AActor*> hitResults;
|
||||
TArray<AActor*> HitResults;
|
||||
|
||||
UKismetSystemLibrary::SphereOverlapActors(GetWorld(),
|
||||
target->GetActorLocation(),
|
||||
Target->GetActorLocation(),
|
||||
LightingBoltRadius,
|
||||
traceObjectTypes,
|
||||
AEnemyCharacter::StaticClass(),
|
||||
actorsToIgnore,
|
||||
hitResults);
|
||||
ActorsToIgnore,
|
||||
HitResults);
|
||||
|
||||
if (LightningEffectSystem)
|
||||
{
|
||||
float scale = FMath::FloorToFloat((CurrentLevel + 2.0f) / 2.0f);
|
||||
UNiagaraFunctionLibrary::SpawnSystemAtLocation(this, LightningEffectSystem, target->GetActorLocation(),
|
||||
GetActorRotation(), FVector(scale));
|
||||
float Scale = FMath::FloorToFloat((CurrentLevel + 2.0f) / 2.0f);
|
||||
UNiagaraFunctionLibrary::SpawnSystemAtLocation(this, LightningEffectSystem, Target->GetActorLocation(),
|
||||
GetActorRotation(), FVector(Scale));
|
||||
}
|
||||
|
||||
for (AActor* EnemyHitResult : hitResults)
|
||||
for (AActor* EnemyHitResult : HitResults)
|
||||
{
|
||||
UGameplayStatics::ApplyDamage(EnemyHitResult, Damage, nullptr, this, nullptr);
|
||||
}
|
||||
|
||||
targetableEnemies.Remove(target);
|
||||
TargetableEnemies.Remove(Target);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ class VAMPIRES_API ALightningRingWeapon : public AWeapon
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
protected:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon | Lightning Ring")
|
||||
int LightningBolts = 1;
|
||||
|
||||
@ -27,10 +27,8 @@ public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon | Lightning Ring")
|
||||
TObjectPtr<UNiagaraSystem> LightningEffectSystem;
|
||||
|
||||
public:
|
||||
ALightningRingWeapon();
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
|
@ -27,33 +27,36 @@ void AMagicWandWeapon::FireWeaponAction_Implementation()
|
||||
|
||||
bool AMagicWandWeapon::UpgradeWeapon_Implementation()
|
||||
{
|
||||
if (!Super::UpgradeWeapon_Implementation()) return false;
|
||||
if (!Super::UpgradeWeapon_Implementation())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (CurrentLevel)
|
||||
{
|
||||
case 1:
|
||||
ProjectilesPerActivation++;
|
||||
break;
|
||||
case 2:
|
||||
WeaponCooldown -= 0.2;
|
||||
break;
|
||||
case 3:
|
||||
ProjectilesPerActivation++;
|
||||
break;
|
||||
case 4:
|
||||
Damage += 10;
|
||||
break;
|
||||
case 5:
|
||||
ProjectilesPerActivation++;
|
||||
break;
|
||||
case 6:
|
||||
ProjectileTemplate->DamageableEnemies++;
|
||||
break;
|
||||
case 7:
|
||||
Damage += 10;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
case 1:
|
||||
ProjectilesPerActivation++;
|
||||
break;
|
||||
case 2:
|
||||
WeaponCooldown -= 0.2;
|
||||
break;
|
||||
case 3:
|
||||
ProjectilesPerActivation++;
|
||||
break;
|
||||
case 4:
|
||||
Damage += 10;
|
||||
break;
|
||||
case 5:
|
||||
ProjectilesPerActivation++;
|
||||
break;
|
||||
case 6:
|
||||
ProjectileTemplate->DamageableEnemies++;
|
||||
break;
|
||||
case 7:
|
||||
Damage += 10;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
ResetWeaponTimer();
|
||||
@ -65,30 +68,29 @@ void AMagicWandWeapon::FireProjectile()
|
||||
{
|
||||
if (ProjectileTemplate && OverlappedEnemies.Num() > 0)
|
||||
{
|
||||
float distance = 0.0f;
|
||||
AActor* nearestActor = UGameplayStatics::FindNearestActor(GetActorLocation(), OverlappedEnemies, distance);
|
||||
float Distance = 0.0f;
|
||||
|
||||
if (nearestActor)
|
||||
if (AActor* nearestActor = UGameplayStatics::FindNearestActor(GetActorLocation(), OverlappedEnemies, Distance))
|
||||
{
|
||||
AGameModeBase* gamemode = UGameplayStatics::GetGameMode(GetWorld());
|
||||
AGameModeBase* Gamemode = UGameplayStatics::GetGameMode(GetWorld());
|
||||
|
||||
if (UKismetSystemLibrary::DoesImplementInterface(gamemode, UPools::StaticClass()))
|
||||
if (UKismetSystemLibrary::DoesImplementInterface(Gamemode, UPools::StaticClass()))
|
||||
{
|
||||
if (AObjectPoolManager* objectPoolManager = IPools::Execute_GetProjectileObjectPoolManager(gamemode))
|
||||
if (AObjectPoolManager* ObjectPoolManager = IPools::Execute_GetProjectileObjectPoolManager(Gamemode))
|
||||
{
|
||||
AActor* projectile = objectPoolManager->GetObject();
|
||||
AActor* Projectile = ObjectPoolManager->GetObject();
|
||||
|
||||
if (UKismetSystemLibrary::DoesImplementInterface(projectile, UProjectilable::StaticClass()))
|
||||
if (UKismetSystemLibrary::DoesImplementInterface(Projectile, UProjectilable::StaticClass()))
|
||||
{
|
||||
IProjectilable::Execute_LoadDataFromDataAsset(projectile, ProjectileTemplate);
|
||||
projectile->SetOwner(this);
|
||||
IProjectilable::Execute_LoadDataFromDataAsset(Projectile, ProjectileTemplate);
|
||||
Projectile->SetOwner(this);
|
||||
|
||||
FVector direction = UKismetMathLibrary::GetDirectionUnitVector(
|
||||
FVector Direction = UKismetMathLibrary::GetDirectionUnitVector(
|
||||
GetActorLocation(), nearestActor->GetActorLocation());
|
||||
direction.Z = 0.0;
|
||||
direction.Normalize();
|
||||
Direction.Z = 0.0;
|
||||
Direction.Normalize();
|
||||
|
||||
IProjectilable::Execute_SetTargetDirection(projectile, direction);
|
||||
IProjectilable::Execute_SetTargetDirection(Projectile, Direction);
|
||||
}
|
||||
|
||||
Super::FireProjectile();
|
||||
|
@ -25,6 +25,6 @@ public:
|
||||
|
||||
virtual bool UpgradeWeapon_Implementation() override;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
virtual void FireProjectile() override;
|
||||
};
|
||||
|
@ -36,7 +36,10 @@ void APentagramWeapon::FireWeaponAction_Implementation()
|
||||
|
||||
bool APentagramWeapon::UpgradeWeapon_Implementation()
|
||||
{
|
||||
if (!Super::UpgradeWeapon_Implementation()) return false;
|
||||
if (!Super::UpgradeWeapon_Implementation())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (CurrentLevel)
|
||||
{
|
||||
@ -71,20 +74,22 @@ bool APentagramWeapon::UpgradeWeapon_Implementation()
|
||||
}
|
||||
|
||||
void APentagramWeapon::OnWeaponBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep,
|
||||
const FHitResult& SweepResult)
|
||||
{
|
||||
if (APickup* Pickup = Cast<APickup>(OtherActor))
|
||||
if (APickup* Pickup = Cast<APickup>(OtherActor))
|
||||
{
|
||||
OverlappedPickups.Add(Pickup);
|
||||
}
|
||||
else
|
||||
{
|
||||
Super::OnWeaponBeginOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
Super::OnWeaponBeginOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep,
|
||||
SweepResult);
|
||||
}
|
||||
}
|
||||
|
||||
void APentagramWeapon::OnWeaponEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor,
|
||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
|
||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
|
||||
{
|
||||
if (APickup* Pickup = Cast<APickup>(OtherActor))
|
||||
{
|
||||
|
@ -17,7 +17,6 @@ class VAMPIRES_API APentagramWeapon : public AWeapon
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
private:
|
||||
TArray<TObjectPtr<APickup>> OverlappedPickups = TArray<TObjectPtr<APickup>>();
|
||||
|
||||
public:
|
||||
@ -25,11 +24,12 @@ public:
|
||||
|
||||
virtual void FireWeaponAction_Implementation() override;
|
||||
|
||||
bool UpgradeWeapon_Implementation() override;
|
||||
virtual bool UpgradeWeapon_Implementation() override;
|
||||
|
||||
virtual void OnWeaponBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) override;
|
||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep,
|
||||
const FHitResult& SweepResult) override;
|
||||
|
||||
virtual void OnWeaponEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor,
|
||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex) override;
|
||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex) override;
|
||||
};
|
||||
|
@ -47,12 +47,12 @@ void ASwarmAgent::OnSwarmAgentBeginOverlap(UPrimitiveComponent* OverlappedCompon
|
||||
|
||||
if (!EnemyHealthComponent->GetIsDead())
|
||||
{
|
||||
if (AWeapon* ownerWeapon = Cast<AWeapon>(GetOwner()))
|
||||
if (AWeapon* OwnerWeapon = Cast<AWeapon>(GetOwner()))
|
||||
{
|
||||
if (AVampireCharacter* character = Cast<AVampireCharacter>(ownerWeapon->GetOwner()))
|
||||
if (AVampireCharacter* Character = Cast<AVampireCharacter>(OwnerWeapon->GetOwner()))
|
||||
{
|
||||
AController* ownerController = character->GetController();
|
||||
EnemyHealthComponent->TakeDamage(Enemy, ownerWeapon->GetDamage(), nullptr, ownerController, this);
|
||||
AController* OwnerController = Character->GetController();
|
||||
EnemyHealthComponent->TakeDamage(Enemy, OwnerWeapon->GetDamage(), nullptr, OwnerController, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ class VAMPIRES_API ASwarmAgent : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
protected:
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TObjectPtr<USphereComponent> SphereComponent = nullptr;
|
||||
|
||||
@ -27,7 +27,6 @@ public:
|
||||
// Sets default values for this actor's properties
|
||||
ASwarmAgent();
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
|
@ -40,7 +40,7 @@ void ASwarmWeapon::BeginPlay()
|
||||
TimelineComponent->PlayFromStart();
|
||||
}
|
||||
|
||||
void ASwarmWeapon::TimelineCallback(float val)
|
||||
void ASwarmWeapon::TimelineCallback(float Val)
|
||||
{
|
||||
float num = SwarmActors.Num();
|
||||
|
||||
@ -50,7 +50,7 @@ void ASwarmWeapon::TimelineCallback(float val)
|
||||
float offset = (actorIndex / num) * 360.0f;
|
||||
FVector CenterLocation = GetActorLocation();
|
||||
FVector Direction = FVector(0.0, 1, 0.0);
|
||||
FVector RotatedDirection = Direction.RotateAngleAxis(val * 360.0f + offset, FVector(0.0f, 0.0f, 1.0f));
|
||||
FVector RotatedDirection = Direction.RotateAngleAxis(Val * 360.0f + offset, FVector(0.0f, 0.0f, 1.0f));
|
||||
FVector NewLocation = CenterLocation + (RotatedDirection * Distance);
|
||||
NewLocation.Z = 190.0f;
|
||||
SwarmActors[i]->SetActorLocation(NewLocation);
|
||||
|
@ -14,20 +14,20 @@ class VAMPIRES_API ASwarmWeapon : public AWeapon
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
protected:
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Weapon | Swarm")
|
||||
TObjectPtr<UTimelineComponent> TimelineComponent = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Weapon | Swarm")
|
||||
TObjectPtr<UCurveFloat> SwarmCurve;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon | Swarm")
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Weapon | Swarm")
|
||||
float TimelinePlayRate = 1;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Weapon | Swarm")
|
||||
TSubclassOf<ASwarmAgent> SwarmActor;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon | Swarm")
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Weapon | Swarm")
|
||||
float Distance = 250.0f;
|
||||
|
||||
private:
|
||||
@ -45,7 +45,7 @@ protected:
|
||||
|
||||
public:
|
||||
UFUNCTION()
|
||||
void TimelineCallback(float val);
|
||||
void TimelineCallback(float Val);
|
||||
|
||||
virtual bool UpgradeWeapon_Implementation() override;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user