2022-11-10 11:52:10 +00:00
|
|
|
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
|
|
#include "TempCharacter.h"
|
2022-11-18 13:07:44 +00:00
|
|
|
|
2022-11-12 18:47:13 +00:00
|
|
|
#include "Blueprint/UserWidget.h"
|
2022-11-14 17:42:26 +00:00
|
|
|
#include "the_twilight_abyss/BaseItems/InventoryComponent.h"
|
2022-11-14 16:52:57 +00:00
|
|
|
#include "the_twilight_abyss/BaseItems/Items/BaseItem.h"
|
2023-02-06 15:26:22 +00:00
|
|
|
#include "GameFramework/CharacterMovementComponent.h"
|
2022-11-13 16:43:01 +00:00
|
|
|
#include "the_twilight_abyss/MerchantInteraction/Interaction.h"
|
2023-02-06 15:55:12 +00:00
|
|
|
#include <Runtime/Engine/Classes/Kismet/GameplayStatics.h>
|
2023-03-05 17:41:39 +00:00
|
|
|
#include "Components/PawnNoiseEmitterComponent.h"
|
2023-05-21 17:55:22 +00:00
|
|
|
#include "Blueprint/WidgetBlueprintLibrary.h"
|
2023-02-17 13:12:28 +00:00
|
|
|
#include "Kismet/KismetMathLibrary.h"
|
2023-05-21 18:06:16 +00:00
|
|
|
#include "Misc/OutputDeviceNull.h"
|
2022-11-10 16:38:38 +00:00
|
|
|
|
2022-11-10 11:52:10 +00:00
|
|
|
|
2022-11-10 12:57:31 +00:00
|
|
|
// CONSTRUCTOR
|
2022-11-10 11:52:10 +00:00
|
|
|
ATempCharacter::ATempCharacter()
|
|
|
|
{
|
|
|
|
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
|
|
|
PrimaryActorTick.bCanEverTick = true;
|
2022-11-14 17:42:26 +00:00
|
|
|
Inventory = CreateDefaultSubobject<UInventoryComponent>("Inventory");
|
|
|
|
Inventory->MaxItemSlots = 10;
|
2023-02-06 15:26:22 +00:00
|
|
|
this->GetCharacterMovement()->GetNavAgentPropertiesRef().bCanCrouch = true;
|
2023-05-21 17:55:22 +00:00
|
|
|
|
|
|
|
if (static ConstructorHelpers::FObjectFinder<UTexture2D> CrossHairTexture(TEXT("Texture2D'/Game/Blueprints/Display_UI/InteracableIcon.InteracableIcon'")); IsValid(CrossHairTexture.Object))
|
|
|
|
{
|
|
|
|
InteractableCrossHair = CrossHairTexture.Object;
|
|
|
|
}
|
2022-11-10 11:52:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Called when the game starts or when spawned
|
|
|
|
void ATempCharacter::BeginPlay()
|
|
|
|
{
|
|
|
|
Super::BeginPlay();
|
2023-04-24 17:01:51 +00:00
|
|
|
FirstPlayerController = GetWorld()->GetFirstPlayerController();
|
2023-04-25 00:07:35 +00:00
|
|
|
CombatSystem = Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState());
|
2023-04-24 17:01:51 +00:00
|
|
|
WidgetPointer = Cast<UWidgetInteractionComponent>(this->GetComponentByClass(UWidgetInteractionComponent::StaticClass()));
|
|
|
|
|
2022-11-14 15:53:50 +00:00
|
|
|
Health = 100;
|
2023-02-04 18:34:53 +00:00
|
|
|
ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());
|
2023-02-06 15:26:22 +00:00
|
|
|
PlayerCapsule = GetCapsuleComponent();
|
2023-02-06 15:55:12 +00:00
|
|
|
TArray<AActor*> AllActorsInScene;
|
2023-02-06 23:51:45 +00:00
|
|
|
//MAKE SURE POST PROCESSING IS IN THE SCENE OR GAME WILL CRASH
|
2023-02-06 15:55:12 +00:00
|
|
|
UGameplayStatics::GetAllActorsOfClass(GetWorld(), APostProcessVolume::StaticClass(), AllActorsInScene);
|
2023-02-23 01:28:29 +00:00
|
|
|
if (ensureMsgf(AllActorsInScene.Num() > 0, TEXT("No Post Processing Volume in scene")))
|
|
|
|
{
|
|
|
|
PostProcessVolume = Cast<APostProcessVolume>(AllActorsInScene[0]);
|
|
|
|
}
|
2023-02-17 13:12:28 +00:00
|
|
|
Enemy = TEXT("Enemy");
|
2023-03-06 15:37:31 +00:00
|
|
|
//UGameplayStatics::GetAllActorsWithTag(GetWorld(), Enemy, AIActors);
|
2023-02-19 15:28:34 +00:00
|
|
|
Ammo = TEXT("Ammo");
|
2023-03-05 17:41:39 +00:00
|
|
|
NoiseEmitter = Cast<UPawnNoiseEmitterComponent>(this->FindComponentByClass(UPawnNoiseEmitterComponent::StaticClass()));
|
2023-03-14 13:04:33 +00:00
|
|
|
|
|
|
|
//Widget Refs
|
|
|
|
CrossHairWidget = CreateWidget<UUserWidget>(GetWorld(), CrossHairSub);
|
|
|
|
CrossHairWidget->SetVisibility(ESlateVisibility::Visible);
|
2023-05-21 17:55:22 +00:00
|
|
|
CrossHair = Cast<UImage>(CrossHairWidget->GetWidgetFromName(TEXT("Crosshair")));
|
2023-03-14 13:04:33 +00:00
|
|
|
CrossHairWidget->AddToViewport();
|
|
|
|
|
2023-05-13 15:27:39 +00:00
|
|
|
InventoryWidget = CreateWidget<UUserWidget>(GetWorld(), InventoryMenuSub);
|
|
|
|
InventoryWidget->SetVisibility(ESlateVisibility::Hidden);
|
|
|
|
InventoryWidget->AddToViewport();
|
2023-05-13 16:58:13 +00:00
|
|
|
|
|
|
|
EscapeMenuWidget = CreateWidget<UUserWidget>(GetWorld(), EscapeMenuSub);
|
|
|
|
EscapeMenuWidget->SetVisibility(ESlateVisibility::Hidden);
|
|
|
|
EscapeMenuWidget->AddToViewport();
|
2022-11-10 11:52:10 +00:00
|
|
|
}
|
|
|
|
|
2022-11-10 12:57:31 +00:00
|
|
|
//Binds the input we made in the setup player component to the forward vector
|
2022-11-10 11:52:10 +00:00
|
|
|
void ATempCharacter::ForwardInput(float Axis)
|
|
|
|
{
|
2023-02-02 02:19:59 +00:00
|
|
|
AddMovementInput(UKismetMathLibrary::GetForwardVector(FRotator(0, GetControlRotation().Yaw, 0)) * Axis);
|
2023-03-05 17:41:39 +00:00
|
|
|
if (isInStealth == false) MakeNoise(1.0f, this, GetActorLocation(), 1200.0f);
|
2022-11-10 11:52:10 +00:00
|
|
|
}
|
2023-02-23 01:28:29 +00:00
|
|
|
|
2022-11-10 12:57:31 +00:00
|
|
|
//Binds the input we made in the setup player component to the right vector
|
2022-11-10 11:52:10 +00:00
|
|
|
void ATempCharacter::RightMoveInput(float Axis)
|
|
|
|
{
|
2023-02-02 02:19:59 +00:00
|
|
|
AddMovementInput(UKismetMathLibrary::GetRightVector(FRotator(0, GetControlRotation().Yaw, 0)) * Axis);
|
2023-03-05 17:41:39 +00:00
|
|
|
if (isInStealth == false) MakeNoise(1.0f, this, GetActorLocation(), 1200.0f);
|
2022-11-10 11:52:10 +00:00
|
|
|
}
|
|
|
|
|
2023-02-06 14:30:13 +00:00
|
|
|
void ATempCharacter::Sneak()
|
|
|
|
{
|
2023-02-06 15:26:22 +00:00
|
|
|
UE_LOG(LogTemp, Display, TEXT("Sneak activated"));
|
|
|
|
if (bIsCrouched)
|
|
|
|
{
|
|
|
|
UnCrouch();
|
2023-03-05 17:41:39 +00:00
|
|
|
isInStealth = false;
|
2023-02-23 01:28:29 +00:00
|
|
|
if (PostProcessVolume != nullptr) PostProcessVolume->Settings.VignetteIntensity = 0.0f;
|
2023-02-06 15:26:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Crouch();
|
2023-03-05 17:41:39 +00:00
|
|
|
isInStealth = true;
|
2023-02-23 01:28:29 +00:00
|
|
|
if (PostProcessVolume != nullptr) PostProcessVolume->Settings.VignetteIntensity = 0.8f;
|
2023-02-06 15:26:22 +00:00
|
|
|
}
|
2023-02-06 14:30:13 +00:00
|
|
|
}
|
|
|
|
|
2022-11-10 12:57:31 +00:00
|
|
|
|
2023-04-26 02:51:17 +00:00
|
|
|
void ATempCharacter::ResetWidgetPointer() const
|
|
|
|
{
|
|
|
|
WidgetPointer->SetWorldLocationAndRotation(FVector(0, 0, 0), FRotator(0, 0, 0).Quaternion());
|
|
|
|
}
|
|
|
|
|
2022-11-10 11:52:10 +00:00
|
|
|
// Called every frame
|
|
|
|
void ATempCharacter::Tick(float DeltaTime)
|
|
|
|
{
|
|
|
|
Super::Tick(DeltaTime);
|
2023-04-24 17:01:51 +00:00
|
|
|
if (CombatSystem->bIsInCombat)
|
|
|
|
{
|
|
|
|
FVector VectorRotation;
|
|
|
|
FVector WidgetLocation;
|
|
|
|
FirstPlayerController->DeprojectMousePositionToWorld(WidgetLocation, VectorRotation);
|
|
|
|
WidgetPointer->SetWorldLocationAndRotation(WidgetLocation, VectorRotation.Rotation().Quaternion());
|
|
|
|
}
|
2023-05-21 17:55:22 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
const FVector Start = ThisCamera->GetComponentLocation();
|
|
|
|
const FVector End = Start + TraceDistance * ThisCamera->GetForwardVector();
|
|
|
|
FCollisionQueryParams TraceParams;
|
|
|
|
TraceParams.AddIgnoredActor(this);
|
|
|
|
if (FHitResult OutResult = FHitResult(); GetWorld()->LineTraceSingleByChannel(OutResult, Start, End, ECC_Pawn, TraceParams))
|
|
|
|
{
|
|
|
|
if (!IsValid(OutResult.GetActor()))
|
|
|
|
{
|
|
|
|
CrossHair->SetBrush(FSlateBrush());
|
|
|
|
CrossHair->SetDesiredSizeOverride(FVector2D(5, 5));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (OutResult.GetActor()->ActorHasTag("Probertium") || OutResult.GetActor()->ActorHasTag("Iroquid")
|
|
|
|
|| OutResult.GetActor()->ActorHasTag("Azos") || OutResult.GetActor()->ActorHasTag("Eis")
|
2023-05-21 18:06:16 +00:00
|
|
|
|| OutResult.GetActor()->ActorHasTag("NPC") || OutResult.GetActor()->ActorHasTag("Interactable")
|
|
|
|
|| OutResult.GetActor()->FindComponentByClass<UInventoryComponent>())
|
2023-05-21 17:55:22 +00:00
|
|
|
{
|
|
|
|
CrossHair->SetBrush(UWidgetBlueprintLibrary::MakeBrushFromTexture(InteractableCrossHair));
|
|
|
|
CrossHair->SetDesiredSizeOverride(FVector2D(43.6, 51.3));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
CrossHair->SetBrush(FSlateBrush());
|
|
|
|
CrossHair->SetDesiredSizeOverride(FVector2D(5, 5));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CrossHair->SetBrush(FSlateBrush());
|
|
|
|
CrossHair->SetDesiredSizeOverride(FVector2D(5, 5));
|
|
|
|
}
|
|
|
|
}
|
2022-11-10 11:52:10 +00:00
|
|
|
}
|
|
|
|
|
2022-11-14 16:52:57 +00:00
|
|
|
// Gives the character the functionality
|
2022-11-10 11:52:10 +00:00
|
|
|
void ATempCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
|
|
|
|
{
|
|
|
|
Super::SetupPlayerInputComponent(PlayerInputComponent);
|
|
|
|
PlayerInputComponent->BindAxis(TEXT("Move Forward / Backward"), this, &ATempCharacter::ForwardInput);
|
|
|
|
PlayerInputComponent->BindAxis(TEXT("Move Right / Left"), this, &ATempCharacter::RightMoveInput);
|
|
|
|
PlayerInputComponent->BindAxis(TEXT("Turn Right / Left Mouse"), this, &ATempCharacter::AddControllerYawInput);
|
|
|
|
PlayerInputComponent->BindAxis(TEXT("Look Up / Down Mouse"), this, &ATempCharacter::AddControllerPitchInput);
|
2023-02-06 14:30:13 +00:00
|
|
|
PlayerInputComponent->BindAction(TEXT("Jump"), IE_Pressed, this, &ATempCharacter::Jump);
|
|
|
|
PlayerInputComponent->BindAction(TEXT("Sneak"), IE_Pressed, this, &ATempCharacter::Sneak);
|
2023-02-06 15:26:22 +00:00
|
|
|
PlayerInputComponent->BindAction(TEXT("Sneak"), IE_Released, this, &ATempCharacter::Sneak);
|
2022-11-11 22:21:10 +00:00
|
|
|
PlayerInputComponent->BindAction("Interact", IE_Pressed, this, &ATempCharacter::KeyPressed);
|
2022-11-10 11:52:10 +00:00
|
|
|
}
|
2022-11-11 22:21:10 +00:00
|
|
|
|
2022-11-14 16:52:57 +00:00
|
|
|
// When the player presses the E key
|
2022-11-11 20:21:44 +00:00
|
|
|
void ATempCharacter::KeyPressed()
|
2022-11-10 11:52:10 +00:00
|
|
|
{
|
2022-11-11 22:21:10 +00:00
|
|
|
LineTraceLogic();
|
|
|
|
}
|
|
|
|
|
2023-02-06 14:30:13 +00:00
|
|
|
|
2022-11-14 16:52:57 +00:00
|
|
|
// Line trace logic
|
2022-11-11 22:21:10 +00:00
|
|
|
void ATempCharacter::LineTraceLogic()
|
|
|
|
{
|
2023-03-06 04:28:13 +00:00
|
|
|
//UE_LOG(LogTemp, Display, TEXT("LineTraceLogic activated"));
|
2023-01-16 20:44:23 +00:00
|
|
|
ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());
|
2023-05-21 18:06:16 +00:00
|
|
|
const float GlobalTrace = TraceDistance;
|
|
|
|
const FVector Start = ThisCamera->GetComponentLocation();
|
|
|
|
const FVector End = Start + GlobalTrace * ThisCamera->GetForwardVector();
|
2022-11-10 16:38:38 +00:00
|
|
|
FCollisionQueryParams TraceParams;
|
2022-11-11 20:21:44 +00:00
|
|
|
TraceParams.AddIgnoredActor(this);
|
2023-04-28 00:40:49 +00:00
|
|
|
bHit = GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Pawn, TraceParams);
|
2022-11-11 22:21:10 +00:00
|
|
|
if (bHit)
|
2022-11-10 16:38:38 +00:00
|
|
|
{
|
2023-02-23 01:28:29 +00:00
|
|
|
if (OutHit.GetActor() == nullptr)
|
2022-11-13 16:43:01 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2023-05-21 14:19:18 +00:00
|
|
|
if (OutHit.GetActor()->ActorHasTag(TEXT("Probertium")))
|
2023-05-10 12:27:27 +00:00
|
|
|
{
|
|
|
|
AddToInventory();
|
|
|
|
return;
|
|
|
|
}
|
2023-05-21 14:19:18 +00:00
|
|
|
if (OutHit.GetActor()->ActorHasTag(TEXT("Iroquid")))
|
2023-05-10 12:27:27 +00:00
|
|
|
{
|
|
|
|
AddToInventory();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (OutHit.GetActor()->ActorHasTag(TEXT("Azos")))
|
|
|
|
{
|
|
|
|
AddToInventory();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (OutHit.GetActor()->ActorHasTag(TEXT("Eis")))
|
|
|
|
{
|
|
|
|
AddToInventory();
|
|
|
|
return;
|
|
|
|
}
|
2023-05-21 18:06:16 +00:00
|
|
|
if (OutHit.GetActor()->ActorHasTag(TEXT("Interactable")))
|
|
|
|
{
|
|
|
|
FOutputDeviceNull AR;
|
|
|
|
const FString Command = FString::Printf(TEXT("Interact"));
|
|
|
|
OutHit.GetActor()->CallFunctionByNameWithArguments(*Command, AR, nullptr, true);
|
|
|
|
return;
|
|
|
|
}
|
2023-02-23 01:28:29 +00:00
|
|
|
if (OutHit.GetActor()->FindComponentByClass<UInventoryComponent>())
|
2022-11-15 03:27:44 +00:00
|
|
|
{
|
2023-02-04 17:39:12 +00:00
|
|
|
UE_LOG(LogTemp, Display, TEXT("Hit Merchant"));
|
2023-05-21 18:06:16 +00:00
|
|
|
const auto ItemArray = OutHit.GetActor()->FindComponentByClass<UInventoryComponent>()->GetItem(0);
|
2023-02-23 01:28:29 +00:00
|
|
|
if (GoldBalance >= ItemArray->ItemCostPrice)
|
2022-11-15 03:27:44 +00:00
|
|
|
{
|
2022-11-29 12:55:46 +00:00
|
|
|
GoldBalance -= ItemArray->ItemCostPrice;
|
|
|
|
Inventory->AddItem(ItemArray);
|
2022-11-15 03:27:44 +00:00
|
|
|
UE_LOG(LogTemp, Display, TEXT("Item Purchased"));
|
|
|
|
}
|
2023-02-23 01:28:29 +00:00
|
|
|
if (GoldBalance <= 0)
|
2022-11-15 03:27:44 +00:00
|
|
|
{
|
|
|
|
UE_LOG(LogTemp, Display, TEXT("Not Enough Gold"));
|
|
|
|
}
|
|
|
|
}
|
2023-01-14 20:35:49 +00:00
|
|
|
// if the actor hit has the interaction component/script then it will activate the code
|
2023-02-23 01:28:29 +00:00
|
|
|
|
2023-05-21 14:19:18 +00:00
|
|
|
if (const AInteraction* MyInteractable = Cast<AInteraction>(OutHit.GetActor()))
|
2022-11-11 20:35:41 +00:00
|
|
|
{
|
2023-01-30 21:07:36 +00:00
|
|
|
if (MyInteractable->ShopDialogWidget->IsVisible())
|
|
|
|
{
|
|
|
|
UE_LOG(LogTemp, Display, TEXT("ShopKeeper text is visible"));
|
|
|
|
bShopKeeperText = true;
|
2023-01-14 20:35:49 +00:00
|
|
|
}
|
2022-11-11 20:35:41 +00:00
|
|
|
}
|
2022-11-10 16:38:38 +00:00
|
|
|
}
|
2022-11-10 11:52:10 +00:00
|
|
|
}
|
2022-11-14 16:52:57 +00:00
|
|
|
|
2023-05-10 12:27:27 +00:00
|
|
|
void ATempCharacter::AddToInventory()
|
|
|
|
{
|
|
|
|
if (OutHit.GetActor()->FindComponentByClass<UInventoryComponent>())
|
|
|
|
{
|
|
|
|
UE_LOG(LogTemp, Display, TEXT("Hit Merchant"));
|
2023-05-21 18:06:16 +00:00
|
|
|
const auto ItemArray = OutHit.GetActor()->FindComponentByClass<UInventoryComponent>()->GetItem(0);
|
2023-05-10 12:27:27 +00:00
|
|
|
if (GoldBalance >= ItemArray->ItemCostPrice)
|
|
|
|
{
|
|
|
|
GoldBalance -= ItemArray->ItemCostPrice;
|
|
|
|
Inventory->AddItem(ItemArray);
|
|
|
|
UE_LOG(LogTemp, Display, TEXT("Item Purchased"));
|
|
|
|
}
|
|
|
|
if (GoldBalance <= 0)
|
|
|
|
{
|
|
|
|
UE_LOG(LogTemp, Display, TEXT("Not Enough Gold"));
|
|
|
|
}
|
|
|
|
OutHit.GetActor()->Destroy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-14 20:35:49 +00:00
|
|
|
void ATempCharacter::InputDisabler()
|
|
|
|
{
|
2023-03-16 14:49:17 +00:00
|
|
|
CrossHairWidget->SetVisibility(ESlateVisibility::Hidden);
|
2023-05-21 14:19:18 +00:00
|
|
|
|
2023-02-06 15:26:22 +00:00
|
|
|
//Set to UI Mode Only
|
|
|
|
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
|
2023-05-21 14:19:18 +00:00
|
|
|
PlayerController->SetInputMode(FInputModeGameAndUI());
|
2023-02-06 15:26:22 +00:00
|
|
|
PlayerController->bShowMouseCursor = true;
|
2023-05-21 14:19:18 +00:00
|
|
|
PlayerController->SetIgnoreMoveInput(true);
|
|
|
|
PlayerController->SetIgnoreLookInput(true);
|
2023-03-16 17:18:01 +00:00
|
|
|
|
2023-02-04 17:39:12 +00:00
|
|
|
disableTab = true;
|
2023-02-17 13:12:28 +00:00
|
|
|
if (ThisCamera != nullptr)
|
2023-01-16 20:44:23 +00:00
|
|
|
{
|
2023-03-16 17:18:01 +00:00
|
|
|
OriginalCameraLocation = ThisCamera->GetComponentLocation();
|
|
|
|
OriginalCameraRotation = ThisCamera->GetComponentRotation();
|
2023-01-16 20:44:23 +00:00
|
|
|
OriginalCameraFOV = ThisCamera->FieldOfView;
|
2023-03-16 17:18:01 +00:00
|
|
|
UE_LOG(LogTemp, Display, TEXT("Original Camera Location: %s"), *OriginalCameraLocation.ToString());
|
2023-01-16 20:44:23 +00:00
|
|
|
}
|
2023-01-15 16:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ATempCharacter::InputEnabler()
|
|
|
|
{
|
2023-02-06 15:26:22 +00:00
|
|
|
//Reset UI Mode
|
|
|
|
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
|
|
|
|
PlayerController->SetInputMode(FInputModeGameOnly());
|
|
|
|
PlayerController->bShowMouseCursor = false;
|
2023-05-13 16:58:13 +00:00
|
|
|
PlayerController->SetIgnoreMoveInput(false);
|
|
|
|
PlayerController->SetIgnoreLookInput(false);
|
2023-05-21 14:19:18 +00:00
|
|
|
CrossHairWidget->SetVisibility(ESlateVisibility::HitTestInvisible);
|
2023-03-16 17:18:01 +00:00
|
|
|
|
2023-05-21 14:19:18 +00:00
|
|
|
//Enable Character Movement
|
|
|
|
if (ACharacter* PlayerCharacter = Cast<ACharacter>(GetWorld()->GetFirstPlayerController()->GetPawn()))
|
|
|
|
{
|
|
|
|
PlayerCharacter->EnableInput(GetWorld()->GetFirstPlayerController());
|
|
|
|
}
|
2023-05-21 17:55:22 +00:00
|
|
|
|
2023-03-16 17:18:01 +00:00
|
|
|
UE_LOG(LogTemp, Display, TEXT("Enabling Inputs"));
|
2023-02-04 17:39:12 +00:00
|
|
|
disableTab = true;
|
2023-01-17 02:46:42 +00:00
|
|
|
TraceDistance = 300;
|
2023-02-17 13:12:28 +00:00
|
|
|
if (ThisCamera != nullptr)
|
2023-01-16 20:44:23 +00:00
|
|
|
{
|
2023-03-16 17:18:01 +00:00
|
|
|
ThisCamera->SetWorldLocation(OriginalCameraLocation);
|
|
|
|
ThisCamera->SetWorldRotation(OriginalCameraRotation);
|
2023-01-16 20:44:23 +00:00
|
|
|
ThisCamera->FieldOfView = OriginalCameraFOV;
|
2023-03-16 17:18:01 +00:00
|
|
|
UE_LOG(LogTemp, Display, TEXT("Original Camera Location: %s"), *OriginalCameraLocation.ToString());
|
2023-01-16 20:44:23 +00:00
|
|
|
}
|
2023-01-14 20:35:49 +00:00
|
|
|
}
|
|
|
|
|
2022-11-14 16:52:57 +00:00
|
|
|
void ATempCharacter::UseItem(class UBaseItem* Item)
|
|
|
|
{
|
2023-02-23 01:28:29 +00:00
|
|
|
if (Item)
|
2022-11-14 16:52:57 +00:00
|
|
|
{
|
|
|
|
Item->Use(this);
|
2023-02-06 15:55:12 +00:00
|
|
|
Item->OnUse(this); //OnUse is a Blueprint Version
|
2022-11-14 16:52:57 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-15 03:27:44 +00:00
|
|
|
|
2023-03-28 02:43:31 +00:00
|
|
|
void ATempCharacter::BuyItem(AActor* Item)
|
2023-01-16 20:44:23 +00:00
|
|
|
{
|
2023-05-09 11:50:34 +00:00
|
|
|
if (Item == nullptr)
|
2023-03-28 02:43:31 +00:00
|
|
|
{
|
2023-05-09 11:50:34 +00:00
|
|
|
UE_LOG(LogTemp, Display, TEXT("Item is null"));
|
|
|
|
return;
|
2023-03-28 02:43:31 +00:00
|
|
|
}
|
2023-05-09 11:50:34 +00:00
|
|
|
else
|
2023-03-28 02:43:31 +00:00
|
|
|
{
|
2023-05-09 11:50:34 +00:00
|
|
|
UBaseItem* ItemArray = Item->FindComponentByClass<UInventoryComponent>()->GetItem(0);
|
|
|
|
if (GoldBalance <= 0)
|
|
|
|
{
|
|
|
|
UE_LOG(LogTemp, Display, TEXT("Not Enough Gold"));
|
|
|
|
}
|
|
|
|
else if (GoldBalance >= ItemArray->ItemCostPrice)
|
|
|
|
{
|
|
|
|
GoldBalance -= ItemArray->ItemCostPrice;
|
|
|
|
Inventory->AddItem(ItemArray);
|
|
|
|
UE_LOG(LogTemp, Display, TEXT("Item Purchased"));
|
|
|
|
}
|
|
|
|
UE_LOG(LogTemp, Display, TEXT("BUY ITEM FIRING"));
|
|
|
|
TraceDistance = 1000;
|
|
|
|
LineTraceLogic();
|
2023-03-28 02:43:31 +00:00
|
|
|
}
|
2023-01-16 20:44:23 +00:00
|
|
|
}
|