Compare commits
6 Commits
70f474c5ee
...
c133ccd1e9
Author | SHA1 | Date | |
---|---|---|---|
c133ccd1e9 | |||
bd510f297c | |||
9f7d2bf4c7 | |||
55ec2cbfda | |||
bd01f3312d | |||
f3c2da70d0 |
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,6 +21,8 @@ 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()
|
UPROPERTY(VisibleAnywhere)
|
||||||
UHealthComponent* HealthComponent;
|
UHealthComponent* HealthComponent;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
@ -71,9 +71,6 @@ 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())
|
||||||
{
|
{
|
||||||
@ -81,7 +78,11 @@ 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,21 +20,22 @@ 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()
|
bool AWeapon::UpgradeWeapon_Implementation()
|
||||||
{
|
{
|
||||||
if (CurrentLevel + 1 <= Upgrades.Num())
|
if (CurrentLevel < MaxLevel)
|
||||||
{
|
{
|
||||||
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,24 +9,6 @@
|
|||||||
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
|
||||||
{
|
{
|
||||||
@ -55,10 +37,13 @@ public:
|
|||||||
float Damage;
|
float Damage;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties")
|
||||||
TArray<FWeaponLevelUpgrades> Upgrades = TArray<FWeaponLevelUpgrades>();
|
TArray<FText> UpgradeDescriptions;
|
||||||
|
|
||||||
int CurrentLevel = 0;
|
int CurrentLevel = 0;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
|
||||||
|
int MaxLevel = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FTimerHandle WeaponTimerHandle;
|
FTimerHandle WeaponTimerHandle;
|
||||||
|
|
||||||
@ -71,11 +56,14 @@ 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()
|
UFUNCTION(BlueprintNativeEvent)
|
||||||
virtual bool UpgradeWeapon();
|
bool UpgradeWeapon();
|
||||||
|
virtual bool UpgradeWeapon_Implementation();
|
||||||
};
|
};
|
||||||
|
@ -83,6 +83,7 @@ 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(
|
||||||
@ -90,13 +91,48 @@ void AGarlicWeapon::GarlicFireWeaponAction(FOverlappedEnemy EnemyCharacter)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AGarlicWeapon::UpgradeWeapon()
|
bool AGarlicWeapon::UpgradeWeapon_Implementation()
|
||||||
{
|
{
|
||||||
if (Super::UpgradeWeapon())
|
if (!Super::UpgradeWeapon_Implementation()) return false;
|
||||||
|
|
||||||
|
switch (CurrentLevel)
|
||||||
{
|
{
|
||||||
Range *= Upgrades[CurrentLevel - 1].WeaponRangeMultiplier;
|
case 1:
|
||||||
|
Range *= 1.4f;
|
||||||
SphereComponent->SetSphereRadius(Range);
|
SphereComponent->SetSphereRadius(Range);
|
||||||
return true;
|
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;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ResetWeaponTimer();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void GarlicFireWeaponAction(FOverlappedEnemy EnemyCharacter);
|
void GarlicFireWeaponAction(FOverlappedEnemy EnemyCharacter);
|
||||||
|
|
||||||
virtual bool UpgradeWeapon() override;
|
virtual bool UpgradeWeapon_Implementation() 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->Upgrades.Num())
|
if (weapon->CurrentLevel < weapon->UpgradeDescriptions.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->Description;
|
Description = Weapon->UpgradeDescriptions[Weapon->CurrentLevel];
|
||||||
WeaponIcon = Weapon->Icon;
|
WeaponIcon = Weapon->Icon;
|
||||||
WeaponInstance = Weapon;
|
WeaponInstance = Weapon;
|
||||||
Parent = parent;
|
Parent = parent;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user