diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp index a029e95..cfd111a 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp @@ -9,6 +9,7 @@ #include "GameFramework/Character.h" #include "Components/WidgetComponent.h" #include "Kismet/KismetMathLibrary.h" +#include "the_twilight_abyss/PlayerTemp/TempCharacter.h" // Sets default values @@ -24,9 +25,8 @@ void AInteraction::BeginPlay() Super::BeginPlay(); //Character refs - TempCharacter = GetWorld()->GetFirstPlayerController()->GetCharacter(); - MainCamera = Cast(TempCharacter->FindComponentByClass()); - + TempCharacterRef = Cast(GetWorld()->GetFirstPlayerController()->GetCharacter()); + MainCamera = Cast(TempCharacterRef->FindComponentByClass()); //Item refs TargetHealingLocation = HealingItem->GetActorLocation(); @@ -57,6 +57,7 @@ void AInteraction::BeginPlay() BuyHealingTextWidget->AddToViewport(); //We are getting the property of interaction since we need a reference for when we cast in BP and we need the reference to be self BuyHealingProperty = BuyHealingTextWidget->GetClass()->FindPropertyByName("publicActor"); + } // Called every frame @@ -118,7 +119,7 @@ void AInteraction::RemoveWidget() void AInteraction::CameraLeftMover() { UE_LOG(LogTemp, Display, TEXT("Button Left is being pressed")); - if (TempCharacter == nullptr || BuyHealingProperty == nullptr) + if (TempCharacterRef == nullptr || BuyHealingProperty == nullptr) { UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp")); return; @@ -148,7 +149,7 @@ void AInteraction::CameraLeftMover() void AInteraction::CameraRightMover() { UE_LOG(LogTemp, Display, TEXT("Button Right is being pressed")); - if (TempCharacter == nullptr || BuyBuffProperty == nullptr) + if (TempCharacterRef == nullptr || BuyBuffProperty == nullptr) { UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp")); return; @@ -181,15 +182,20 @@ void AInteraction::CancelPurchase() BuyHealingTextWidget->SetVisibility(ESlateVisibility::Hidden); } -void AInteraction::HealingPurchase() +void AInteraction::ExitScreen() { - -} - -void AInteraction::BuffPurchase() -{ - + if (TempCharacterRef == nullptr) + { + UE_LOG(LogTemp, Display, TEXT("TempCharacterRef in Interaction.cpp not found")); + return; + } + else + { + TempCharacterRef->InputEnabler(); + ItemSelectorWidget->SetVisibility(ESlateVisibility::Hidden); + } } + diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h index 72b0afb..798c680 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h @@ -5,6 +5,7 @@ #include "CoreMinimal.h" #include "Camera/CameraComponent.h" #include "GameFramework/Actor.h" +#include "the_twilight_abyss/PlayerTemp/TempCharacter.h" #include "Interaction.generated.h" UCLASS() @@ -70,9 +71,6 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera") UCameraComponent* MainCamera; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player") - ACharacter* TempCharacter; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Items") AActor* HealingItem; @@ -83,10 +81,10 @@ public: virtual void CancelPurchase(); UFUNCTION(BlueprintCallable, Category = "ConfirmButtons") - virtual void HealingPurchase(); - - UFUNCTION(BlueprintCallable, Category = "ConfirmButtons") - virtual void BuffPurchase(); + virtual void ExitScreen(); + + UPROPERTY(EditAnywhere, Category = "Player") + ATempCharacter* TempCharacterRef; private: diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index da1d08c..d646157 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -161,7 +161,6 @@ void ATempCharacter::InputEnabler() ThisCamera->SetWorldLocation(OriginalCameraLocation); ThisCamera->SetWorldRotation(OriginalCameraRotation); ThisCamera->FieldOfView = OriginalCameraFOV; - ItemSelectorWidget->SetVisibility(ESlateVisibility::Hidden); //ulog the originalcameralocation value UE_LOG(LogTemp, Display, TEXT("Original Camera Location: %s"), *OriginalCameraLocation.ToString()); } diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index 5333280..9bb3b3f 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -31,12 +31,9 @@ public: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = "true")) class UInventoryComponent* Inventory; //Using the InventoryComponent class - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ItemSelector") + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets") UUserWidget* ItemSelectorWidget; - - UPROPERTY(EditAnywhere, Category = "Widgets") - TSubclassOf ItemSelector; // Called to bind functionality to input virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;