From 17916321f28de8246255cbaa5d9c8e8ec312418b Mon Sep 17 00:00:00 2001 From: Rafal Swierczek <34179rs@gmail.com> Date: Wed, 11 Oct 2023 13:20:28 +0100 Subject: [PATCH] Implemented Favour Buying System Wituout UI --- .../BountySystem/BountyDirector.cpp | 59 ++++++++++++++++++- .../BountySystem/BountyDirector.h | 27 ++++++++- .../EndlessVendettaCharacter.h | 2 + 3 files changed, 86 insertions(+), 2 deletions(-) diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.cpp b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.cpp index f2a11b38..8e87f2e3 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.cpp @@ -119,11 +119,68 @@ void ABountyDirector::DestroyActiveSideBounties() UpdateBountyDisplay(); } +// ----------- Favour Shop --------------- + void ABountyDirector::EarnFavours(int FavoursEarned) { - UE_LOG(LogTemp, Warning, TEXT("Earned %d favours"), FavoursEarned); + Favours += FavoursEarned; +} + +void ABountyDirector::BuyCustomBountyAlteration_1() +{ + if (!IsValid(ActiveBounty)) return; + int Cost = ActiveBounty->GetCustomBountyAlteration_1_Cost(); + if (Favours < Cost) return; + Favours -= Cost; + ActiveBounty->BuyCustomBountyAlteration_1(); } +void ABountyDirector::BuyCustomBountyAlteration_2() +{ + if (!IsValid(ActiveBounty)) return; + int Cost = ActiveBounty->GetCustomBountyAlteration_2_Cost(); + if (Favours < Cost) return; + Favours -= Cost; + ActiveBounty->BuyCustomBountyAlteration_2(); +} +void ABountyDirector::BuyCustomBountyAlteration_3() +{ + if (!IsValid(ActiveBounty)) return; + int Cost = ActiveBounty->GetCustomBountyAlteration_3_Cost(); + if (Favours < Cost) return; + Favours -= Cost; + ActiveBounty->BuyCustomBountyAlteration_3(); +} +void ABountyDirector::BuyAmmoDrop() +{ + if (!IsValid(ActiveBounty)) return; + if (Favours < 1) return; + Favours--; + ActiveBounty->BuySpawnAmmoDrops(); +} + +void ABountyDirector::BuyHealthDrop() +{ + if (!IsValid(ActiveBounty)) return; + if (Favours < 1) return; + Favours--; + ActiveBounty->BuySpawnHealthDrops(); +} + +void ABountyDirector::BuyEnemyRadio() +{ + if (!IsValid(ActiveBounty)) return; + if (Favours < 1) return; + Favours--; + ActiveBounty->BuyEnemyRadio(); +} + +void ABountyDirector::BuyFavours() +{ + if (PlayerChar->Money < FavourCost) return; + PlayerChar->Money -= FavourCost; + Favours++; +} \ No newline at end of file diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.h b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.h index 08a92bc6..dcaa927b 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.h +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.h @@ -20,9 +20,12 @@ class ENDLESSVENDETTA_API ABountyDirector : public AActor UArrowComponent* BountyAttachmentPoint; // Ordered Array of Main Bounties - UPROPERTY(EditDefaultsOnly, Category = "Bounty") + UPROPERTY(EditDefaultsOnly, Category = "Bounty Director") TArray> BountyClassArray; + UPROPERTY(EditDefaultsOnly, Category = "Bounty Director") + int FavourCost = 500; + int CurrentBountyIndex = 0; UPROPERTY(VisibleAnywhere, Category = "Bounty") @@ -41,6 +44,7 @@ class ENDLESSVENDETTA_API ABountyDirector : public AActor void FinishActiveBounty(); protected: + int Favours = 0; // Called when the game starts or when spawned virtual void BeginPlay() override; @@ -55,6 +59,27 @@ protected: UFUNCTION() void EarnFavours(int FavoursEarned); + UFUNCTION(BlueprintCallable, Category = "Bounty Director") + void BuyCustomBountyAlteration_1(); + + UFUNCTION(BlueprintCallable, Category = "Bounty Director") + void BuyCustomBountyAlteration_2(); + + UFUNCTION(BlueprintCallable, Category = "Bounty Director") + void BuyCustomBountyAlteration_3(); + + UFUNCTION(BlueprintCallable, Category = "Bounty Director") + void BuyAmmoDrop(); + + UFUNCTION(BlueprintCallable, Category = "Bounty Director") + void BuyHealthDrop(); + + UFUNCTION(BlueprintCallable, Category = "Bounty Director") + void BuyEnemyRadio(); + + UFUNCTION(BlueprintCallable, Category = "Bounty Director") + void BuyFavours(); + public: // Called every frame virtual void Tick(float DeltaTime) override; diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h index 3fb99716..b1c84ec7 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h @@ -86,6 +86,8 @@ protected: AGadgetManager* GadgetManager; public: + int Money = 2000; + /** Look Input Action */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true")) class UInputAction* LookAction;