From d8a4603651d66b76a3025e748065d3d3ef24337d Mon Sep 17 00:00:00 2001 From: MarcelHara Date: Mon, 8 May 2023 20:03:54 +0100 Subject: [PATCH] Updated Merchant to fix buttons not working --- .../the_twilight_abyss/BaseItems/Items/BaseItem.h | 2 +- .../MerchantInteraction/Interaction.cpp | 13 ++++++++++--- .../the_twilight_abyss/PlayerTemp/TempCharacter.cpp | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h index de0964b..2cdcf5c 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h +++ b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h @@ -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); diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp index a3ee695..e9dbe65 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp @@ -25,8 +25,8 @@ void AInteraction::BeginPlay() Super::BeginPlay(); //Character & Camera refs - if (TempCharacterRef != nullptr) TempCharacterRef = Cast(GetWorld()->GetFirstPlayerController()->GetCharacter()); - if (MainCamera != nullptr) MainCamera = Cast(TempCharacterRef->FindComponentByClass()); + TempCharacterRef = Cast(GetWorld()->GetFirstPlayerController()->GetCharacter()); + MainCamera = Cast(TempCharacterRef->FindComponentByClass()); //Item refs TargetHealingLocation = HealingItem->GetActorLocation(); @@ -130,7 +130,14 @@ void AInteraction::CameraLeftMover() UE_LOG(LogTemp, Display, TEXT("Button Left is being pressed")); if (TempCharacterRef == nullptr || BuyHealingProperty == nullptr) { - UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp")); + 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 diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index 77c5aa7..c3f4d17 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -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()->GetItem(0); + UBaseItem* ItemArray = Item->FindComponentByClass()->GetItem(0); if (GoldBalance <= 0) { UE_LOG(LogTemp, Display, TEXT("Not Enough Gold"));