From d32b2fc6f556c8765380273ae62c30335c114aab Mon Sep 17 00:00:00 2001 From: Rafal Swierczek <34179rs@gmail.com> Date: Sun, 15 Oct 2023 13:07:20 +0100 Subject: [PATCH] Implemented All Favour Buying Buttons --- .../BountyDirector/WBP_PC_Display.uasset | 4 +-- .../MainBounty/MB_TestBounty.uasset | 4 +-- .../HDRI/HDRI_Epic_Courtyard_Daylight.uasset | 4 +-- .../Props/MaterialSphere.uasset | 4 +-- .../BountySystem/BountyDirector.cpp | 32 ++++++++++------- .../BountySystem/BountyDirector.h | 28 +++++++-------- .../BountySystem/MainBountyClass.cpp | 30 ++++++++-------- .../BountySystem/MainBountyClass.h | 13 +++---- .../EndlessVendetta/UserWidgets/PC_Display.h | 34 ++++++++++++++----- 9 files changed, 91 insertions(+), 62 deletions(-) diff --git a/EndlessVendetta/Content/BountySystem/BountyDirector/WBP_PC_Display.uasset b/EndlessVendetta/Content/BountySystem/BountyDirector/WBP_PC_Display.uasset index c5d78681..5e266442 100644 --- a/EndlessVendetta/Content/BountySystem/BountyDirector/WBP_PC_Display.uasset +++ b/EndlessVendetta/Content/BountySystem/BountyDirector/WBP_PC_Display.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e18f1c5b5a87200f0a39ce1a55e9b8e5f1def9f890d5974e8fe5c767efe868d3 -size 1025165 +oid sha256:acab50641ebfd8ec73bda00d7ce661f23e7773e4b88863de1982b34b52ebc114 +size 1026639 diff --git a/EndlessVendetta/Content/BountySystem/TestBounties/FavourSystemBountyTest/MainBounty/MB_TestBounty.uasset b/EndlessVendetta/Content/BountySystem/TestBounties/FavourSystemBountyTest/MainBounty/MB_TestBounty.uasset index f805cb3d..0309cf1b 100644 --- a/EndlessVendetta/Content/BountySystem/TestBounties/FavourSystemBountyTest/MainBounty/MB_TestBounty.uasset +++ b/EndlessVendetta/Content/BountySystem/TestBounties/FavourSystemBountyTest/MainBounty/MB_TestBounty.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:27d63c0acfd4fdceacc37b252fac625161c9feddfe9b2ccaeff6b4e84f1d9857 -size 25558 +oid sha256:3bee98bbd8e50e208c8f9ee6c2a8560f183a2bba774f090b183ab236ba7ebd22 +size 38649 diff --git a/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset b/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset index 0f990580..92a6630d 100644 --- a/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset +++ b/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bc35eb2d43a47427d30aba0196f9eac90d089dd3abca319528c5d25c83510d0d -size 72364642 +oid sha256:121885d21829880bc9b29a22c541e1e2113f964beb1a5307902cd6b2d550bea5 +size 66790690 diff --git a/EndlessVendetta/Content/StarterContent/Props/MaterialSphere.uasset b/EndlessVendetta/Content/StarterContent/Props/MaterialSphere.uasset index 34eb8e6b..56bddfc9 100644 --- a/EndlessVendetta/Content/StarterContent/Props/MaterialSphere.uasset +++ b/EndlessVendetta/Content/StarterContent/Props/MaterialSphere.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8fe02baa138e086ccfe9f77f87f3898fb489e4e132a4164798fbbb9a6680bef2 -size 47710 +oid sha256:3a8777c01491888bba9f40eda9d2bed76a611f0e80f75917501ce69c1a321342 +size 47333 diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.cpp b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.cpp index 75d4ae39..e11b7841 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.cpp @@ -37,7 +37,6 @@ void ABountyDirector::BeginPlay() } SpawnBountyAndItsSideBounties(); - UpdateBountyDisplay(); } void ABountyDirector::SpawnBountyAndItsSideBounties() @@ -97,12 +96,10 @@ void ABountyDirector::FinishActiveBounty() { UE_LOG(LogTemp, Warning, TEXT("Finished all bounties currently available in the game :)")); ActiveBounty = nullptr; - UpdateBountyDisplay(); return; } SpawnBountyAndItsSideBounties(); - UpdateBountyDisplay(); } void ABountyDirector::DestroyActiveSideBounties() @@ -116,8 +113,6 @@ void ABountyDirector::DestroyActiveSideBounties() SideBounty->DestroyCheckpoints(); SideBounty->Destroy(); } - - UpdateBountyDisplay(); } // ----------- Favour Shop --------------- @@ -133,7 +128,8 @@ void ABountyDirector::BuyCustomBountyAlteration_1() int Cost = ActiveBounty->GetCustomBountyAlteration_1_Cost(); if (Cost == 0 || Favours < Cost) return; Favours -= Cost; - ActiveBounty->BuyCustomBountyAlteration_1(); + PC_Display->UpdateFavourCount(Favours); + ActiveBounty->ActivateCustomBountyAlteration_1(); } @@ -143,7 +139,8 @@ void ABountyDirector::BuyCustomBountyAlteration_2() int Cost = ActiveBounty->GetCustomBountyAlteration_2_Cost(); if (Cost == 0 || Favours < Cost) return; Favours -= Cost; - ActiveBounty->BuyCustomBountyAlteration_2(); + PC_Display->UpdateFavourCount(Favours); + ActiveBounty->ActivateCustomBountyAlteration_2(); } void ABountyDirector::BuyCustomBountyAlteration_3() @@ -152,7 +149,8 @@ void ABountyDirector::BuyCustomBountyAlteration_3() int Cost = ActiveBounty->GetCustomBountyAlteration_3_Cost(); if (Cost == 0 || Favours < Cost) return; Favours -= Cost; - ActiveBounty->BuyCustomBountyAlteration_3(); + PC_Display->UpdateFavourCount(Favours); + ActiveBounty->ActivateCustomBountyAlteration_3(); } void ABountyDirector::BuyAmmoDrop() @@ -160,7 +158,8 @@ void ABountyDirector::BuyAmmoDrop() if (!IsValid(ActiveBounty)) return; if (Favours < 1) return; Favours--; - ActiveBounty->BuySpawnAmmoDrops(); + PC_Display->UpdateFavourCount(Favours); + ActiveBounty->SpawnAmmoDrops(); } void ABountyDirector::BuyHealthDrop() @@ -168,7 +167,8 @@ void ABountyDirector::BuyHealthDrop() if (!IsValid(ActiveBounty)) return; if (Favours < 1) return; Favours--; - ActiveBounty->BuySpawnHealthDrops(); + PC_Display->UpdateFavourCount(Favours); + ActiveBounty->SpawnHealthDrops(); } void ABountyDirector::BuyEnemyRadio() @@ -176,7 +176,8 @@ void ABountyDirector::BuyEnemyRadio() if (!IsValid(ActiveBounty)) return; if (Favours < 1) return; Favours--; - ActiveBounty->BuyEnemyRadio(); + PC_Display->UpdateFavourCount(Favours); + ActiveBounty->ActivateEnemyRadio(); } void ABountyDirector::BuyFavours() @@ -184,6 +185,7 @@ void ABountyDirector::BuyFavours() if (PlayerChar->Money < FavourCost) return; PlayerChar->Money -= FavourCost; Favours++; + PC_Display->UpdateFavourCount(Favours); } // ----------- PC Display --------------- @@ -202,7 +204,7 @@ void ABountyDirector::Interact() PlayerController->bEnableClickEvents = true; PlayerController->bEnableMouseOverEvents = true; - UPC_Display* PC_Display = Cast(PC_DisplayWidget); + PC_Display = Cast(PC_DisplayWidget); bool GameOver = !IsValid(ActiveBounty); PC_Display->PC_Display_Info.IsGameOver = GameOver; PC_Display->LogoutFromBountyDirectorPC.AddDynamic(this, &ABountyDirector::DestroyBountyDirectorPCWidget); @@ -248,6 +250,12 @@ void ABountyDirector::Interact() // Button Delegates PC_Display->BuyCba_1.AddDynamic(this, &ABountyDirector::BuyCustomBountyAlteration_1); + PC_Display->BuyCba_2.AddDynamic(this, &ABountyDirector::BuyCustomBountyAlteration_2); + PC_Display->BuyCba_3.AddDynamic(this, &ABountyDirector::BuyCustomBountyAlteration_3); + PC_Display->BuyAmmoDrop.AddDynamic(this, &ABountyDirector::BuyAmmoDrop); + PC_Display->BuyHealthDrop.AddDynamic(this, &ABountyDirector::BuyHealthDrop); + PC_Display->BuyRadio.AddDynamic(this, &ABountyDirector::BuyEnemyRadio); + PC_Display->BuyFavour.AddDynamic(this, &ABountyDirector::BuyFavours); PC_Display->LoadOS(); } diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.h b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.h index a2a64d45..41fc840c 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.h +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyDirector.h @@ -33,6 +33,8 @@ class ENDLESSVENDETTA_API ABountyDirector : public AInteractableActor UUserWidget* PC_DisplayWidget; + UPC_Display* PC_Display; + int CurrentBountyIndex = 0; UPROPERTY(VisibleAnywhere, Category = "Bounty") @@ -42,7 +44,6 @@ class ENDLESSVENDETTA_API ABountyDirector : public AInteractableActor TArray ActiveSideBounties; // Checks if completed the bounty, and moves onto the next if so - //UFUNCTION(BlueprintCallable, Category = "Bounty") void UpdateBountyProgression(); void SpawnBountyAndItsSideBounties(); @@ -50,46 +51,45 @@ class ENDLESSVENDETTA_API ABountyDirector : public AInteractableActor // Collect reward for current Bounty and prepare for the next void FinishActiveBounty(); + // Opens up Bounty Director PC Interface void Interact() override; protected: int Favours = 20; + // Called when the game starts or when spawned virtual void BeginPlay() override; - - /** Blueprint implemented function called from c++, handles aesthetic changes to bounty display - based on data from ActiveBC and ActiveSBC */ - UFUNCTION(BlueprintImplementableEvent, Category = "bounty") - void UpdateBountyDisplay(); - + UFUNCTION() void DestroyActiveSideBounties(); UFUNCTION() void DestroyBountyDirectorPCWidget(); + // Listens for when a side bounty is completed UFUNCTION() void EarnFavours(int FavoursEarned); - + +// -------- Buy Buttons -------- UFUNCTION() void BuyCustomBountyAlteration_1(); - UFUNCTION(BlueprintCallable, Category = "Bounty Director") + UFUNCTION() void BuyCustomBountyAlteration_2(); - UFUNCTION(BlueprintCallable, Category = "Bounty Director") + UFUNCTION() void BuyCustomBountyAlteration_3(); - UFUNCTION(BlueprintCallable, Category = "Bounty Director") + UFUNCTION() void BuyAmmoDrop(); - UFUNCTION(BlueprintCallable, Category = "Bounty Director") + UFUNCTION() void BuyHealthDrop(); - UFUNCTION(BlueprintCallable, Category = "Bounty Director") + UFUNCTION() void BuyEnemyRadio(); - UFUNCTION(BlueprintCallable, Category = "Bounty Director") + UFUNCTION() void BuyFavours(); public: diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.cpp b/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.cpp index 714fb672..f6cc0edd 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.cpp @@ -3,22 +3,24 @@ #include "MainBountyClass.h" -void AMainBountyClass::BuySpawnAmmoDrops() +void AMainBountyClass::SpawnAmmoDrops() { - FActorSpawnParameters SpawnParameters; - SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; - for (FTransform Spawn : AmmoDropSpawnTransforms) - { - GetWorld()->SpawnActor(AmmoDropClass, Spawn.GetLocation(), Spawn.GetRotation().Rotator(), SpawnParameters); - } + UE_LOG(LogTemp, Display, TEXT("Bought Ammo Drops, but its not implemented yet")); + // FActorSpawnParameters SpawnParameters; + // SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; + // for (FTransform Spawn : AmmoDropSpawnTransforms) + // { + // GetWorld()->SpawnActor(AmmoDropClass, Spawn.GetLocation(), Spawn.GetRotation().Rotator(), SpawnParameters); + // } } -void AMainBountyClass::BuySpawnHealthDrops() +void AMainBountyClass::SpawnHealthDrops() { - FActorSpawnParameters SpawnParameters; - SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; - for (FTransform Spawn : HealthDropSpawnTransforms) - { - GetWorld()->SpawnActor(HealthDropClass, Spawn.GetLocation(), Spawn.GetRotation().Rotator(), SpawnParameters); - } + UE_LOG(LogTemp, Display, TEXT("Bought Health Drops, but its not implemented yet")); + // FActorSpawnParameters SpawnParameters; + // SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; + // for (FTransform Spawn : HealthDropSpawnTransforms) + // { + // GetWorld()->SpawnActor(HealthDropClass, Spawn.GetLocation(), Spawn.GetRotation().Rotator(), SpawnParameters); + // } } \ No newline at end of file diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.h b/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.h index 2ca99a55..47109d1e 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/MainBountyClass.h @@ -48,13 +48,13 @@ public: // ------------- Custom Bounty Alterations ------------- UFUNCTION(BlueprintImplementableEvent, Category = "Bounty") - void BuyCustomBountyAlteration_1(); + void ActivateCustomBountyAlteration_1(); UFUNCTION(BlueprintImplementableEvent, Category = "Bounty") - void BuyCustomBountyAlteration_2(); + void ActivateCustomBountyAlteration_2(); UFUNCTION(BlueprintImplementableEvent, Category = "Bounty") - void BuyCustomBountyAlteration_3(); + void ActivateCustomBountyAlteration_3(); UFUNCTION(BlueprintCallable, Category = "Bounty") FString GetCustomBountyAlteration_1_Description() @@ -93,12 +93,13 @@ public: } // ------------- Simple Bounty Alterations ------------- - void BuySpawnAmmoDrops(); + void SpawnAmmoDrops(); - void BuySpawnHealthDrops(); + void SpawnHealthDrops(); - void BuyEnemyRadio() + void ActivateEnemyRadio() { + UE_LOG(LogTemp, Display, TEXT("Bought Radio, but it's not implemented yet")); HasEnemyRadio = true; } diff --git a/EndlessVendetta/Source/EndlessVendetta/UserWidgets/PC_Display.h b/EndlessVendetta/Source/EndlessVendetta/UserWidgets/PC_Display.h index 0a2df784..e2d8a2ca 100644 --- a/EndlessVendetta/Source/EndlessVendetta/UserWidgets/PC_Display.h +++ b/EndlessVendetta/Source/EndlessVendetta/UserWidgets/PC_Display.h @@ -47,29 +47,47 @@ struct FPC_Display_Info DECLARE_DYNAMIC_MULTICAST_DELEGATE(FLogoutFromBountyDirectorPC); DECLARE_DYNAMIC_MULTICAST_DELEGATE(FBuyCBA_1); +DECLARE_DYNAMIC_MULTICAST_DELEGATE(FBuyCBA_2); +DECLARE_DYNAMIC_MULTICAST_DELEGATE(FBuyCBA_3); +DECLARE_DYNAMIC_MULTICAST_DELEGATE(FBuyAmmoDrop); +DECLARE_DYNAMIC_MULTICAST_DELEGATE(FBuyHealthDrop); +DECLARE_DYNAMIC_MULTICAST_DELEGATE(FBuyRadio); +DECLARE_DYNAMIC_MULTICAST_DELEGATE(FBuyFavour); UCLASS() class ENDLESSVENDETTA_API UPC_Display : public UUserWidget { GENERATED_BODY() -protected: - UFUNCTION(BlueprintCallable, Category = "PC_Display") - void LogoutButtonPressed() - { - LogoutFromBountyDirectorPC.Broadcast(); - } - public: + // Button Delegates + UPROPERTY(BlueprintCallable, Category = PC_Display) FLogoutFromBountyDirectorPC LogoutFromBountyDirectorPC; UPROPERTY(BlueprintCallable, Category = PC_Display) FBuyCBA_1 BuyCba_1; + UPROPERTY(BlueprintCallable, Category = PC_Display) + FBuyCBA_2 BuyCba_2; + UPROPERTY(BlueprintCallable, Category = PC_Display) + FBuyCBA_3 BuyCba_3; + UPROPERTY(BlueprintCallable, Category = PC_Display) + FBuyAmmoDrop BuyAmmoDrop; + UPROPERTY(BlueprintCallable, Category = PC_Display) + FBuyHealthDrop BuyHealthDrop; + UPROPERTY(BlueprintCallable, Category = PC_Display) + FBuyRadio BuyRadio; + UPROPERTY(BlueprintCallable, Category = PC_Display) + FBuyFavour BuyFavour; + // USTRUCT UPROPERTY(BlueprintReadOnly) FPC_Display_Info PC_Display_Info; - + + // Takes USTRUCT and uses its values to fill in widget UFUNCTION(BlueprintImplementableEvent, Category = "PC_Display") void LoadOS(); + UFUNCTION(BlueprintImplementableEvent, Category = "PC_Display") + void UpdateFavourCount(int NewFavourCount); + };