Compare commits
6 Commits
70f474c5ee
...
c133ccd1e9
Author | SHA1 | Date | |
---|---|---|---|
c133ccd1e9 | |||
bd510f297c | |||
9f7d2bf4c7 | |||
55ec2cbfda | |||
bd01f3312d | |||
f3c2da70d0 |
Content
Source/vampires
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 "HealthComponent.h"
|
||||
#include "PaperFlipbookComponent.h"
|
||||
#include "WeaponInventoryComponent.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
|
||||
// Sets default values
|
||||
AVampireCharacter::AVampireCharacter()
|
||||
@ -21,6 +21,8 @@ AVampireCharacter::AVampireCharacter()
|
||||
|
||||
//Create 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
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere)
|
||||
float SlerpSpeed = 10.0f;
|
||||
protected:
|
||||
UPROPERTY()
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UHealthComponent* HealthComponent;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
|
@ -71,9 +71,6 @@ void AVampireGameMode::SpawnEnemy()
|
||||
break;
|
||||
}
|
||||
|
||||
SpawnLocation.Z = PlayerCharacter->GetActorLocation().Z;
|
||||
FTransform Transform;
|
||||
Transform.SetLocation(SpawnLocation);
|
||||
|
||||
if (AActor* enemy = GetEnemyObjectPoolManager_Implementation()->GetObject())
|
||||
{
|
||||
@ -81,7 +78,11 @@ void AVampireGameMode::SpawnEnemy()
|
||||
{
|
||||
IEnemyable::Execute_LoadDataFromDataAsset(enemy, EnemyDataAssets[FMath::RandRange(0, EnemyDataAssets.Num() - 1)]);
|
||||
|
||||
SpawnLocation.Z = PlayerCharacter->GetActorLocation().Z;
|
||||
FTransform Transform;
|
||||
Transform.SetLocation(SpawnLocation);
|
||||
enemy->SetActorTransform(Transform);
|
||||
|
||||
float CapsuleRadius = IEnemyable::Execute_GetCapsuleRadius(enemy);
|
||||
FVector Direction = SpawnLocation - PlayerCharacter->GetActorLocation();
|
||||
Direction.Normalize();
|
||||
|
@ -20,23 +20,24 @@ void AWeapon::BeginPlay()
|
||||
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()
|
||||
{
|
||||
// This should be overridden in child weapon classes
|
||||
}
|
||||
|
||||
bool AWeapon::UpgradeWeapon()
|
||||
bool AWeapon::UpgradeWeapon_Implementation()
|
||||
{
|
||||
if (CurrentLevel + 1 <= Upgrades.Num())
|
||||
if (CurrentLevel < MaxLevel)
|
||||
{
|
||||
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 false;
|
||||
}
|
||||
}
|
||||
|
@ -9,24 +9,6 @@
|
||||
class UPaperSprite;
|
||||
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()
|
||||
class VAMPIRES_API AWeapon : public AActor
|
||||
{
|
||||
@ -55,10 +37,13 @@ public:
|
||||
float Damage;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties")
|
||||
TArray<FWeaponLevelUpgrades> Upgrades = TArray<FWeaponLevelUpgrades>();
|
||||
TArray<FText> UpgradeDescriptions;
|
||||
|
||||
int CurrentLevel = 0;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
|
||||
int MaxLevel = 0;
|
||||
|
||||
private:
|
||||
FTimerHandle WeaponTimerHandle;
|
||||
|
||||
@ -71,11 +56,14 @@ protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
void ResetWeaponTimer();
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintNativeEvent)
|
||||
void FireWeaponAction();
|
||||
virtual void FireWeaponAction_Implementation();
|
||||
|
||||
UFUNCTION()
|
||||
virtual bool UpgradeWeapon();
|
||||
UFUNCTION(BlueprintNativeEvent)
|
||||
bool UpgradeWeapon();
|
||||
virtual bool UpgradeWeapon_Implementation();
|
||||
};
|
||||
|
@ -83,6 +83,7 @@ void AGarlicWeapon::GarlicFireWeaponAction(FOverlappedEnemy EnemyCharacter)
|
||||
{
|
||||
FVector Direction = EnemyCharacter.OverlappedEnemyCharacter->GetActorLocation() - this->GetActorLocation();
|
||||
Direction.Normalize();
|
||||
Direction.Z = 0.0f;
|
||||
float distance = SphereComponent->GetScaledSphereRadius();
|
||||
Direction *= distance;
|
||||
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;
|
||||
SphereComponent->SetSphereRadius(Range);
|
||||
return true;
|
||||
case 1:
|
||||
Range *= 1.4f;
|
||||
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;
|
||||
}
|
||||
return false;
|
||||
|
||||
ResetWeaponTimer();
|
||||
return true;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
UFUNCTION()
|
||||
void GarlicFireWeaponAction(FOverlappedEnemy EnemyCharacter);
|
||||
|
||||
virtual bool UpgradeWeapon() override;
|
||||
virtual bool UpgradeWeapon_Implementation() override;
|
||||
|
||||
protected:
|
||||
UFUNCTION()
|
||||
|
@ -43,7 +43,7 @@ void ULevelUpWidget::NativeConstruct()
|
||||
TArray<UUpgradeButtonDataObject*> upgradeItems;
|
||||
for (AWeapon* weapon : Inventory)
|
||||
{
|
||||
if (weapon->CurrentLevel < weapon->Upgrades.Num())
|
||||
if (weapon->CurrentLevel < weapon->UpgradeDescriptions.Num())
|
||||
{
|
||||
UUpgradeButtonDataObject* Temp = NewObject<UUpgradeButtonDataObject>(this);
|
||||
Temp->SetData(weapon, this);
|
||||
|
@ -8,7 +8,7 @@
|
||||
void UUpgradeButtonDataObject::SetData(AWeapon* Weapon, UUserWidget* parent)
|
||||
{
|
||||
WeaponName = Weapon->Name;
|
||||
Description = Weapon->Description;
|
||||
Description = Weapon->UpgradeDescriptions[Weapon->CurrentLevel];
|
||||
WeaponIcon = Weapon->Icon;
|
||||
WeaponInstance = Weapon;
|
||||
Parent = parent;
|
||||
|
Loading…
x
Reference in New Issue
Block a user