Compare commits
No commits in common. "c133ccd1e93f98cdfe402601c9917ff363ccf2ec" and "70f474c5ee208d07c79bc4bb605a33107205e42a" have entirely different histories.
c133ccd1e9
...
70f474c5ee
BIN
Content/Enemy/BP_TestEnemy.uasset
(Stored with Git LFS)
BIN
Content/Enemy/BP_TestEnemy.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Weapons/Garlic/BP_GarlicWeapon.uasset
(Stored with Git LFS)
BIN
Content/Weapons/Garlic/BP_GarlicWeapon.uasset
(Stored with Git LFS)
Binary file not shown.
@ -4,8 +4,8 @@
|
|||||||
#include "VampireCharacter.h"
|
#include "VampireCharacter.h"
|
||||||
|
|
||||||
#include "HealthComponent.h"
|
#include "HealthComponent.h"
|
||||||
|
#include "PaperFlipbookComponent.h"
|
||||||
#include "WeaponInventoryComponent.h"
|
#include "WeaponInventoryComponent.h"
|
||||||
#include "GameFramework/CharacterMovementComponent.h"
|
|
||||||
|
|
||||||
// Sets default values
|
// Sets default values
|
||||||
AVampireCharacter::AVampireCharacter()
|
AVampireCharacter::AVampireCharacter()
|
||||||
@ -21,8 +21,6 @@ AVampireCharacter::AVampireCharacter()
|
|||||||
|
|
||||||
//Create Weapon Inventory Component
|
//Create Weapon Inventory Component
|
||||||
WeaponInventoryComponent = CreateDefaultSubobject<UWeaponInventoryComponent>(TEXT("Weapon Inventory Component"));
|
WeaponInventoryComponent = CreateDefaultSubobject<UWeaponInventoryComponent>(TEXT("Weapon Inventory Component"));
|
||||||
|
|
||||||
GetCharacterMovement()->SetPlaneConstraintNormal({0.0f, 0.0f, 1.0f});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the game starts or when spawned
|
// Called when the game starts or when spawned
|
||||||
|
@ -27,7 +27,7 @@ public:
|
|||||||
UPROPERTY(BlueprintReadWrite, EditAnywhere)
|
UPROPERTY(BlueprintReadWrite, EditAnywhere)
|
||||||
float SlerpSpeed = 10.0f;
|
float SlerpSpeed = 10.0f;
|
||||||
protected:
|
protected:
|
||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY()
|
||||||
UHealthComponent* HealthComponent;
|
UHealthComponent* HealthComponent;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
@ -71,6 +71,9 @@ void AVampireGameMode::SpawnEnemy()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SpawnLocation.Z = PlayerCharacter->GetActorLocation().Z;
|
||||||
|
FTransform Transform;
|
||||||
|
Transform.SetLocation(SpawnLocation);
|
||||||
|
|
||||||
if (AActor* enemy = GetEnemyObjectPoolManager_Implementation()->GetObject())
|
if (AActor* enemy = GetEnemyObjectPoolManager_Implementation()->GetObject())
|
||||||
{
|
{
|
||||||
@ -78,11 +81,7 @@ void AVampireGameMode::SpawnEnemy()
|
|||||||
{
|
{
|
||||||
IEnemyable::Execute_LoadDataFromDataAsset(enemy, EnemyDataAssets[FMath::RandRange(0, EnemyDataAssets.Num() - 1)]);
|
IEnemyable::Execute_LoadDataFromDataAsset(enemy, EnemyDataAssets[FMath::RandRange(0, EnemyDataAssets.Num() - 1)]);
|
||||||
|
|
||||||
SpawnLocation.Z = PlayerCharacter->GetActorLocation().Z;
|
|
||||||
FTransform Transform;
|
|
||||||
Transform.SetLocation(SpawnLocation);
|
|
||||||
enemy->SetActorTransform(Transform);
|
enemy->SetActorTransform(Transform);
|
||||||
|
|
||||||
float CapsuleRadius = IEnemyable::Execute_GetCapsuleRadius(enemy);
|
float CapsuleRadius = IEnemyable::Execute_GetCapsuleRadius(enemy);
|
||||||
FVector Direction = SpawnLocation - PlayerCharacter->GetActorLocation();
|
FVector Direction = SpawnLocation - PlayerCharacter->GetActorLocation();
|
||||||
Direction.Normalize();
|
Direction.Normalize();
|
||||||
|
@ -20,22 +20,21 @@ void AWeapon::BeginPlay()
|
|||||||
GetWorldTimerManager().SetTimer(WeaponTimerHandle, this, &AWeapon::FireWeaponAction, WeaponCooldown, true);
|
GetWorldTimerManager().SetTimer(WeaponTimerHandle, this, &AWeapon::FireWeaponAction, WeaponCooldown, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AWeapon::ResetWeaponTimer()
|
|
||||||
{
|
|
||||||
GetWorldTimerManager().ClearTimer(WeaponTimerHandle);
|
|
||||||
GetWorldTimerManager().SetTimer(WeaponTimerHandle, this, &AWeapon::FireWeaponAction, WeaponCooldown, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AWeapon::FireWeaponAction_Implementation()
|
void AWeapon::FireWeaponAction_Implementation()
|
||||||
{
|
{
|
||||||
// This should be overridden in child weapon classes
|
// This should be overridden in child weapon classes
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AWeapon::UpgradeWeapon_Implementation()
|
bool AWeapon::UpgradeWeapon()
|
||||||
{
|
{
|
||||||
if (CurrentLevel < MaxLevel)
|
if (CurrentLevel + 1 <= Upgrades.Num())
|
||||||
{
|
{
|
||||||
CurrentLevel++;
|
CurrentLevel++;
|
||||||
|
WeaponCooldown *= Upgrades[CurrentLevel - 1].WeaponCooldownMultiplier;
|
||||||
|
Damage *= Upgrades[CurrentLevel - 1].WeaponDamageMultiplier;
|
||||||
|
|
||||||
|
GetWorldTimerManager().ClearTimer(WeaponTimerHandle);
|
||||||
|
GetWorldTimerManager().SetTimer(WeaponTimerHandle, this, &AWeapon::FireWeaponAction, WeaponCooldown, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,24 @@
|
|||||||
class UPaperSprite;
|
class UPaperSprite;
|
||||||
class UWeaponDataAsset;
|
class UWeaponDataAsset;
|
||||||
|
|
||||||
|
USTRUCT(BlueprintType)
|
||||||
|
struct FWeaponLevelUpgrades
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ClampMin = 0.01f, ClampMax = 1.0f))
|
||||||
|
float WeaponCooldownMultiplier = 1.0f;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ClampMin = 0.01f))
|
||||||
|
float WeaponDamageMultiplier = 1.0f;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ClampMin = 0.01f))
|
||||||
|
float WeaponRangeMultiplier = 1.0f;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
FText WeaponUpgradeText;
|
||||||
|
};
|
||||||
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class VAMPIRES_API AWeapon : public AActor
|
class VAMPIRES_API AWeapon : public AActor
|
||||||
{
|
{
|
||||||
@ -37,13 +55,10 @@ public:
|
|||||||
float Damage;
|
float Damage;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties")
|
||||||
TArray<FText> UpgradeDescriptions;
|
TArray<FWeaponLevelUpgrades> Upgrades = TArray<FWeaponLevelUpgrades>();
|
||||||
|
|
||||||
int CurrentLevel = 0;
|
int CurrentLevel = 0;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
|
|
||||||
int MaxLevel = 0;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FTimerHandle WeaponTimerHandle;
|
FTimerHandle WeaponTimerHandle;
|
||||||
|
|
||||||
@ -56,14 +71,11 @@ protected:
|
|||||||
// Called when the game starts or when spawned
|
// Called when the game starts or when spawned
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
void ResetWeaponTimer();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UFUNCTION(BlueprintNativeEvent)
|
UFUNCTION(BlueprintNativeEvent)
|
||||||
void FireWeaponAction();
|
void FireWeaponAction();
|
||||||
virtual void FireWeaponAction_Implementation();
|
virtual void FireWeaponAction_Implementation();
|
||||||
|
|
||||||
UFUNCTION(BlueprintNativeEvent)
|
UFUNCTION()
|
||||||
bool UpgradeWeapon();
|
virtual bool UpgradeWeapon();
|
||||||
virtual bool UpgradeWeapon_Implementation();
|
|
||||||
};
|
};
|
||||||
|
@ -83,7 +83,6 @@ void AGarlicWeapon::GarlicFireWeaponAction(FOverlappedEnemy EnemyCharacter)
|
|||||||
{
|
{
|
||||||
FVector Direction = EnemyCharacter.OverlappedEnemyCharacter->GetActorLocation() - this->GetActorLocation();
|
FVector Direction = EnemyCharacter.OverlappedEnemyCharacter->GetActorLocation() - this->GetActorLocation();
|
||||||
Direction.Normalize();
|
Direction.Normalize();
|
||||||
Direction.Z = 0.0f;
|
|
||||||
float distance = SphereComponent->GetScaledSphereRadius();
|
float distance = SphereComponent->GetScaledSphereRadius();
|
||||||
Direction *= distance;
|
Direction *= distance;
|
||||||
EnemyCharacter.OverlappedEnemyCharacter->SetActorLocation(
|
EnemyCharacter.OverlappedEnemyCharacter->SetActorLocation(
|
||||||
@ -91,48 +90,13 @@ void AGarlicWeapon::GarlicFireWeaponAction(FOverlappedEnemy EnemyCharacter)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AGarlicWeapon::UpgradeWeapon_Implementation()
|
bool AGarlicWeapon::UpgradeWeapon()
|
||||||
{
|
{
|
||||||
if (!Super::UpgradeWeapon_Implementation()) return false;
|
if (Super::UpgradeWeapon())
|
||||||
|
|
||||||
switch (CurrentLevel)
|
|
||||||
{
|
{
|
||||||
case 1:
|
Range *= Upgrades[CurrentLevel - 1].WeaponRangeMultiplier;
|
||||||
Range *= 1.4f;
|
|
||||||
SphereComponent->SetSphereRadius(Range);
|
SphereComponent->SetSphereRadius(Range);
|
||||||
Damage += 2.0f;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
WeaponCooldown -= 0.1f;
|
|
||||||
Damage += 1;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
Range *= 1.2f;
|
|
||||||
SphereComponent->SetSphereRadius(Range);
|
|
||||||
Damage += 1.0f;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
WeaponCooldown -= 0.1f;
|
|
||||||
Damage += 2;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
Range *= 1.2f;
|
|
||||||
SphereComponent->SetSphereRadius(Range);
|
|
||||||
Damage += 1.0f;
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
WeaponCooldown -= 0.1f;
|
|
||||||
Damage += 1;
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
Range *= 1.2f;
|
|
||||||
SphereComponent->SetSphereRadius(Range);
|
|
||||||
Damage += 1.0f;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ResetWeaponTimer();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void GarlicFireWeaponAction(FOverlappedEnemy EnemyCharacter);
|
void GarlicFireWeaponAction(FOverlappedEnemy EnemyCharacter);
|
||||||
|
|
||||||
virtual bool UpgradeWeapon_Implementation() override;
|
virtual bool UpgradeWeapon() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
|
@ -43,7 +43,7 @@ void ULevelUpWidget::NativeConstruct()
|
|||||||
TArray<UUpgradeButtonDataObject*> upgradeItems;
|
TArray<UUpgradeButtonDataObject*> upgradeItems;
|
||||||
for (AWeapon* weapon : Inventory)
|
for (AWeapon* weapon : Inventory)
|
||||||
{
|
{
|
||||||
if (weapon->CurrentLevel < weapon->UpgradeDescriptions.Num())
|
if (weapon->CurrentLevel < weapon->Upgrades.Num())
|
||||||
{
|
{
|
||||||
UUpgradeButtonDataObject* Temp = NewObject<UUpgradeButtonDataObject>(this);
|
UUpgradeButtonDataObject* Temp = NewObject<UUpgradeButtonDataObject>(this);
|
||||||
Temp->SetData(weapon, this);
|
Temp->SetData(weapon, this);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
void UUpgradeButtonDataObject::SetData(AWeapon* Weapon, UUserWidget* parent)
|
void UUpgradeButtonDataObject::SetData(AWeapon* Weapon, UUserWidget* parent)
|
||||||
{
|
{
|
||||||
WeaponName = Weapon->Name;
|
WeaponName = Weapon->Name;
|
||||||
Description = Weapon->UpgradeDescriptions[Weapon->CurrentLevel];
|
Description = Weapon->Description;
|
||||||
WeaponIcon = Weapon->Icon;
|
WeaponIcon = Weapon->Icon;
|
||||||
WeaponInstance = Weapon;
|
WeaponInstance = Weapon;
|
||||||
Parent = parent;
|
Parent = parent;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user