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()
|
void UDialogueNPC::NextDialogue()
|
||||||
{
|
{
|
||||||
//log bruh
|
|
||||||
UE_LOG(LogTemp, Warning, TEXT("Next Dialogue"));
|
|
||||||
//Dialogue Skip
|
//Dialogue Skip
|
||||||
if (CurrentDialogue.Len() < Dialogue[DialogueIndex].Len())
|
if (CurrentDialogue.Len() < Dialogue[DialogueIndex].Len())
|
||||||
{
|
{
|
||||||
@ -85,7 +83,7 @@ void UDialogueNPC::StartDialogue()
|
|||||||
PlayerController->bShowMouseCursor = true;
|
PlayerController->bShowMouseCursor = true;
|
||||||
|
|
||||||
DialogueWidgetInstance->AddToViewport();
|
DialogueWidgetInstance->AddToViewport();
|
||||||
DialogueIndex = 0;
|
DialogueIndex = 1;
|
||||||
NPCNameText->SetText(FText::FromString(NPCName));
|
NPCNameText->SetText(FText::FromString(NPCName));
|
||||||
CurrentDialogue = "";
|
CurrentDialogue = "";
|
||||||
GetWorld()->GetTimerManager().SetTimer(TextAnimationTimerHandle, this, &UDialogueNPC::NextCharacter, TextAnimationSpeed, true);
|
GetWorld()->GetTimerManager().SetTimer(TextAnimationTimerHandle, this, &UDialogueNPC::NextCharacter, TextAnimationSpeed, true);
|
||||||
@ -106,3 +104,15 @@ void UDialogueNPC::EndDialogue()
|
|||||||
PlayerController->SetInputMode(FInputModeGameOnly());
|
PlayerController->SetInputMode(FInputModeGameOnly());
|
||||||
PlayerController->bShowMouseCursor = false;
|
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 "Components/TextBlock.h"
|
||||||
#include "DialogueNPC.generated.h"
|
#include "DialogueNPC.generated.h"
|
||||||
|
|
||||||
UENUM()
|
UENUM(BlueprintType)
|
||||||
enum class EDialogueType
|
enum class EChoices : uint8
|
||||||
{
|
{
|
||||||
Text UMETA(DisplayName="Text"),
|
Choice1 UMETA(DisplayName="Choice 1"),
|
||||||
End UMETA(DisplayName="End"),
|
Choice2 UMETA(DisplayName="Choice 2"),
|
||||||
Action UMETA(DisplayName="Action"),
|
Choice3 UMETA(DisplayName="Choice 3"),
|
||||||
};
|
};
|
||||||
|
|
||||||
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
||||||
@ -28,10 +28,7 @@ public:
|
|||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
FString NPCName;
|
FString NPCName;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY()
|
||||||
TArray<EDialogueType> DialogueType;
|
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere)
|
|
||||||
TArray<FString> Dialogue;
|
TArray<FString> Dialogue;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
@ -57,7 +54,7 @@ private:
|
|||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
UButton* NextButton;
|
UButton* NextButton;
|
||||||
|
|
||||||
int DialogueIndex = 0;
|
int DialogueIndex = 1;
|
||||||
FString CurrentDialogue;
|
FString CurrentDialogue;
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
@ -76,4 +73,10 @@ public:
|
|||||||
|
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void EndDialogue();
|
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