diff --git a/Content/Weapons/DA_ExampleWeapon.uasset b/Content/Weapons/DA_ExampleWeapon.uasset deleted file mode 100644 index 227c151..0000000 --- a/Content/Weapons/DA_ExampleWeapon.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:60f21d7e88b0949d2cc050358268c4a948e557ae240f447102cb43a275fab848 -size 1372 diff --git a/Source/vampires/Weapon.cpp b/Source/vampires/Weapon.cpp index 195d957..4040058 100644 --- a/Source/vampires/Weapon.cpp +++ b/Source/vampires/Weapon.cpp @@ -32,6 +32,22 @@ void AWeapon::FireWeaponAction_Implementation() // Do stuff } -void AWeapon::UpgradeWeapon(int newLevel) +bool AWeapon::UpgradeWeapon() { + return UpgradeWeapon(CurrentLevel + 1); +} + +bool AWeapon::UpgradeWeapon(int newLevel) +{ + if (newLevel < Upgrades.Num()) + { + WeaponCooldown *= Upgrades[newLevel].WeaponCooldownMultiplier; + Damage *= Upgrades[newLevel].WeaponDamageMultiplier; + + GetWorldTimerManager().ClearTimer(WeaponTimerHandle); + GetWorldTimerManager().SetTimer(WeaponTimerHandle, this, &AWeapon::FireWeaponAction, WeaponCooldown, true); + return true; + } + + return false; } diff --git a/Source/vampires/Weapon.h b/Source/vampires/Weapon.h index e85a0b0..1d27e7c 100644 --- a/Source/vampires/Weapon.h +++ b/Source/vampires/Weapon.h @@ -6,23 +6,33 @@ #include "GameFramework/Actor.h" #include "Weapon.generated.h" +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 { GENERATED_BODY() public: - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties") - float WeaponCooldown = 1.0f; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties") - float Damage; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties") - TObjectPtr WeaponDataAsset; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties") FText Name; @@ -32,9 +42,26 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties") TObjectPtr Icon; + UPROPERTY(EditDefaultsOnly, Category = "Weapon Properties") + USoundBase* WeaponActivatedSoundBase = nullptr; + + UPROPERTY(EditDefaultsOnly, Category = "Weapon Properties") + TObjectPtr WeaponSprite = nullptr; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties") + float WeaponCooldown = 1.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties") + float Damage; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties") + TArray Upgrades = TArray(); + private: FTimerHandle WeaponTimerHandle; + int CurrentLevel = 0; + public: // Sets default values for this actor's properties AWeapon(); @@ -49,5 +76,6 @@ public: virtual void FireWeaponAction_Implementation(); UFUNCTION() - virtual void UpgradeWeapon(int newLevel); + virtual bool UpgradeWeapon(); + virtual bool UpgradeWeapon(int newLevel); }; diff --git a/Source/vampires/Weapons/WeaponDataAsset.cpp b/Source/vampires/Weapons/WeaponDataAsset.cpp deleted file mode 100644 index 0d6c5db..0000000 --- a/Source/vampires/Weapons/WeaponDataAsset.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - -#include "WeaponDataAsset.h" diff --git a/Source/vampires/Weapons/WeaponDataAsset.h b/Source/vampires/Weapons/WeaponDataAsset.h deleted file mode 100644 index 4ee3c8e..0000000 --- a/Source/vampires/Weapons/WeaponDataAsset.h +++ /dev/null @@ -1,50 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once - -#include "CoreMinimal.h" -#include "Engine/DataAsset.h" -#include "WeaponDataAsset.generated.h" - -class UPaperSprite; -class AProjectile; - -USTRUCT(BlueprintType) -struct FWeaponLevelUpgrades -{ - GENERATED_BODY() - - UPROPERTY(EditAnywhere, BlueprintReadWrite) - float WeaponCooldownMultiplier; - - UPROPERTY(EditAnywhere, BlueprintReadWrite) - float WeaponDamageMultiplier; - - UPROPERTY(EditAnywhere, BlueprintReadWrite) - float WeaponRangeMultiplier; - - UPROPERTY(EditAnywhere, BlueprintReadWrite) - FText WeaponUpgradeText; -}; - -/** - * - */ -UCLASS(BlueprintType) -class VAMPIRES_API UWeaponDataAsset : public UDataAsset -{ - GENERATED_BODY() - -public: - UPROPERTY(EditDefaultsOnly, Category = "Weapon Properties") - TSubclassOf ProjectileTemplate = nullptr; - - UPROPERTY(EditDefaultsOnly, Category = "Weapon Properties") - USoundBase* WeaponActivatedSoundBase = nullptr; - - UPROPERTY(EditDefaultsOnly, Category = "Weapon Properties") - TObjectPtr WeaponSprite = nullptr; - - UPROPERTY(EditDefaultsOnly, Category = "Weapon Upgrades") - TArray WeaponLevelUpgrades = TArray(); -};