Implemented Receiving Bounty Awards for Completing Bounties

This commit is contained in:
Rafal Swierczek 2024-02-22 13:52:20 +00:00
parent 1cdaea777e
commit 20c331e8a3
16 changed files with 110 additions and 20 deletions

View File

@ -9,13 +9,18 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="dfa3053d-1d51-4dad-9270-4c17e086f627" name="Changes" comment=""> <list default="true" id="dfa3053d-1d51-4dad-9270-4c17e086f627" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/BountySystem/ControlsTutorial/Bounty/MB_Training.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/BountySystem/ControlsTutorial/Bounty/MB_Training.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/PauseMenu/WBP_PauseMenu.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/PauseMenu/WBP_PauseMenu.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/StarterContent/Architecture/Floor_400x400.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/Architecture/Floor_400x400.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/StarterContent/Blueprints/Blueprint_CeilingLight.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/Blueprints/Blueprint_CeilingLight.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/BountyClass.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/BountyClass.h" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/BountyClass.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/BountyClass.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/BountyDirector.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/BountyDirector.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/MainBountyClass.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/MainBountyClass.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/SideBountyClass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/SideBountyClass.cpp" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/SideBountyClass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/SideBountyClass.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/SideBountyClass.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/SideBountyClass.h" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/SideBountyClass.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/SideBountyClass.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.h" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/EVGameInstance.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/EVGameInstance.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/MainSaveGameClass.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/MainSaveGameClass.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/PauseMenu/PauseMenuClass.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/PauseMenu/PauseMenuClass.h" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -146,6 +151,8 @@
<workItem from="1708089465885" duration="1591000" /> <workItem from="1708089465885" duration="1591000" />
<workItem from="1708180486567" duration="2641000" /> <workItem from="1708180486567" duration="2641000" />
<workItem from="1708269543495" duration="2914000" /> <workItem from="1708269543495" duration="2914000" />
<workItem from="1708434176965" duration="6053000" />
<workItem from="1708607826264" duration="1417000" />
</task> </task>
<servers /> <servers />
</component> </component>

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:474599332f82e0e18990902c5a79b7de5dd80a4e9c7fe016b22fd4280f96936e oid sha256:6cdc863b9bd4477a188dfba127b747fad85d5a2be2adba1663696d88db0ca63c
size 80064 size 82240

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:7f9eeb93d9528280841ebfa552cc29d769515d093467e822741471ff85488699 oid sha256:0d4289da6b9ff9cbe01059bf37b1d3a758f45d2609be2e75283085f0f135d978
size 308710 size 308758

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:64ca05e586e2efad00caccb8877e80ff186de099c7271b368fea7ed544606929 oid sha256:ff738c6b1ccafb79a8381f4e2ae3b6015ba59a191a0f50db49b6864f0426489f
size 485440 size 508962

View File

@ -32,6 +32,12 @@ protected:
public: public:
FCompletedACheckpoint CompletedACheckpoint; FCompletedACheckpoint CompletedACheckpoint;
// Gets the Reward Money for Completing this Bounty, used by Players Character
int GetRewardMoney()
{
return RewardMoney;
}
// ------------------- METHODS --------------------------------- // ------------------- METHODS ---------------------------------
private: private:

View File

@ -7,6 +7,7 @@
void ASideBountyClass::BeginPlay() void ASideBountyClass::BeginPlay()
{ {
SideBountyStruct.SideBountyUID = GetUniqueID(); SideBountyStruct.SideBountyUID = GetUniqueID();
SideBountyStruct.MoneyEarnedForCompletion = RewardMoney;
Super::BeginPlay(); Super::BeginPlay();
} }

View File

@ -23,6 +23,8 @@ struct FSideBountyStruct
// Amount of Favours the Player will earn for Completing this Side Bounty // Amount of Favours the Player will earn for Completing this Side Bounty
UPROPERTY(EditDefaultsOnly) UPROPERTY(EditDefaultsOnly)
int FavoursEarnedForCompletion = 1; int FavoursEarnedForCompletion = 1;
int MoneyEarnedForCompletion = 0;
}; };
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCompletedSideBounty, int, SB_UID); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCompletedSideBounty, int, SB_UID);

View File

@ -34,13 +34,14 @@ void ABountyHunterCharacter::SpawnMainBounty(UEVGameInstance* GI)
for (auto SideBounty : CurrentSideBounties) for (auto SideBounty : CurrentSideBounties)
{ {
SideBountyStructs.Add(SideBounty->SideBountyStruct); SideBountyStructs.Add(SideBounty->SideBountyStruct);
SideBounty->CompletedSideBounty.AddDynamic(this, &CompletedASideBounty); SideBounty->CompletedSideBounty.AddDynamic(this, &ABountyHunterCharacter::CompletedASideBounty);
} }
} }
void ABountyHunterCharacter::CompleteCurrentMainBounty(UEVGameInstance* GI) void ABountyHunterCharacter::CompleteCurrentMainBounty(UEVGameInstance* GI)
{ {
// Collect rewards for bounty and move onto next EarnMoney(MainBountyClasses[CurrentMainBountyIndex]->GetDefaultObject<AMainBountyClass>()->GetRewardMoney());
if (IsValid(PauseMenu)) PauseMenu->UpdatePlayerStatistics(Money, Favours);
UE_LOG(LogTemp, Warning, TEXT("Would be collecting reward for completing bounty %d"), CurrentMainBountyIndex); UE_LOG(LogTemp, Warning, TEXT("Would be collecting reward for completing bounty %d"), CurrentMainBountyIndex);
// Saves players spawn now as players location is set after spawn main bounty finishes running in begin play // Saves players spawn now as players location is set after spawn main bounty finishes running in begin play
@ -55,7 +56,9 @@ void ABountyHunterCharacter::CompletedASideBounty(int CompletedSideBountiesUID)
for (auto SBStruct : SideBountyStructs) for (auto SBStruct : SideBountyStructs)
{ {
if (SBStruct.SideBountyUID != CompletedSideBountiesUID) continue; if (SBStruct.SideBountyUID != CompletedSideBountiesUID) continue;
//Continue writing code here about gaining money and favours EarnMoney(SBStruct.MoneyEarnedForCompletion);
EarnFavours(SBStruct.FavoursEarnedForCompletion);
if (IsValid(PauseMenu)) PauseMenu->UpdatePlayerStatistics(Money, Favours);
} }
} }
@ -64,11 +67,22 @@ void ABountyHunterCharacter::AllBountiesCompleted()
UE_LOG(LogTemp, Warning, TEXT("Game Completed!!!! No more Bounties left... or you forgot to set a bounty at one of the indexes oof")); UE_LOG(LogTemp, Warning, TEXT("Game Completed!!!! No more Bounties left... or you forgot to set a bounty at one of the indexes oof"));
} }
void ABountyHunterCharacter::SavePlayerMoneyAndFavours()
{
UEVGameInstance* GI = Cast<UEVGameInstance>(GetGameInstance());
if (!IsValid(GI->MainSaveGameInstanceRef)) return;
GI->MainSaveGameInstanceRef->MoneySave = Money;
GI->MainSaveGameInstanceRef->FavourSave = Favours;
UGameplayStatics::SaveGameToSlot(GI->MainSaveGameInstanceRef, "MainSave", 0);
}
void ABountyHunterCharacter::BeginPlay() void ABountyHunterCharacter::BeginPlay()
{ {
UEVGameInstance* GI = Cast<UEVGameInstance>(GetGameInstance()); UEVGameInstance* GI = Cast<UEVGameInstance>(GetGameInstance());
if (IsValid(GI->MainSaveGameInstanceRef)) if (IsValid(GI->MainSaveGameInstanceRef))
{ {
Money = GI->MainSaveGameInstanceRef->MoneySave;
Favours = GI->MainSaveGameInstanceRef->FavourSave;
SpawnMainBounty(GI); SpawnMainBounty(GI);
FTransform SpawnLoc = GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave; FTransform SpawnLoc = GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave;
if (SpawnLoc.GetLocation() != FVector(0, 0, 0) && UGameplayStatics::GetCurrentLevelName(GetWorld()) == OpenWorldLevelName) if (SpawnLoc.GetLocation() != FVector(0, 0, 0) && UGameplayStatics::GetCurrentLevelName(GetWorld()) == OpenWorldLevelName)
@ -162,6 +176,7 @@ void ABountyHunterCharacter::TogglePauseMenu()
return; return;
} }
PauseMenu = CreateWidget<UPauseMenuClass>(GetWorld(), PauseMenuWidgetClass, FName("PauseMenu")); PauseMenu = CreateWidget<UPauseMenuClass>(GetWorld(), PauseMenuWidgetClass, FName("PauseMenu"));
PauseMenu->UpdatePlayerStatistics(Money, Favours);
PauseMenu->AddToViewport(50); PauseMenu->AddToViewport(50);
PauseMenu->OpenNewTab(BountiesTab); PauseMenu->OpenNewTab(BountiesTab);
PauseMenu->OpenedBountiesTab.AddDynamic(this, &ABountyHunterCharacter::OpenBountiesTab); PauseMenu->OpenedBountiesTab.AddDynamic(this, &ABountyHunterCharacter::OpenBountiesTab);

View File

@ -23,6 +23,12 @@ class ENDLESSVENDETTA_API ABountyHunterCharacter : public AEndlessVendettaCharac
GENERATED_BODY() GENERATED_BODY()
// ------------------- ATTRIBUTES ------------------------------ // ------------------- ATTRIBUTES ------------------------------
// Money Used for Buying things
int Money = 0;
// Favours used for making bounties easier
int Favours = 0;
// Array of Main Bounties' Classes in Order // Array of Main Bounties' Classes in Order
UPROPERTY(EditDefaultsOnly, Category = "Bounty Hunter") UPROPERTY(EditDefaultsOnly, Category = "Bounty Hunter")
TArray<TSubclassOf<AMainBountyClass>> MainBountyClasses; TArray<TSubclassOf<AMainBountyClass>> MainBountyClasses;
@ -45,6 +51,9 @@ protected:
public: public:
// ------------------- METHODS --------------------------------- // ------------------- METHODS ---------------------------------
private: private:
// Spawns Current Main Bounty along with its Side Bounties, and spawns its appropriate CP's based on level // Spawns Current Main Bounty along with its Side Bounties, and spawns its appropriate CP's based on level
@ -60,6 +69,8 @@ private:
// Replaces Normal Bounty Info UI with Unique Game Over UI // Replaces Normal Bounty Info UI with Unique Game Over UI
void AllBountiesCompleted(); void AllBountiesCompleted();
void SavePlayerMoneyAndFavours();
protected: protected:
// Called When Player Spawns // Called When Player Spawns
virtual void BeginPlay() override; virtual void BeginPlay() override;
@ -77,6 +88,42 @@ public:
return OpenWorldLevelName; return OpenWorldLevelName;
} }
// Public incase Money can be earned through outside sources in the future
void EarnMoney(int MoneyEarned)
{
Money += MoneyEarned;
SavePlayerMoneyAndFavours();
}
// Checks if player has enough money to spend, if true then spend money and return true
bool SpendMoney(int MoneySpent)
{
if (MoneySpent > Money) return false;
Money -= MoneySpent;
SavePlayerMoneyAndFavours();
return true;
}
// Public incase favours can be earned through outside sources in the future
void EarnFavours(int FavoursEarned)
{
Favours += FavoursEarned;
SavePlayerMoneyAndFavours();
}
// Checks if player has enough favours to spend, if true then spend favours and return true
bool SpendFavours(int FavoursSpent)
{
if (FavoursSpent > Favours) return false;
Favours -= FavoursSpent;
SavePlayerMoneyAndFavours();
return true;
}
// ------------------- Pause Menu --------------------------------- // ------------------- Pause Menu ---------------------------------
private: private:
// Input Action for Opening and Closing Pause Menu // Input Action for Opening and Closing Pause Menu

View File

@ -12,6 +12,8 @@ void UEVGameInstance::CreateNewSaveGameInstance()
MainSaveGameInstanceRef = Cast<UMainSaveGameClass>(UGameplayStatics::CreateSaveGameObject(UMainSaveGameClass::StaticClass())); MainSaveGameInstanceRef = Cast<UMainSaveGameClass>(UGameplayStatics::CreateSaveGameObject(UMainSaveGameClass::StaticClass()));
MainSaveGameInstanceRef->CurrentMainBountyIndexSave = 0; MainSaveGameInstanceRef->CurrentMainBountyIndexSave = 0;
MainSaveGameInstanceRef->LastMainBountyIndexInOpenWorld = 0; MainSaveGameInstanceRef->LastMainBountyIndexInOpenWorld = 0;
MainSaveGameInstanceRef->MoneySave = 0;
MainSaveGameInstanceRef->FavourSave = 0;
UGameplayStatics::SaveGameToSlot(MainSaveGameInstanceRef, "MainSave", 0); UGameplayStatics::SaveGameToSlot(MainSaveGameInstanceRef, "MainSave", 0);
} }

View File

@ -30,4 +30,10 @@ public:
UPROPERTY() UPROPERTY()
FTransform PlayerOpenWorldSpawnTransformSave; FTransform PlayerOpenWorldSpawnTransformSave;
UPROPERTY()
int MoneySave;
UPROPERTY()
int FavourSave;
}; };

View File

@ -38,4 +38,8 @@ public:
// Closes any Previously Opened Tab and Opens the Given new Tab // Closes any Previously Opened Tab and Opens the Given new Tab
UFUNCTION(BlueprintImplementableEvent) UFUNCTION(BlueprintImplementableEvent)
void OpenNewTab(UTabWidget* TabWidget); void OpenNewTab(UTabWidget* TabWidget);
// Updates Displayed Player Statistics, aka Money and Favours
UFUNCTION(BlueprintImplementableEvent)
void UpdatePlayerStatistics(int NewMoney, int NewFavours);
}; };