WIP Completing Side Bounties and Receiving Rewards

This commit is contained in:
Rafal Swierczek 2024-02-18 19:51:22 +00:00
parent 6a8e5a98c2
commit 1cdaea777e
8 changed files with 42 additions and 28 deletions

View File

@ -9,9 +9,13 @@
<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/Levels/TempOpenWorld.umap" beforeDir="false" afterPath="$PROJECT_DIR$/Content/Levels/TempOpenWorld.umap" 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$/Content/StarterContent/Architecture/Floor_400x400.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/Architecture/Floor_400x400.uasset" 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$/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/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" />
</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" />
@ -140,7 +144,8 @@
<workItem from="1707931429298" duration="599000" /> <workItem from="1707931429298" duration="599000" />
<workItem from="1707989731613" duration="3670000" /> <workItem from="1707989731613" duration="3670000" />
<workItem from="1708089465885" duration="1591000" /> <workItem from="1708089465885" duration="1591000" />
<workItem from="1708180486567" duration="731000" /> <workItem from="1708180486567" duration="2641000" />
<workItem from="1708269543495" duration="2914000" />
</task> </task>
<servers /> <servers />
</component> </component>

View File

@ -25,6 +25,10 @@ protected:
// Array of References to the Spawned in Checkpoints for this Bounty // Array of References to the Spawned in Checkpoints for this Bounty
TArray<ACheckpointClass*> BountyCheckpoints; TArray<ACheckpointClass*> BountyCheckpoints;
// Money Rewarded to Player for Completing this Bounty
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
int RewardMoney = 0;
public: public:
FCompletedACheckpoint CompletedACheckpoint; FCompletedACheckpoint CompletedACheckpoint;
@ -64,8 +68,7 @@ protected:
// ------- Properties Set in Editor -------------- // ------- Properties Set in Editor --------------
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
int RewardMoney = 0;
UPROPERTY(EditDefaultsOnly, Category = "Bounty") UPROPERTY(EditDefaultsOnly, Category = "Bounty")
FString BountyTitle; FString BountyTitle;

View File

@ -68,7 +68,7 @@ void ABountyDirector::SpawnBountyAndItsSideBounties()
ASideBountyClass* SideBounty = Cast<ASideBountyClass>(SideBountyActor); ASideBountyClass* SideBounty = Cast<ASideBountyClass>(SideBountyActor);
if (!IsValid(SideBounty)) UE_LOG(LogTemp, Fatal, TEXT("A SideBounty for %s has been set to a wrong type"), *ActiveBounty->GetBountyTitle()); if (!IsValid(SideBounty)) UE_LOG(LogTemp, Fatal, TEXT("A SideBounty for %s has been set to a wrong type"), *ActiveBounty->GetBountyTitle());
int i = ActiveSideBounties.Add(SideBounty); int i = ActiveSideBounties.Add(SideBounty);
ActiveSideBounties[i]->CompletedSideBounty.AddDynamic(this, &ABountyDirector::EarnFavours); // ActiveSideBounties[i]->CompletedSideBounty.AddDynamic(this, &ABountyDirector::EarnFavours);
// ONCE AGAIN WHEN MARCEL STOPS PLAYING WITH THE CHARACTER, ADD THIS SIDE BOUNTY TO PLAYERS ARRAY OF ACTIVE BOUNTIES!!!!! // ONCE AGAIN WHEN MARCEL STOPS PLAYING WITH THE CHARACTER, ADD THIS SIDE BOUNTY TO PLAYERS ARRAY OF ACTIVE BOUNTIES!!!!!
} }
} }

View File

@ -32,9 +32,6 @@ struct FMainBountyStruct
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly) UPROPERTY(BlueprintReadOnly, EditDefaultsOnly)
UTexture2D* Floorplan = nullptr; UTexture2D* Floorplan = nullptr;
UPROPERTY(BlueprintReadOnly)
bool Tracked = true;
}; };
UCLASS() UCLASS()

View File

@ -23,7 +23,7 @@ void ASideBountyClass::IncrementBountyCheckpoint()
if (BountyCheckpoints.IsEmpty()) if (BountyCheckpoints.IsEmpty())
{ {
CompletedSideBounty.Broadcast(FavoursEarnedForCompletion); CompletedSideBounty.Broadcast(GetUniqueID());
} }
} }

View File

@ -17,14 +17,15 @@ struct FSideBountyStruct
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly) UPROPERTY(BlueprintReadOnly, EditDefaultsOnly)
FString BountyDesc = ""; FString BountyDesc = "";
UPROPERTY(BlueprintReadOnly)
bool Tracked = true;
UPROPERTY(BlueprintReadOnly) UPROPERTY(BlueprintReadOnly)
int SideBountyUID = 0; int SideBountyUID = 0;
// Amount of Favours the Player will earn for Completing this Side Bounty
UPROPERTY(EditDefaultsOnly)
int FavoursEarnedForCompletion = 1;
}; };
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCompletedSideBounty, int, FavoursEarned); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCompletedSideBounty, int, SB_UID);
UCLASS() UCLASS()
class ENDLESSVENDETTA_API ASideBountyClass : public ABountyClass class ENDLESSVENDETTA_API ASideBountyClass : public ABountyClass
@ -32,9 +33,7 @@ class ENDLESSVENDETTA_API ASideBountyClass : public ABountyClass
GENERATED_BODY() GENERATED_BODY()
// ------------------- ATTRIBUTES ------------------------------ // ------------------- ATTRIBUTES ------------------------------
// Amount of Favours the Player will earn for Completing this Side Bounty
UPROPERTY(EditDefaultsOnly, Category = "Side Bounty")
int FavoursEarnedForCompletion = 1;
protected: protected:
@ -47,7 +46,6 @@ public:
FSideBountyStruct SideBountyStruct; FSideBountyStruct SideBountyStruct;
// ------------------- METHODS --------------------------------- // ------------------- METHODS ---------------------------------
private: private:
virtual void BeginPlay() override; virtual void BeginPlay() override;
@ -66,6 +64,6 @@ public:
void DestroyCheckpoints(); void DestroyCheckpoints();
int GetRewardInFavours() int GetRewardInFavours()
{ {
return FavoursEarnedForCompletion; return 0;
} }
}; };

View File

@ -34,6 +34,7 @@ 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);
} }
} }
@ -42,16 +43,22 @@ void ABountyHunterCharacter::CompleteCurrentMainBounty(UEVGameInstance* GI)
// Collect rewards for bounty and move onto next // Collect rewards for bounty and move onto next
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);
// FTransform PostBountySpawnTransform = MainBountyClasses[CurrentMainBountyIndex]->GetDefaultObject<AMainBountyClass>()->GetPlayerSpawnTransform(); // Saves players spawn now as players location is set after spawn main bounty finishes running in begin play
// SetActorTransform(PostBountySpawnTransform);
// Cast<APlayerController>(GetController())->SetControlRotation(PostBountySpawnTransform.GetRotation().Rotator());
GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave = MainBountyClasses[CurrentMainBountyIndex]->GetDefaultObject<AMainBountyClass>()->GetPlayerSpawnTransform(); GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave = MainBountyClasses[CurrentMainBountyIndex]->GetDefaultObject<AMainBountyClass>()->GetPlayerSpawnTransform();
CurrentMainBountyIndex = GI->MainSaveGameInstanceRef->CurrentMainBountyIndexSave; CurrentMainBountyIndex = GI->MainSaveGameInstanceRef->CurrentMainBountyIndexSave;
GI->MainSaveGameInstanceRef->LastMainBountyIndexInOpenWorld = CurrentMainBountyIndex; GI->MainSaveGameInstanceRef->LastMainBountyIndexInOpenWorld = CurrentMainBountyIndex;
UGameplayStatics::SaveGameToSlot(GI->MainSaveGameInstanceRef, "MainSave", 0); UGameplayStatics::SaveGameToSlot(GI->MainSaveGameInstanceRef, "MainSave", 0);
} }
void ABountyHunterCharacter::CompletedASideBounty(int CompletedSideBountiesUID)
{
for (auto SBStruct : SideBountyStructs)
{
if (SBStruct.SideBountyUID != CompletedSideBountiesUID) continue;
//Continue writing code here about gaining money and favours
}
}
void ABountyHunterCharacter::AllBountiesCompleted() 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"));

View File

@ -31,12 +31,12 @@ class ENDLESSVENDETTA_API ABountyHunterCharacter : public AEndlessVendettaCharac
UPROPERTY() UPROPERTY()
AMainBountyClass* CurrentMainBounty; AMainBountyClass* CurrentMainBounty;
UPROPERTY()
TArray<ASideBountyClass*> CurrentSideBounties;
// Index of Currently Active Main Bounty, Used for MainBountyClasses // Index of Currently Active Main Bounty, Used for MainBountyClasses
int CurrentMainBountyIndex = 0; int CurrentMainBountyIndex = 0;
// References to Currently Active Side Bounties
TArray<ASideBountyClass*> CurrentSideBounties;
// Name of open world, so that the correct bounties can be spawned based on level // Name of open world, so that the correct bounties can be spawned based on level
UPROPERTY(EditDefaultsOnly, Category = "Bounty Hunter") UPROPERTY(EditDefaultsOnly, Category = "Bounty Hunter")
FString OpenWorldLevelName = "ControlTutorialLevel"; FString OpenWorldLevelName = "ControlTutorialLevel";
@ -53,6 +53,10 @@ private:
// Collects Reward for Current Main Bounty and Increments the Main Bounty Index // Collects Reward for Current Main Bounty and Increments the Main Bounty Index
void CompleteCurrentMainBounty(UEVGameInstance* GI); void CompleteCurrentMainBounty(UEVGameInstance* GI);
// Collects Reward for Completing a Side Bounty
UFUNCTION()
void CompletedASideBounty(int CompletedSideBountiesUID);
// Replaces Normal Bounty Info UI with Unique Game Over UI // Replaces Normal Bounty Info UI with Unique Game Over UI
void AllBountiesCompleted(); void AllBountiesCompleted();