Merge pull request #10 from Games-Academy-Student-Work-22-23/Stealth-Mechanics-v1.0.2

Stealth mechanics v1.0.2
This commit is contained in:
Philip W 2023-02-23 16:04:33 +00:00 committed by GitHub Enterprise
commit 76043108b1
5 changed files with 20 additions and 23 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Content/Levels/Testing/SneakMechanicTesting.umap (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -36,11 +36,13 @@ void ATempCharacter::BeginPlay()
//MAKE SURE POST PROCESSING IS IN THE SCENE OR GAME WILL CRASH //MAKE SURE POST PROCESSING IS IN THE SCENE OR GAME WILL CRASH
UGameplayStatics::GetAllActorsOfClass(GetWorld(), APostProcessVolume::StaticClass(), AllActorsInScene); UGameplayStatics::GetAllActorsOfClass(GetWorld(), APostProcessVolume::StaticClass(), AllActorsInScene);
PostProcessVolume = Cast<APostProcessVolume>(AllActorsInScene[0]);
Enemy = TEXT("Enemy"); Enemy = TEXT("Enemy");
UGameplayStatics::GetAllActorsWithTag(GetWorld(), Enemy, AIActors); UGameplayStatics::GetAllActorsWithTag(GetWorld(), Enemy, AIActors);
//stops crashing
if (ensureMsgf(AllActorsInScene.Num() > 0, TEXT("No Post Processing Volume in scene")))
{
PostProcessVolume = Cast<APostProcessVolume>(AllActorsInScene[0]);
}
Ammo = TEXT("Ammo"); Ammo = TEXT("Ammo");
} }
@ -61,14 +63,11 @@ void ATempCharacter::Sneak()
if (bIsCrouched) if (bIsCrouched)
{ {
UnCrouch(); UnCrouch();
PostProcessVolume->Settings.VignetteIntensity = 0.0f; if (PostProcessVolume != nullptr) PostProcessVolume->Settings.VignetteIntensity = 0.0f;
for (AActor* Actor : AIActors) for (AActor* Actor : AIActors)
{ {
USphereComponent* SphereComponent = Actor->FindComponentByClass<USphereComponent>(); USphereComponent* SphereComponent = Actor->FindComponentByClass<USphereComponent>();
if (SphereComponent != nullptr) if (SphereComponent != nullptr) SphereComponent->SetSphereRadius(40.0f); //default value
{
SphereComponent->SetSphereRadius(40.0f); //default value
}
} }
} }
else else
@ -77,12 +76,9 @@ void ATempCharacter::Sneak()
for (AActor* Actor : AIActors) for (AActor* Actor : AIActors)
{ {
USphereComponent* SphereComponent = Actor->FindComponentByClass<USphereComponent>(); USphereComponent* SphereComponent = Actor->FindComponentByClass<USphereComponent>();
if (SphereComponent != nullptr) if (SphereComponent != nullptr) SphereComponent->SetSphereRadius(15.0f);
{
SphereComponent->SetSphereRadius(15.0f);
}
} }
PostProcessVolume->Settings.VignetteIntensity = 0.8f; if (PostProcessVolume != nullptr) PostProcessVolume->Settings.VignetteIntensity = 0.8f;
} }
} }
@ -140,7 +136,6 @@ void ATempCharacter::LineTraceLogic()
} }
if(OutHit.GetActor()->FindComponentByClass<UInventoryComponent>()) if(OutHit.GetActor()->FindComponentByClass<UInventoryComponent>())
{ {
UE_LOG(LogTemp, Display, TEXT("Hit Merchant"));
auto ItemArray = OutHit.GetActor()->FindComponentByClass<UInventoryComponent>()->GetItem(0); auto ItemArray = OutHit.GetActor()->FindComponentByClass<UInventoryComponent>()->GetItem(0);
if(GoldBalance >= ItemArray->ItemCostPrice) if(GoldBalance >= ItemArray->ItemCostPrice)
{ {
@ -150,10 +145,11 @@ void ATempCharacter::LineTraceLogic()
} }
if(GoldBalance <= 0) if(GoldBalance <= 0)
{ {
UE_LOG(LogTemp, Display, TEXT("Not Enough Gold")); return;
} }
if(OutHit.GetActor()->ActorHasTag(Ammo)) if(OutHit.GetActor()->ActorHasTag(Ammo))
{ {
UE_LOG(LogTemp, Display, TEXT("Ammo destroy func activated"));
OutHit.GetActor()->Destroy(); OutHit.GetActor()->Destroy();
} }
} }
@ -163,7 +159,6 @@ void ATempCharacter::LineTraceLogic()
{ {
if (MyInteractable->ShopDialogWidget->IsVisible()) if (MyInteractable->ShopDialogWidget->IsVisible())
{ {
UE_LOG(LogTemp, Display, TEXT("ShopKeeper text is visible"));
bShopKeeperText = true; bShopKeeperText = true;
return; return;
} }
@ -178,7 +173,6 @@ void ATempCharacter::LineTraceLogic()
{ {
DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f); DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f);
MyInteractable->OnInteract(); MyInteractable->OnInteract();
UE_LOG(LogTemp, Display, TEXT("OnInteract activated"));
UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *OutHit.GetActor()->GetName()); UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *OutHit.GetActor()->GetName());
// While loop to check bisDisabled var until it changes to true // While loop to check bisDisabled var until it changes to true