Merge remote-tracking branch 'origin/merchant-system-v4' into Turn-Based-Combat
# Conflicts: # Content/Blueprints/Combat_UI/CombatCharacter.uasset
This commit is contained in:
commit
7e81387247
BIN
Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Merchant/Merchant_UI/WBP_BuyBuff.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Merchant/Merchant_UI/WBP_BuyBuff.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Merchant/Merchant_UI/WBP_BuyHealing.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Merchant/Merchant_UI/WBP_BuyHealing.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Player/BP_MyTempCharacter.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Player/BP_MyTempCharacter.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Levels/MerchantPrototype.umap
(Stored with Git LFS)
BIN
Content/Levels/MerchantPrototype.umap
(Stored with Git LFS)
Binary file not shown.
@ -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
|
||||
@ -23,6 +24,40 @@ void AInteraction::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
//Character & Camera refs
|
||||
TempCharacterRef = Cast<ATempCharacter>(GetWorld()->GetFirstPlayerController()->GetCharacter());
|
||||
MainCamera = Cast<UCameraComponent>(TempCharacterRef->FindComponentByClass<UCameraComponent>());
|
||||
//Item refs
|
||||
|
||||
TargetHealingLocation = HealingItem->GetActorLocation();
|
||||
TargetBuffLocation = BuffItem->GetActorLocation();
|
||||
|
||||
// Dialog refs
|
||||
|
||||
ShopDialogWidget = CreateWidget<UUserWidget>(GetWorld(), ShopDialog);
|
||||
ShopDialogWidget->SetVisibility(ESlateVisibility::Hidden);
|
||||
ShopDialogWidget->AddToViewport();
|
||||
|
||||
//Item Selector refs
|
||||
ItemSelectorWidget = CreateWidget<UUserWidget>(GetWorld(), ItemSelector);
|
||||
ItemSelectorWidget->SetVisibility(ESlateVisibility::Hidden);
|
||||
ItemSelectorWidget->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
|
||||
Property = ItemSelectorWidget->GetClass()->FindPropertyByName("publicActor");
|
||||
|
||||
//Confirm Buy refs
|
||||
BuyBuffTextWidget = CreateWidget<UUserWidget>(GetWorld(), BuyBuffText);
|
||||
BuyBuffTextWidget->SetVisibility(ESlateVisibility::Hidden);
|
||||
BuyBuffTextWidget->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
|
||||
BuyBuffProperty = BuyBuffTextWidget->GetClass()->FindPropertyByName("publicActor");
|
||||
|
||||
BuyHealingTextWidget = CreateWidget<UUserWidget>(GetWorld(), BuyHealingText);
|
||||
BuyHealingTextWidget->SetVisibility(ESlateVisibility::Hidden);
|
||||
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
|
||||
@ -35,14 +70,17 @@ void AInteraction::Tick(float DeltaTime)
|
||||
void AInteraction::OnInteract()
|
||||
{
|
||||
bDisableShopDialMove = true;
|
||||
ShopDialogWidget = CreateWidget<UUserWidget>(GetWorld(), ShopDialog);
|
||||
if (ShopDialogWidget == nullptr)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("ShopDialogWidget is null"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ShopDialogWidget->AddToViewport(0);
|
||||
//Shop Widget to visible
|
||||
ShopDialogWidget->SetVisibility(ESlateVisibility::Visible);
|
||||
//Call a custom event in a blueprint called "PlayText"
|
||||
ShopDialogWidget->CallFunctionByNameWithArguments(TEXT("PlayText"), *GLog, nullptr, true);
|
||||
}
|
||||
//handles the widget disappearing from the viewport
|
||||
FTimerHandle WidgetTimer;
|
||||
@ -53,13 +91,22 @@ void AInteraction::OnInteract()
|
||||
void AInteraction::RemoveWidget()
|
||||
{
|
||||
bisDisabled = true;
|
||||
ShopDialogWidget->RemoveFromViewport();
|
||||
//Setting ShopWidgetText back to hidden
|
||||
ShopDialogWidget->SetVisibility(ESlateVisibility::Hidden);
|
||||
if (ShopDialogWidget->IsVisible())
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("You cant open this widget when this widget is open"));
|
||||
}
|
||||
UE_LOG(LogTemp, Display, TEXT("setting isDisabled to true"));
|
||||
ItemSelectorWidget = CreateWidget<UUserWidget>(GetWorld(), ItemSelector);
|
||||
FProperty* Property = ItemSelectorWidget->GetClass()->FindPropertyByName("publicActor");
|
||||
|
||||
if (Property == nullptr)
|
||||
{
|
||||
UE_LOG(LogTemp, Error, TEXT("Property not found"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -72,7 +119,7 @@ void AInteraction::RemoveWidget()
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemSelectorWidget->AddToViewport(0);
|
||||
ItemSelectorWidget->SetVisibility(ESlateVisibility::Visible);
|
||||
bisDisabled = false;
|
||||
}
|
||||
}
|
||||
@ -80,9 +127,7 @@ void AInteraction::RemoveWidget()
|
||||
void AInteraction::CameraLeftMover()
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Button Left is being pressed"));
|
||||
TempCharacter = GetWorld()->GetFirstPlayerController()->GetCharacter();
|
||||
MainCamera = Cast<UCameraComponent>(TempCharacter->FindComponentByClass<UCameraComponent>());
|
||||
if (TempCharacter == nullptr)
|
||||
if (TempCharacterRef == nullptr || BuyHealingProperty == nullptr)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp"));
|
||||
return;
|
||||
@ -90,18 +135,21 @@ void AInteraction::CameraLeftMover()
|
||||
else
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Character Found in interaction.cpp"));
|
||||
if (MainCamera == nullptr)
|
||||
if (MainCamera == nullptr || HealingItem == nullptr)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Camera not found in Interaction.cpp"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
FVector TargetLocation = FVector(5700,-1270,4040);
|
||||
FVector CameraLocation = MainCamera->GetComponentLocation();
|
||||
FRotator CameraRotation = UKismetMathLibrary::FindLookAtRotation(CameraLocation, TargetLocation);
|
||||
FObjectPropertyBase* ObjectProperty = static_cast<FObjectPropertyBase*>(BuyHealingProperty);
|
||||
ObjectProperty->SetObjectPropertyValue(ObjectProperty->ContainerPtrToValuePtr<void>(BuyHealingTextWidget), this);
|
||||
|
||||
CameraLocation = MainCamera->GetComponentLocation();
|
||||
FRotator CameraRotation = UKismetMathLibrary::FindLookAtRotation(CameraLocation, TargetHealingLocation);
|
||||
MainCamera->SetWorldRotation(CameraRotation);
|
||||
MainCamera->SetFieldOfView(40);
|
||||
BuyHealingTextWidget->SetVisibility(ESlateVisibility::Visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -109,9 +157,7 @@ void AInteraction::CameraLeftMover()
|
||||
void AInteraction::CameraRightMover()
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Button Right is being pressed"));
|
||||
TempCharacter = GetWorld()->GetFirstPlayerController()->GetCharacter();
|
||||
MainCamera = Cast<UCameraComponent>(TempCharacter->FindComponentByClass<UCameraComponent>());
|
||||
if (TempCharacter == nullptr)
|
||||
if (TempCharacterRef == nullptr || BuyBuffProperty == nullptr)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp"));
|
||||
return;
|
||||
@ -119,18 +165,45 @@ void AInteraction::CameraRightMover()
|
||||
else
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Character Found in interaction.cpp"));
|
||||
if (MainCamera == nullptr)
|
||||
if (MainCamera == nullptr || BuffItem == nullptr)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Camera not found in Interaction.cpp"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
FVector TargetLocation = FVector(5260, -840, 4070);
|
||||
FVector CameraLocation = MainCamera->GetComponentLocation();
|
||||
FRotator CameraRotation = UKismetMathLibrary::FindLookAtRotation(CameraLocation, TargetLocation);
|
||||
FObjectPropertyBase* ObjectProperty = static_cast<FObjectPropertyBase*>(BuyBuffProperty);
|
||||
ObjectProperty->SetObjectPropertyValue(ObjectProperty->ContainerPtrToValuePtr<void>(BuyBuffTextWidget), this);
|
||||
|
||||
CameraLocation = MainCamera->GetComponentLocation();
|
||||
FRotator CameraRotation = UKismetMathLibrary::FindLookAtRotation(CameraLocation, TargetBuffLocation);
|
||||
MainCamera->SetWorldRotation(CameraRotation);
|
||||
MainCamera->SetFieldOfView(40);
|
||||
BuyBuffTextWidget->SetVisibility(ESlateVisibility::Visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AInteraction::CancelPurchase()
|
||||
{
|
||||
BuyBuffTextWidget->SetVisibility(ESlateVisibility::Hidden);
|
||||
BuyHealingTextWidget->SetVisibility(ESlateVisibility::Hidden);
|
||||
}
|
||||
|
||||
void AInteraction::ExitScreen()
|
||||
{
|
||||
if (TempCharacterRef == nullptr)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("TempCharacterRef in Interaction.cpp not found"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
TempCharacterRef->InputEnabler();
|
||||
ItemSelectorWidget->SetVisibility(ESlateVisibility::Hidden);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -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()
|
||||
@ -24,12 +25,18 @@ public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
UPROPERTY(EditAnywhere, Category= "Widgets")
|
||||
TSubclassOf<UUserWidget> ShopDialog;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
UPROPERTY(EditAnywhere, Category= "Widgets")
|
||||
TSubclassOf<UUserWidget> ItemSelector;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Widgets")
|
||||
TSubclassOf<UUserWidget> BuyBuffText;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Widgets")
|
||||
TSubclassOf<UUserWidget> BuyHealingText;
|
||||
|
||||
virtual void OnInteract();
|
||||
|
||||
virtual void RemoveWidget();
|
||||
@ -39,8 +46,14 @@ public:
|
||||
|
||||
UPROPERTY()
|
||||
UUserWidget* ItemSelectorWidget;
|
||||
|
||||
UPROPERTY()
|
||||
UUserWidget* BuyBuffTextWidget;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
UPROPERTY()
|
||||
UUserWidget* BuyHealingTextWidget;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category= "Widgets")
|
||||
float WaitTimer = 8.0f;
|
||||
|
||||
UPROPERTY()
|
||||
@ -48,6 +61,7 @@ public:
|
||||
|
||||
UPROPERTY()
|
||||
bool bDisableShopDialMove = false;
|
||||
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category= "ButtonLeft")
|
||||
virtual void CameraLeftMover();
|
||||
@ -58,7 +72,29 @@ public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera")
|
||||
UCameraComponent* MainCamera;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player")
|
||||
ACharacter* TempCharacter;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Items")
|
||||
AActor* HealingItem;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Items")
|
||||
AActor* BuffItem;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "ConfirmButtons")
|
||||
virtual void CancelPurchase();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "ConfirmButtons")
|
||||
virtual void ExitScreen();
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Player")
|
||||
ATempCharacter* TempCharacterRef;
|
||||
|
||||
private:
|
||||
|
||||
FVector TargetHealingLocation;
|
||||
FVector TargetBuffLocation;
|
||||
FVector CameraLocation;
|
||||
|
||||
FProperty* Property;
|
||||
FProperty* BuyBuffProperty;
|
||||
FProperty* BuyHealingProperty;
|
||||
};
|
||||
|
||||
|
@ -101,18 +101,35 @@ void ATempCharacter::LineTraceLogic()
|
||||
|
||||
if (AInteraction* MyInteractable = Cast<AInteraction>(OutHit.GetActor()))
|
||||
{
|
||||
DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f);
|
||||
MyInteractable->OnInteract();
|
||||
UE_LOG(LogTemp, Display, TEXT("OnInteract activated"));
|
||||
UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *OutHit.GetActor()->GetName());
|
||||
|
||||
// While loop to check bisDisabled var until it changes to true
|
||||
while (MyInteractable->bisDisabled == false || MyInteractable->bDisableShopDialMove == false)
|
||||
if (MyInteractable->ShopDialogWidget->IsVisible())
|
||||
{
|
||||
if (MyInteractable->bisDisabled == true || MyInteractable->bDisableShopDialMove == true)
|
||||
UE_LOG(LogTemp, Display, TEXT("ShopKeeper text is visible"));
|
||||
bShopKeeperText = true;
|
||||
return;
|
||||
}
|
||||
//if there is no text on screen this triggers
|
||||
else
|
||||
{
|
||||
if (MyInteractable->ItemSelectorWidget->IsVisible())
|
||||
{
|
||||
InputDisabler();
|
||||
break;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f);
|
||||
MyInteractable->OnInteract();
|
||||
UE_LOG(LogTemp, Display, TEXT("OnInteract activated"));
|
||||
UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *OutHit.GetActor()->GetName());
|
||||
|
||||
// While loop to check bisDisabled var until it changes to true
|
||||
while (MyInteractable->bisDisabled == false || MyInteractable->bDisableShopDialMove == false)
|
||||
{
|
||||
if (MyInteractable->bisDisabled == true || MyInteractable->bDisableShopDialMove == true)
|
||||
{
|
||||
InputDisabler();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -122,6 +139,7 @@ void ATempCharacter::LineTraceLogic()
|
||||
void ATempCharacter::InputDisabler()
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Disabling playermovement"));
|
||||
//GetWorld()->GetFirstPlayerController()->InputComponent->RemoveActionBinding("Interact", IE_Pressed);
|
||||
GetWorld()->GetFirstPlayerController()->SetIgnoreLookInput(true);
|
||||
GetWorld()->GetFirstPlayerController()->SetIgnoreMoveInput(true);
|
||||
GetWorld()->GetFirstPlayerController()->bShowMouseCursor = true;
|
||||
@ -150,6 +168,7 @@ void ATempCharacter::InputEnabler()
|
||||
GetWorld()->GetFirstPlayerController()->bShowMouseCursor = false;
|
||||
GetWorld()->GetFirstPlayerController()->bEnableClickEvents = false;
|
||||
GetWorld()->GetFirstPlayerController()->bEnableMouseOverEvents = false;
|
||||
//GetWorld()->GetFirstPlayerController()->InputComponent->BindAction("Interact", IE_Pressed, this, &ATempCharacter::KeyPressed);
|
||||
TraceDistance = 300;
|
||||
ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());
|
||||
if (ThisCamera == nullptr)
|
||||
@ -161,7 +180,6 @@ void ATempCharacter::InputEnabler()
|
||||
ThisCamera->SetWorldLocation(OriginalCameraLocation);
|
||||
ThisCamera->SetWorldRotation(OriginalCameraRotation);
|
||||
ThisCamera->FieldOfView = OriginalCameraFOV;
|
||||
|
||||
//ulog the originalcameralocation value
|
||||
UE_LOG(LogTemp, Display, TEXT("Original Camera Location: %s"), *OriginalCameraLocation.ToString());
|
||||
}
|
||||
|
@ -31,7 +31,10 @@ public:
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = "true"))
|
||||
class UInventoryComponent* Inventory; //Using the InventoryComponent class
|
||||
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets")
|
||||
UUserWidget* ItemSelectorWidget;
|
||||
|
||||
// Called to bind functionality to input
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
|
||||
@ -43,6 +46,8 @@ public:
|
||||
void InputDisabler();
|
||||
void LineTraceLogic();
|
||||
|
||||
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= "Health")
|
||||
float Health;
|
||||
|
||||
@ -70,5 +75,7 @@ public:
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category= "Items")
|
||||
void BuyItem();
|
||||
|
||||
bool bShopKeeperText = false;
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user