Added Side Bounties to Save System
This commit is contained in:
parent
c166aa1cdb
commit
9a2a365528
@ -8,7 +8,13 @@
|
||||
</component>
|
||||
<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/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/MainBountyClass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/MainBountyClass.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/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/MainSaveGameClass.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/MainSaveGameClass.h" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -140,7 +146,7 @@
|
||||
<workItem from="1708180486567" duration="2641000" />
|
||||
<workItem from="1708269543495" duration="2914000" />
|
||||
<workItem from="1708434176965" duration="6053000" />
|
||||
<workItem from="1708607826264" duration="3320000" />
|
||||
<workItem from="1708607826264" duration="9842000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0d4289da6b9ff9cbe01059bf37b1d3a758f45d2609be2e75283085f0f135d978
|
||||
size 308758
|
||||
oid sha256:fa952eb25972ab6e6dca1d46cf254f62d1684ba665ee45a7c3d6a8e3527ffac1
|
||||
size 308710
|
||||
|
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/HDRI/HDRI_Epic_Courtyard_Daylight.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset
(Stored with Git LFS)
Binary file not shown.
@ -45,20 +45,11 @@ void AMainBountyClass::SpawnCheckpoints()
|
||||
ActivateFirstCheckpoint();
|
||||
}
|
||||
|
||||
TArray<ASideBountyClass*> AMainBountyClass::SpawnAndReturnSideBounties()
|
||||
{
|
||||
TArray<ASideBountyClass*> SpawnedSideBounties;
|
||||
for (auto SideBountyClass : SideBountiesToSpawn)
|
||||
{
|
||||
if (!IsValid(SideBountyClass)) continue;
|
||||
ASideBountyClass* SpawnedSideBounty = GetWorld()->SpawnActor<ASideBountyClass>(SideBountyClass);
|
||||
const FAttachmentTransformRules AttachmentTransformRules(EAttachmentRule::SnapToTarget, true);
|
||||
SpawnedSideBounty->AttachToComponent(GetRootComponent(), AttachmentTransformRules);
|
||||
SpawnedSideBounty->SpawnCheckpoints();
|
||||
SpawnedSideBounties.Add(SpawnedSideBounty);
|
||||
}
|
||||
return SpawnedSideBounties;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void AMainBountyClass::SpawnAmmoDrops()
|
||||
|
@ -71,14 +71,17 @@ protected:
|
||||
|
||||
|
||||
public:
|
||||
// Used by Bounty Char to Save and Spawn Side Bounties Unlocked by Activating this Main Bounty
|
||||
TArray<TSubclassOf<ASideBountyClass>> GetAssociatedSideBounties()
|
||||
{
|
||||
return SideBountiesToSpawn;
|
||||
}
|
||||
|
||||
// Spawns the Single Checkpoint in the Open World for this Main Bounty
|
||||
void SpawnOpenWorldCheckpoint();
|
||||
|
||||
void SpawnCheckpoints() override;
|
||||
|
||||
// Used by Bounty Character to Spawn and Store Side Bounty Refs when Main Bounty is Updated
|
||||
TArray<ASideBountyClass*> SpawnAndReturnSideBounties();
|
||||
|
||||
// Used by Players Character to Determine where to Spawn in the Open World after Completing Main Bounty
|
||||
FTransform GetPlayerSpawnTransform()
|
||||
{
|
||||
|
@ -20,7 +20,6 @@ void ABountyHunterCharacter::SpawnMainBounty(UEVGameInstance* GI)
|
||||
CurrentMainBounty = GetWorld()->SpawnActor<AMainBountyClass>(MainBountyClasses[CurrentMainBountyIndex]);
|
||||
const FAttachmentTransformRules AttachmentTransformRules(EAttachmentRule::SnapToTarget, true);
|
||||
CurrentMainBounty->AttachToComponent(GetRootComponent(), AttachmentTransformRules);
|
||||
|
||||
MainBountyStruct = CurrentMainBounty->MainBountyStruct;
|
||||
if (UGameplayStatics::GetCurrentLevelName(GetWorld()) != OpenWorldLevelName)
|
||||
{
|
||||
@ -28,7 +27,19 @@ void ABountyHunterCharacter::SpawnMainBounty(UEVGameInstance* GI)
|
||||
return;
|
||||
}
|
||||
CurrentMainBounty->SpawnOpenWorldCheckpoint();
|
||||
CurrentSideBounties = CurrentMainBounty->SpawnAndReturnSideBounties();
|
||||
}
|
||||
|
||||
void ABountyHunterCharacter::SpawnSideBounties(UEVGameInstance* GI)
|
||||
{
|
||||
for (auto SideBountyClass : GI->MainSaveGameInstanceRef->SideBountiesToSpawnSave)
|
||||
{
|
||||
if (!IsValid(SideBountyClass)) continue;
|
||||
ASideBountyClass* SpawnedSideBounty = GetWorld()->SpawnActor<ASideBountyClass>(SideBountyClass);
|
||||
const FAttachmentTransformRules AttachmentTransformRules(EAttachmentRule::SnapToTarget, true);
|
||||
SpawnedSideBounty->AttachToComponent(GetRootComponent(), AttachmentTransformRules);
|
||||
SpawnedSideBounty->SpawnCheckpoints();
|
||||
CurrentSideBounties.Add(SpawnedSideBounty);
|
||||
}
|
||||
|
||||
SideBountyStructs.Empty();
|
||||
for (auto SideBounty : CurrentSideBounties)
|
||||
@ -48,11 +59,18 @@ void ABountyHunterCharacter::CompleteCurrentMainBounty(UEVGameInstance* GI)
|
||||
GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave = MainBountyClasses[CurrentMainBountyIndex]->GetDefaultObject<AMainBountyClass>()->GetPlayerSpawnTransform();
|
||||
CurrentMainBountyIndex = GI->MainSaveGameInstanceRef->CurrentMainBountyIndexSave;
|
||||
GI->MainSaveGameInstanceRef->LastMainBountyIndexInOpenWorld = CurrentMainBountyIndex;
|
||||
|
||||
if (!(MainBountyClasses.IsEmpty() || MainBountyClasses.Num() <= CurrentMainBountyIndex|| !IsValid(MainBountyClasses[CurrentMainBountyIndex])))
|
||||
{
|
||||
GI->MainSaveGameInstanceRef->SideBountiesToSpawnSave.Append(MainBountyClasses[CurrentMainBountyIndex]->GetDefaultObject<AMainBountyClass>()->GetAssociatedSideBounties());
|
||||
}
|
||||
|
||||
UGameplayStatics::SaveGameToSlot(GI->MainSaveGameInstanceRef, "MainSave", 0);
|
||||
}
|
||||
|
||||
void ABountyHunterCharacter::CompletedASideBounty(int CompletedSideBountiesUID)
|
||||
{
|
||||
FString TitleOfSideBountyToRemove = "";
|
||||
for (int i = 0; i < SideBountyStructs.Num(); i++)
|
||||
{
|
||||
if (SideBountyStructs[i].SideBountyUID != CompletedSideBountiesUID) continue;
|
||||
@ -60,8 +78,21 @@ void ABountyHunterCharacter::CompletedASideBounty(int CompletedSideBountiesUID)
|
||||
EarnFavours(SideBountyStructs[i].FavoursEarnedForCompletion);
|
||||
if (IsValid(PauseMenu)) PauseMenu->UpdatePlayerStatistics(Money, Favours);
|
||||
|
||||
TitleOfSideBountyToRemove = SideBountyStructs[i].BountyTitle;
|
||||
SideBountyStructs.RemoveAt(i);
|
||||
UpdateBountyTabInfo();
|
||||
break;
|
||||
}
|
||||
|
||||
// Remove completed side bounty from save system
|
||||
UEVGameInstance* GI = Cast<UEVGameInstance>(GetGameInstance());
|
||||
TArray<TSubclassOf<ASideBountyClass>> CopyOfSideBountiesToSpawnSave = GI->MainSaveGameInstanceRef->SideBountiesToSpawnSave;
|
||||
for (int i = 0; i < CopyOfSideBountiesToSpawnSave.Num(); i++)
|
||||
{
|
||||
if (CopyOfSideBountiesToSpawnSave[i]->GetDefaultObject<ASideBountyClass>()->SideBountyStruct.BountyTitle != TitleOfSideBountyToRemove) continue;
|
||||
GI->MainSaveGameInstanceRef->SideBountiesToSpawnSave.RemoveAt(i);
|
||||
UGameplayStatics::SaveGameToSlot(GI->MainSaveGameInstanceRef, "MainSave", 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,11 +113,12 @@ void ABountyHunterCharacter::BeginPlay()
|
||||
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)
|
||||
if (UGameplayStatics::GetCurrentLevelName(GetWorld()) == OpenWorldLevelName)
|
||||
{
|
||||
SetActorTransform(GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave);
|
||||
Cast<APlayerController>(GetController())->SetControlRotation(GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave.GetRotation().Rotator());
|
||||
SpawnSideBounties(GI);
|
||||
FTransform SpawnTransfrom = GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave;
|
||||
SetActorTransform(SpawnTransfrom);
|
||||
Cast<APlayerController>(GetController())->SetControlRotation(SpawnTransfrom.GetRotation().Rotator());
|
||||
}
|
||||
}
|
||||
CreatePauseMenuTabs();
|
||||
|
@ -59,9 +59,12 @@ public:
|
||||
|
||||
// ------------------- METHODS ---------------------------------
|
||||
private:
|
||||
// Spawns Current Main Bounty along with its Side Bounties, and spawns its appropriate CP's based on level
|
||||
// Spawns Current Main Bounty and spawns its appropriate CP's based on level
|
||||
void SpawnMainBounty(UEVGameInstance* GI);
|
||||
|
||||
// Spawns Side Bounties from save system
|
||||
void SpawnSideBounties(UEVGameInstance* GI);
|
||||
|
||||
// Collects Reward for Current Main Bounty and Increments the Main Bounty Index
|
||||
void CompleteCurrentMainBounty(UEVGameInstance* GI);
|
||||
|
||||
@ -256,7 +259,7 @@ private:
|
||||
|
||||
void DeActivateAllBounties()
|
||||
{
|
||||
CurrentMainBounty->DeActivateFirstCheckpoint();
|
||||
if (IsValid(CurrentMainBounty)) CurrentMainBounty->DeActivateFirstCheckpoint();
|
||||
for (auto SideBounty : CurrentSideBounties)
|
||||
{
|
||||
SideBounty->DeActivateFirstCheckpoint();
|
||||
|
@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "BountySystem/SideBountyClass.h"
|
||||
#include "GameFramework/SaveGame.h"
|
||||
#include "WeaponSystem/BaseWeaponClass.h"
|
||||
#include "MainSaveGameClass.generated.h"
|
||||
@ -36,4 +37,7 @@ public:
|
||||
|
||||
UPROPERTY()
|
||||
int FavourSave;
|
||||
|
||||
UPROPERTY()
|
||||
TArray<TSubclassOf<ASideBountyClass>> SideBountiesToSpawnSave;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user