Updated Merchant to fix buttons not working

This commit is contained in:
MarcelHara 2023-05-08 20:03:54 +01:00
parent 9e55e8f930
commit d8a4603651
3 changed files with 12 additions and 5 deletions

View File

@ -76,7 +76,7 @@ public:
class UInventoryComponent* StoredItems;
//The buy class to purchase the item
virtual void Buy(class ATempCharacter* PurchaseItem) PURE_VIRTUAL(UBaseItem); // WILL SET THIS UP LATER
virtual void Buy(class ATempCharacter* BuyItem) PURE_VIRTUAL(UBaseItem); // WILL SET THIS UP LATER
//The use Item class to use the item in the player Inventory
virtual void Use(class ATempCharacter* Character);

View File

@ -25,8 +25,8 @@ void AInteraction::BeginPlay()
Super::BeginPlay();
//Character & Camera refs
if (TempCharacterRef != nullptr) TempCharacterRef = Cast<ATempCharacter>(GetWorld()->GetFirstPlayerController()->GetCharacter());
if (MainCamera != nullptr) MainCamera = Cast<UCameraComponent>(TempCharacterRef->FindComponentByClass<UCameraComponent>());
TempCharacterRef = Cast<ATempCharacter>(GetWorld()->GetFirstPlayerController()->GetCharacter());
MainCamera = Cast<UCameraComponent>(TempCharacterRef->FindComponentByClass<UCameraComponent>());
//Item refs
TargetHealingLocation = HealingItem->GetActorLocation();
@ -129,8 +129,15 @@ void AInteraction::CameraLeftMover()
{
UE_LOG(LogTemp, Display, TEXT("Button Left is being pressed"));
if (TempCharacterRef == nullptr || BuyHealingProperty == nullptr)
{
if (TempCharacterRef == nullptr)
{
UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp"));
}
else if (BuyHealingProperty == nullptr)
{
UE_LOG(LogTemp, Display, TEXT("HealingItem Not Found"));
}
return;
}
else

View File

@ -272,7 +272,7 @@ void ATempCharacter::UseItem(class UBaseItem* Item)
void ATempCharacter::BuyItem(AActor* Item)
{
UE_LOG(LogTemp, Display, TEXT("Hit Merchant"));
auto ItemArray = Item->FindComponentByClass<UInventoryComponent>()->GetItem(0);
UBaseItem* ItemArray = Item->FindComponentByClass<UInventoryComponent>()->GetItem(0);
if (GoldBalance <= 0)
{
UE_LOG(LogTemp, Display, TEXT("Not Enough Gold"));