Compare commits
4 Commits
e0ba69c694
...
f3f4ad0409
Author | SHA1 | Date | |
---|---|---|---|
f3f4ad0409 | |||
3d2826087e | |||
c5435718de | |||
e4d1e05fea |
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.
BIN
Content/Weapons/TestProjectileDataAsset.uasset
(Stored with Git LFS)
BIN
Content/Weapons/TestProjectileDataAsset.uasset
(Stored with Git LFS)
Binary file not shown.
@ -69,12 +69,14 @@ void AProjectile::LoadDataFromDataAsset_Implementation(UProjectileDataAsset* pro
|
|||||||
ProjectileSpeed = projectileDataAsset->ProjectileSpeed;
|
ProjectileSpeed = projectileDataAsset->ProjectileSpeed;
|
||||||
ProjectileMovement->InitialSpeed = ProjectileSpeed;
|
ProjectileMovement->InitialSpeed = ProjectileSpeed;
|
||||||
ProjectileMovement->MaxSpeed = ProjectileSpeed;
|
ProjectileMovement->MaxSpeed = ProjectileSpeed;
|
||||||
|
RemainingDamagableEnemies = projectileDataAsset->DamagableEnemies;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AProjectile::ResetData_Implementation()
|
void AProjectile::ResetData_Implementation()
|
||||||
{
|
{
|
||||||
ProjectileSpeed = NULL;
|
ProjectileSpeed = NULL;
|
||||||
StaticMeshComponent->SetStaticMesh(nullptr);
|
StaticMeshComponent->SetStaticMesh(nullptr);
|
||||||
|
RemainingDamagableEnemies = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AProjectile::OnProjectileBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
void AProjectile::OnProjectileBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||||
@ -96,6 +98,10 @@ void AProjectile::OnProjectileBeginOverlap(UPrimitiveComponent* OverlappedCompon
|
|||||||
AProjectileWeapon* ownerWeapon = Cast<AProjectileWeapon>(GetOwner());
|
AProjectileWeapon* ownerWeapon = Cast<AProjectileWeapon>(GetOwner());
|
||||||
EnemyHealthComponent->TakeDamage(Enemy, ownerWeapon->Damage, nullptr, ownerController, this);
|
EnemyHealthComponent->TakeDamage(Enemy, ownerWeapon->Damage, nullptr, ownerController, this);
|
||||||
|
|
||||||
|
RemainingDamagableEnemies--;
|
||||||
|
|
||||||
|
if (RemainingDamagableEnemies == 0)
|
||||||
|
{
|
||||||
AGameModeBase* gamemode = UGameplayStatics::GetGameMode(GetWorld());
|
AGameModeBase* gamemode = UGameplayStatics::GetGameMode(GetWorld());
|
||||||
|
|
||||||
if (UKismetSystemLibrary::DoesImplementInterface(gamemode, UPools::StaticClass()))
|
if (UKismetSystemLibrary::DoesImplementInterface(gamemode, UPools::StaticClass()))
|
||||||
@ -108,3 +114,4 @@ void AProjectile::OnProjectileBeginOverlap(UPrimitiveComponent* OverlappedCompon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -31,6 +31,9 @@ public:
|
|||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
UStaticMeshComponent* StaticMeshComponent = nullptr;
|
UStaticMeshComponent* StaticMeshComponent = nullptr;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
int RemainingDamagableEnemies = 1;
|
||||||
|
|
||||||
// Sets default values for this actor's properties
|
// Sets default values for this actor's properties
|
||||||
AProjectile();
|
AProjectile();
|
||||||
|
|
||||||
|
@ -16,8 +16,11 @@ class VAMPIRES_API UProjectileDataAsset : public UDataAsset
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
float ProjectileSpeed = 500.0f;
|
float ProjectileSpeed = 1000.0f;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
TObjectPtr<UStaticMesh> StaticMesh;
|
TObjectPtr<UStaticMesh> StaticMesh;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
int DamagableEnemies = 1;
|
||||||
};
|
};
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "vampires/ObjectPoolManager.h"
|
#include "vampires/ObjectPoolManager.h"
|
||||||
#include "vampires/PlayerCharacter.h"
|
#include "vampires/PlayerCharacter.h"
|
||||||
#include "vampires/Projectile.h"
|
#include "vampires/Projectile.h"
|
||||||
|
#include "vampires/ProjectileDataAsset.h"
|
||||||
#include "vampires/Interfaces/Pools.h"
|
#include "vampires/Interfaces/Pools.h"
|
||||||
|
|
||||||
AKnifeWeapon::AKnifeWeapon()
|
AKnifeWeapon::AKnifeWeapon()
|
||||||
@ -22,7 +23,46 @@ void AKnifeWeapon::BeginPlay()
|
|||||||
void AKnifeWeapon::FireWeaponAction_Implementation()
|
void AKnifeWeapon::FireWeaponAction_Implementation()
|
||||||
{
|
{
|
||||||
Super::FireWeaponAction_Implementation();
|
Super::FireWeaponAction_Implementation();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AKnifeWeapon::UpgradeWeapon_Implementation()
|
||||||
|
{
|
||||||
|
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->DamagableEnemies++;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
ProjectilesPerActivation++;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
ProjectilesPerActivation++;
|
||||||
|
Damage += 5.0f;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
ProjectileTemplate->DamagableEnemies++;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AKnifeWeapon::FireProjectile()
|
||||||
|
{
|
||||||
if (UKismetSystemLibrary::DoesImplementInterface(GetOwner(), UInputable::StaticClass()))
|
if (UKismetSystemLibrary::DoesImplementInterface(GetOwner(), UInputable::StaticClass()))
|
||||||
{
|
{
|
||||||
if (ProjectileTemplate && OverlappedEnemies.Num() > 0)
|
if (ProjectileTemplate && OverlappedEnemies.Num() > 0)
|
||||||
@ -46,6 +86,8 @@ void AKnifeWeapon::FireWeaponAction_Implementation()
|
|||||||
|
|
||||||
IProjectilable::Execute_SetTargetDirection(projectile, direction);
|
IProjectilable::Execute_SetTargetDirection(projectile, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Super::FireProjectile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,4 +22,9 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void FireWeaponAction_Implementation() override;
|
virtual void FireWeaponAction_Implementation() override;
|
||||||
|
|
||||||
|
virtual bool UpgradeWeapon_Implementation() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void FireProjectile() override;
|
||||||
};
|
};
|
||||||
|
@ -63,3 +63,20 @@ void AProjectileWeapon::OnWeaponEndOverlap(UPrimitiveComponent* OverlappedComp,
|
|||||||
OverlappedEnemies.Remove(Enemy);
|
OverlappedEnemies.Remove(Enemy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AProjectileWeapon::FireWeaponAction_Implementation()
|
||||||
|
{
|
||||||
|
Super::FireWeaponAction_Implementation();
|
||||||
|
|
||||||
|
remainingProjectilesToSpawn = ProjectilesPerActivation;
|
||||||
|
GetWorldTimerManager().SetTimer(FireProjectileTimerHandler, this, &AProjectileWeapon::FireProjectile, ProjectileSpawningDelay, true, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AProjectileWeapon::FireProjectile()
|
||||||
|
{
|
||||||
|
remainingProjectilesToSpawn--;
|
||||||
|
if (remainingProjectilesToSpawn == 0)
|
||||||
|
{
|
||||||
|
GetWorldTimerManager().ClearTimer(FireProjectileTimerHandler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -25,9 +25,20 @@ public:
|
|||||||
UPROPERTY(EditAnywhere, Category = "Weapon Properties")
|
UPROPERTY(EditAnywhere, Category = "Weapon Properties")
|
||||||
TObjectPtr<UProjectileDataAsset> ProjectileTemplate = nullptr;
|
TObjectPtr<UProjectileDataAsset> ProjectileTemplate = nullptr;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
|
int ProjectilesPerActivation = 1;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
|
float ProjectileSpawningDelay = 0.25f;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TArray<AActor*> OverlappedEnemies = TArray<AActor*>();
|
TArray<AActor*> OverlappedEnemies = TArray<AActor*>();
|
||||||
|
|
||||||
|
FTimerHandle FireProjectileTimerHandler;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int remainingProjectilesToSpawn = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AProjectileWeapon();
|
AProjectileWeapon();
|
||||||
|
|
||||||
@ -43,4 +54,10 @@ public:
|
|||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void OnWeaponEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
|
void OnWeaponEndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
|
||||||
int32 OtherBodyIndex);
|
int32 OtherBodyIndex);
|
||||||
|
|
||||||
|
virtual void FireWeaponAction_Implementation() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
UFUNCTION()
|
||||||
|
virtual void FireProjectile();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user