Implemented Receiving Bounty Awards for Completing Bounties
This commit is contained in:
parent
1cdaea777e
commit
20c331e8a3
@ -9,13 +9,18 @@
|
||||
<component name="ChangeListManager">
|
||||
<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$/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/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.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.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>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -146,6 +151,8 @@
|
||||
<workItem from="1708089465885" duration="1591000" />
|
||||
<workItem from="1708180486567" duration="2641000" />
|
||||
<workItem from="1708269543495" duration="2914000" />
|
||||
<workItem from="1708434176965" duration="6053000" />
|
||||
<workItem from="1708607826264" duration="1417000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:474599332f82e0e18990902c5a79b7de5dd80a4e9c7fe016b22fd4280f96936e
|
||||
size 80064
|
||||
oid sha256:6cdc863b9bd4477a188dfba127b747fad85d5a2be2adba1663696d88db0ca63c
|
||||
size 82240
|
||||
|
BIN
EndlessVendetta/Content/BountySystem/ApartmentBounty/SideBounties/MoneyProblems/SB_MoneyProblems.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/BountySystem/ApartmentBounty/SideBounties/MoneyProblems/SB_MoneyProblems.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/BountySystem/ControlsTutorial/Bounty/MB_Training.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/BountySystem/ControlsTutorial/Bounty/MB_Training.uasset
(Stored with Git LFS)
Binary file not shown.
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7f9eeb93d9528280841ebfa552cc29d769515d093467e822741471ff85488699
|
||||
size 308710
|
||||
oid sha256:0d4289da6b9ff9cbe01059bf37b1d3a758f45d2609be2e75283085f0f135d978
|
||||
size 308758
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:64ca05e586e2efad00caccb8877e80ff186de099c7271b368fea7ed544606929
|
||||
size 485440
|
||||
oid sha256:ff738c6b1ccafb79a8381f4e2ae3b6015ba59a191a0f50db49b6864f0426489f
|
||||
size 508962
|
||||
|
BIN
EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/StarterContent/Blueprints/Blueprint_CeilingLight.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/StarterContent/Blueprints/Blueprint_CeilingLight.uasset
(Stored with Git LFS)
Binary file not shown.
@ -32,6 +32,12 @@ protected:
|
||||
public:
|
||||
FCompletedACheckpoint CompletedACheckpoint;
|
||||
|
||||
// Gets the Reward Money for Completing this Bounty, used by Players Character
|
||||
int GetRewardMoney()
|
||||
{
|
||||
return RewardMoney;
|
||||
}
|
||||
|
||||
|
||||
// ------------------- METHODS ---------------------------------
|
||||
private:
|
||||
|
@ -7,6 +7,7 @@
|
||||
void ASideBountyClass::BeginPlay()
|
||||
{
|
||||
SideBountyStruct.SideBountyUID = GetUniqueID();
|
||||
SideBountyStruct.MoneyEarnedForCompletion = RewardMoney;
|
||||
Super::BeginPlay();
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,8 @@ struct FSideBountyStruct
|
||||
// Amount of Favours the Player will earn for Completing this Side Bounty
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
int FavoursEarnedForCompletion = 1;
|
||||
|
||||
int MoneyEarnedForCompletion = 0;
|
||||
};
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCompletedSideBounty, int, SB_UID);
|
||||
|
@ -34,13 +34,14 @@ void ABountyHunterCharacter::SpawnMainBounty(UEVGameInstance* GI)
|
||||
for (auto SideBounty : CurrentSideBounties)
|
||||
{
|
||||
SideBountyStructs.Add(SideBounty->SideBountyStruct);
|
||||
SideBounty->CompletedSideBounty.AddDynamic(this, &CompletedASideBounty);
|
||||
SideBounty->CompletedSideBounty.AddDynamic(this, &ABountyHunterCharacter::CompletedASideBounty);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
// 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)
|
||||
{
|
||||
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"));
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
UEVGameInstance* GI = Cast<UEVGameInstance>(GetGameInstance());
|
||||
if (IsValid(GI->MainSaveGameInstanceRef))
|
||||
{
|
||||
Money = GI->MainSaveGameInstanceRef->MoneySave;
|
||||
Favours = GI->MainSaveGameInstanceRef->FavourSave;
|
||||
SpawnMainBounty(GI);
|
||||
FTransform SpawnLoc = GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave;
|
||||
if (SpawnLoc.GetLocation() != FVector(0, 0, 0) && UGameplayStatics::GetCurrentLevelName(GetWorld()) == OpenWorldLevelName)
|
||||
@ -162,6 +176,7 @@ void ABountyHunterCharacter::TogglePauseMenu()
|
||||
return;
|
||||
}
|
||||
PauseMenu = CreateWidget<UPauseMenuClass>(GetWorld(), PauseMenuWidgetClass, FName("PauseMenu"));
|
||||
PauseMenu->UpdatePlayerStatistics(Money, Favours);
|
||||
PauseMenu->AddToViewport(50);
|
||||
PauseMenu->OpenNewTab(BountiesTab);
|
||||
PauseMenu->OpenedBountiesTab.AddDynamic(this, &ABountyHunterCharacter::OpenBountiesTab);
|
||||
|
@ -23,6 +23,12 @@ class ENDLESSVENDETTA_API ABountyHunterCharacter : public AEndlessVendettaCharac
|
||||
GENERATED_BODY()
|
||||
// ------------------- 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
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Bounty Hunter")
|
||||
TArray<TSubclassOf<AMainBountyClass>> MainBountyClasses;
|
||||
@ -45,6 +51,9 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
// ------------------- METHODS ---------------------------------
|
||||
private:
|
||||
// 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
|
||||
void AllBountiesCompleted();
|
||||
|
||||
void SavePlayerMoneyAndFavours();
|
||||
|
||||
protected:
|
||||
// Called When Player Spawns
|
||||
virtual void BeginPlay() override;
|
||||
@ -77,6 +88,42 @@ public:
|
||||
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 ---------------------------------
|
||||
private:
|
||||
// Input Action for Opening and Closing Pause Menu
|
||||
|
@ -12,6 +12,8 @@ void UEVGameInstance::CreateNewSaveGameInstance()
|
||||
MainSaveGameInstanceRef = Cast<UMainSaveGameClass>(UGameplayStatics::CreateSaveGameObject(UMainSaveGameClass::StaticClass()));
|
||||
MainSaveGameInstanceRef->CurrentMainBountyIndexSave = 0;
|
||||
MainSaveGameInstanceRef->LastMainBountyIndexInOpenWorld = 0;
|
||||
MainSaveGameInstanceRef->MoneySave = 0;
|
||||
MainSaveGameInstanceRef->FavourSave = 0;
|
||||
UGameplayStatics::SaveGameToSlot(MainSaveGameInstanceRef, "MainSave", 0);
|
||||
}
|
||||
|
||||
|
@ -30,4 +30,10 @@ public:
|
||||
|
||||
UPROPERTY()
|
||||
FTransform PlayerOpenWorldSpawnTransformSave;
|
||||
|
||||
UPROPERTY()
|
||||
int MoneySave;
|
||||
|
||||
UPROPERTY()
|
||||
int FavourSave;
|
||||
};
|
||||
|
@ -38,4 +38,8 @@ public:
|
||||
// Closes any Previously Opened Tab and Opens the Given new Tab
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void OpenNewTab(UTabWidget* TabWidget);
|
||||
|
||||
// Updates Displayed Player Statistics, aka Money and Favours
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void UpdatePlayerStatistics(int NewMoney, int NewFavours);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user