Updated DialogueNPC to Add Dialogue via Blueprints
This commit is contained in:
parent
e5b624411d
commit
7f3e3cbb52
BIN
Content/Dialogue/NPCTest.uasset
(Stored with Git LFS)
BIN
Content/Dialogue/NPCTest.uasset
(Stored with Git LFS)
Binary file not shown.
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user