Created new Main Bounty Class

Seperates new properties and behaviours associated with only the main bounties and not any other bounties
This commit is contained in:
Rafal Swierczek 2023-10-11 10:59:14 +01:00
parent c6db0146e4
commit 546e7b4a6d
8 changed files with 157 additions and 133 deletions

View File

@ -93,26 +93,6 @@ void ABountyClass::CollectRewards_Implementation()
UE_LOG(LogTemp, Warning, TEXT("The player has gained $%d for completing the bounty!"), RewardMoney);
}
void ABountyClass::BuySpawnAmmoDrops()
{
FActorSpawnParameters SpawnParameters;
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
for (FTransform Spawn : AmmoDropSpawnTransforms)
{
GetWorld()->SpawnActor<AActor>(AmmoDropClass, Spawn.GetLocation(), Spawn.GetRotation().Rotator(), SpawnParameters);
}
}
void ABountyClass::BuySpawnHealthDrops()
{
FActorSpawnParameters SpawnParameters;
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
for (FTransform Spawn : HealthDropSpawnTransforms)
{
GetWorld()->SpawnActor<AActor>(HealthDropClass, Spawn.GetLocation(), Spawn.GetRotation().Rotator(), SpawnParameters);
}
}

View File

@ -24,9 +24,6 @@ protected:
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TArray<TSubclassOf<ACheckpointClass>> CheckpointsToSpawn;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TArray<TSubclassOf<ABountyClass>> SideBountiesToSpawn;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
int RewardMoney = 0;
@ -35,39 +32,6 @@ protected:
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
FString BountyDesc;
// ---------------- Bounty Alterations ----------------
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
FString CustomBountyAlteration_1_Description;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
int CustomBountyAlteration_1_Cost = 2;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
FString CustomBountyAlteration_2_Description;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
int CustomBountyAlteration_2_Cost = 2;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
FString CustomBountyAlteration_3_Description;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
int CustomBountyAlteration_3_Cost = 2;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TArray<FTransform> AmmoDropSpawnTransforms;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TSubclassOf<AActor> AmmoDropClass;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TArray<FTransform> HealthDropSpawnTransforms;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TSubclassOf<AActor> HealthDropClass;
bool HasEnemyRadio = false;
// -----------------------------------------------
bool Completed = false;
@ -92,10 +56,6 @@ public:
return Completed;
}
TArray<TSubclassOf<ABountyClass>> GetSideBountiesToSpawn()
{
return SideBountiesToSpawn;
}
FString GetBountyTitle()
{
return BountyTitle;
@ -160,67 +120,4 @@ public:
// Collect Money in C++, any other special reward will be implemented in BP if neccessary
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
void CollectRewards();
// ------------- Custom Bounty Alterations -------------
UFUNCTION(BlueprintImplementableEvent, Category = "Bounty")
void BuyCustomBountyAlteration_1();
UFUNCTION(BlueprintImplementableEvent, Category = "Bounty")
void BuyCustomBountyAlteration_2();
UFUNCTION(BlueprintImplementableEvent, Category = "Bounty")
void BuyCustomBountyAlteration_3();
UFUNCTION(BlueprintCallable, Category = "Bounty")
FString GetCustomBountyAlteration_1_Description()
{
return CustomBountyAlteration_1_Description;
}
UFUNCTION(BlueprintCallable, Category = "Bounty")
FString GetCustomBountyAlteration_2_Description()
{
return CustomBountyAlteration_2_Description;
}
UFUNCTION(BlueprintCallable, Category = "Bounty")
FString GetCustomBountyAlteration_3_Description()
{
return CustomBountyAlteration_3_Description;
}
UFUNCTION(BlueprintCallable, Category = "Bounty")
int GetCustomBountyAlteration_1_Cost()
{
return CustomBountyAlteration_1_Cost;
}
UFUNCTION(BlueprintCallable, Category = "Bounty")
int GetCustomBountyAlteration_2_Cost()
{
return CustomBountyAlteration_2_Cost;
}
UFUNCTION(BlueprintCallable, Category = "Bounty")
int GetCustomBountyAlteration_3_Cost()
{
return CustomBountyAlteration_3_Cost;
}
// ------------- Simple Bounty Alterations -------------
void BuySpawnAmmoDrops();
void BuySpawnHealthDrops();
void BuyEnemyRadio()
{
HasEnemyRadio = true;
}
// Concerned Enemies will call this function, if true, play funny poop voice line and stop enemies from being concerned
bool CheckIfHasEnemyRadio()
{
return HasEnemyRadio;
};
};

View File

@ -54,13 +54,13 @@ void ABountyDirector::SpawnBountyAndItsSideBounties()
const FAttachmentTransformRules AttachmentTransformRules(EAttachmentRule::SnapToTarget, true);
BountyActor->AttachToComponent(BountyAttachmentPoint, AttachmentTransformRules);
ActiveBounty = Cast<ABountyClass>(BountyActor);
ActiveBounty = Cast<AMainBountyClass>(BountyActor);
if (!IsValid(ActiveBounty)) UE_LOG(LogTemp, Fatal, TEXT("Failed to Cast to Bounty class"));
// WHEN MARCEL STOPS PLAYING WITH THE CHARACTER, ADD THIS BOUNTY TO PLAYERS ARRAY OF ACTIVE BOUNTIES!!!!!
ActiveBounty->CompletedFirstCheckpoint.AddDynamic(this, &ABountyDirector::DestroyActiveSideBounties);
ActiveSideBounties.Reset();
for (TSubclassOf<ABountyClass> SideBountyClass : ActiveBounty->GetSideBountiesToSpawn())
for (TSubclassOf<ASideBountyClass> SideBountyClass : ActiveBounty->GetSideBountiesToSpawn())
{
if (!IsValid(SideBountyClass)) continue;
AActor* SideBountyActor = GetWorld()->SpawnActor<AActor>(SideBountyClass, PlayerChar->GetActorLocation(), PlayerChar->GetActorRotation(), SpawnParams);

View File

@ -3,7 +3,7 @@
#pragma once
#include "CoreMinimal.h"
#include "BountyClass.h"
#include "MainBountyClass.h"
#include "SideBountyClass.h"
#include "EndlessVendetta/EndlessVendettaCharacter.h"
#include "GameFramework/Actor.h"
@ -21,12 +21,12 @@ class ENDLESSVENDETTA_API ABountyDirector : public AActor
// Ordered Array of Main Bounties
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TArray<TSubclassOf<ABountyClass>> BountyClassArray;
TArray<TSubclassOf<AMainBountyClass>> BountyClassArray;
int CurrentBountyIndex = 0;
UPROPERTY(VisibleAnywhere, Category = "Bounty")
ABountyClass* ActiveBounty;
AMainBountyClass* ActiveBounty;
UPROPERTY(VisibleAnywhere, Category = "Bounty")
TArray<ASideBountyClass*> ActiveSideBounties;

View File

@ -0,0 +1,24 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "MainBountyClass.h"
void AMainBountyClass::BuySpawnAmmoDrops()
{
FActorSpawnParameters SpawnParameters;
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
for (FTransform Spawn : AmmoDropSpawnTransforms)
{
GetWorld()->SpawnActor<AActor>(AmmoDropClass, Spawn.GetLocation(), Spawn.GetRotation().Rotator(), SpawnParameters);
}
}
void AMainBountyClass::BuySpawnHealthDrops()
{
FActorSpawnParameters SpawnParameters;
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
for (FTransform Spawn : HealthDropSpawnTransforms)
{
GetWorld()->SpawnActor<AActor>(HealthDropClass, Spawn.GetLocation(), Spawn.GetRotation().Rotator(), SpawnParameters);
}
}

View File

@ -0,0 +1,123 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "BountyClass.h"
#include "SideBountyClass.h"
#include "MainBountyClass.generated.h"
/**
*
*/
UCLASS()
class ENDLESSVENDETTA_API AMainBountyClass : public ABountyClass
{
GENERATED_BODY()
protected:
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TArray<TSubclassOf<ASideBountyClass>> SideBountiesToSpawn;
// ---------------- Bounty Alterations ----------------
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
FString CustomBountyAlteration_1_Description;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
int CustomBountyAlteration_1_Cost = 2;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
FString CustomBountyAlteration_2_Description;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
int CustomBountyAlteration_2_Cost = 2;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
FString CustomBountyAlteration_3_Description;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
int CustomBountyAlteration_3_Cost = 2;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TArray<FTransform> AmmoDropSpawnTransforms;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TSubclassOf<AActor> AmmoDropClass;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TArray<FTransform> HealthDropSpawnTransforms;
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TSubclassOf<AActor> HealthDropClass;
bool HasEnemyRadio = false;
public:
TArray<TSubclassOf<ASideBountyClass>> GetSideBountiesToSpawn()
{
return SideBountiesToSpawn;
}
// ------------- Custom Bounty Alterations -------------
UFUNCTION(BlueprintImplementableEvent, Category = "Bounty")
void BuyCustomBountyAlteration_1();
UFUNCTION(BlueprintImplementableEvent, Category = "Bounty")
void BuyCustomBountyAlteration_2();
UFUNCTION(BlueprintImplementableEvent, Category = "Bounty")
void BuyCustomBountyAlteration_3();
UFUNCTION(BlueprintCallable, Category = "Bounty")
FString GetCustomBountyAlteration_1_Description()
{
return CustomBountyAlteration_1_Description;
}
UFUNCTION(BlueprintCallable, Category = "Bounty")
FString GetCustomBountyAlteration_2_Description()
{
return CustomBountyAlteration_2_Description;
}
UFUNCTION(BlueprintCallable, Category = "Bounty")
FString GetCustomBountyAlteration_3_Description()
{
return CustomBountyAlteration_3_Description;
}
UFUNCTION(BlueprintCallable, Category = "Bounty")
int GetCustomBountyAlteration_1_Cost()
{
return CustomBountyAlteration_1_Cost;
}
UFUNCTION(BlueprintCallable, Category = "Bounty")
int GetCustomBountyAlteration_2_Cost()
{
return CustomBountyAlteration_2_Cost;
}
UFUNCTION(BlueprintCallable, Category = "Bounty")
int GetCustomBountyAlteration_3_Cost()
{
return CustomBountyAlteration_3_Cost;
}
// ------------- Simple Bounty Alterations -------------
void BuySpawnAmmoDrops();
void BuySpawnHealthDrops();
void BuyEnemyRadio()
{
HasEnemyRadio = true;
}
// Concerned Enemies will call this function, if true, play funny poop voice line and stop enemies from being concerned
bool CheckIfHasEnemyRadio()
{
return HasEnemyRadio;
};
};