Updated DialogueNPC to Add Dialogue via Blueprints

This commit is contained in:
Philip W 2023-02-06 03:28:53 +00:00
parent e5b624411d
commit 7f3e3cbb52
3 changed files with 28 additions and 15 deletions

BIN
Content/Dialogue/NPCTest.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -34,8 +34,6 @@ void UDialogueNPC::BeginPlay()
void UDialogueNPC::NextDialogue()
{
//log bruh
UE_LOG(LogTemp, Warning, TEXT("Next Dialogue"));
//Dialogue Skip
if (CurrentDialogue.Len() < Dialogue[DialogueIndex].Len())
{
@ -85,7 +83,7 @@ void UDialogueNPC::StartDialogue()
PlayerController->bShowMouseCursor = true;
DialogueWidgetInstance->AddToViewport();
DialogueIndex = 0;
DialogueIndex = 1;
NPCNameText->SetText(FText::FromString(NPCName));
CurrentDialogue = "";
GetWorld()->GetTimerManager().SetTimer(TextAnimationTimerHandle, this, &UDialogueNPC::NextCharacter, TextAnimationSpeed, true);
@ -106,3 +104,15 @@ void UDialogueNPC::EndDialogue()
PlayerController->SetInputMode(FInputModeGameOnly());
PlayerController->bShowMouseCursor = false;
}
TArray<FString> UDialogueNPC::AddDialogue(FText TextInput, TArray<FString> DialogueArrayInput)
{
if (TextInput.IsEmpty()) return DialogueArrayInput;
DialogueArrayInput.Add(TextInput.ToString());
return DialogueArrayInput;
}
void UDialogueNPC::GetFinalDialogue(TArray<FString> DialogueArray)
{
Dialogue = DialogueArray;
}

View File

@ -8,12 +8,12 @@
#include "Components/TextBlock.h"
#include "DialogueNPC.generated.h"
UENUM()
enum class EDialogueType
UENUM(BlueprintType)
enum class EChoices : uint8
{
Text UMETA(DisplayName="Text"),
End UMETA(DisplayName="End"),
Action UMETA(DisplayName="Action"),
Choice1 UMETA(DisplayName="Choice 1"),
Choice2 UMETA(DisplayName="Choice 2"),
Choice3 UMETA(DisplayName="Choice 3"),
};
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
@ -28,10 +28,7 @@ public:
UPROPERTY(EditAnywhere)
FString NPCName;
UPROPERTY(EditAnywhere)
TArray<EDialogueType> DialogueType;
UPROPERTY(EditAnywhere)
UPROPERTY()
TArray<FString> Dialogue;
UPROPERTY(EditAnywhere)
@ -57,7 +54,7 @@ private:
UPROPERTY()
UButton* NextButton;
int DialogueIndex = 0;
int DialogueIndex = 1;
FString CurrentDialogue;
UPROPERTY()
@ -76,4 +73,10 @@ public:
UFUNCTION(BlueprintCallable)
void EndDialogue();
UFUNCTION(BlueprintPure)
TArray<FString> AddDialogue(FText TextInput, TArray<FString> DialogueArrayInput);
UFUNCTION(BlueprintCallable)
void GetFinalDialogue(TArray<FString> DialogueArray);
};