Merge branch 'Dialogue-System' into dev
This commit is contained in:
commit
a6ef9f76cd
BIN
Content/Dialogue/DialogueTest.umap
(Stored with Git LFS)
BIN
Content/Dialogue/DialogueTest.umap
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Dialogue/NPCTest.uasset
(Stored with Git LFS)
BIN
Content/Dialogue/NPCTest.uasset
(Stored with Git LFS)
Binary file not shown.
@ -35,15 +35,15 @@ void UDialogueNPC::BeginPlay()
|
|||||||
void UDialogueNPC::NextDialogue()
|
void UDialogueNPC::NextDialogue()
|
||||||
{
|
{
|
||||||
//Dialogue Skip
|
//Dialogue Skip
|
||||||
if (CurrentDialogue.Len() < Dialogue[DialogueIndex].Len())
|
if (CurrentDialogue.Len() < CurrentDialoguePath[DialogueIndex].Len())
|
||||||
{
|
{
|
||||||
CurrentDialogue = Dialogue[DialogueIndex];
|
CurrentDialogue = CurrentDialoguePath[DialogueIndex];
|
||||||
DialogueText->SetText(FText::FromString(CurrentDialogue));
|
DialogueText->SetText(FText::FromString(CurrentDialogue));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogueIndex++;
|
DialogueIndex++;
|
||||||
if (DialogueIndex >= Dialogue.Num())
|
if (DialogueIndex >= CurrentDialoguePath.Num())
|
||||||
{
|
{
|
||||||
EndDialogue();
|
EndDialogue();
|
||||||
return;
|
return;
|
||||||
@ -53,11 +53,11 @@ void UDialogueNPC::NextDialogue()
|
|||||||
|
|
||||||
void UDialogueNPC::NextCharacter()
|
void UDialogueNPC::NextCharacter()
|
||||||
{
|
{
|
||||||
if (DialogueIndex >= Dialogue.Num()) return;
|
if (DialogueIndex >= CurrentDialoguePath.Num()) return;
|
||||||
|
|
||||||
if (CurrentDialogue.Len() < Dialogue[DialogueIndex].Len())
|
if (CurrentDialogue.Len() < CurrentDialoguePath[DialogueIndex].Len())
|
||||||
{
|
{
|
||||||
CurrentDialogue.AppendChar(Dialogue[DialogueIndex][CurrentDialogue.Len()]);
|
CurrentDialogue.AppendChar(CurrentDialoguePath[DialogueIndex][CurrentDialogue.Len()]);
|
||||||
DialogueText->SetText(FText::FromString(CurrentDialogue));
|
DialogueText->SetText(FText::FromString(CurrentDialogue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,6 +86,7 @@ void UDialogueNPC::StartDialogue()
|
|||||||
DialogueIndex = 1;
|
DialogueIndex = 1;
|
||||||
NPCNameText->SetText(FText::FromString(NPCName));
|
NPCNameText->SetText(FText::FromString(NPCName));
|
||||||
CurrentDialogue = "";
|
CurrentDialogue = "";
|
||||||
|
CurrentDialoguePath = DialoguePaths[0].Dialogue;
|
||||||
GetWorld()->GetTimerManager().SetTimer(TextAnimationTimerHandle, this, &UDialogueNPC::NextCharacter, TextAnimationSpeed, true);
|
GetWorld()->GetTimerManager().SetTimer(TextAnimationTimerHandle, this, &UDialogueNPC::NextCharacter, TextAnimationSpeed, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,14 +106,42 @@ void UDialogueNPC::EndDialogue()
|
|||||||
PlayerController->bShowMouseCursor = false;
|
PlayerController->bShowMouseCursor = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TArray<FString> UDialogueNPC::AddDialogue(FText TextInput, TArray<FString> DialogueArrayInput)
|
FDialoguePath UDialogueNPC::CreateRootDialoguePath()
|
||||||
{
|
{
|
||||||
if (TextInput.IsEmpty()) return DialogueArrayInput;
|
return FDialoguePath();
|
||||||
DialogueArrayInput.Add(TextInput.ToString());
|
}
|
||||||
return DialogueArrayInput;
|
|
||||||
|
FDialoguePath UDialogueNPC::CreateDialoguePath(FDialoguePath ParentDialoguePath)
|
||||||
|
{
|
||||||
|
return FDialoguePath("#" + FString::FromInt(DialoguePaths.Num()));
|
||||||
|
}
|
||||||
|
|
||||||
|
FDialoguePath UDialogueNPC::CreateDialogueChoice(FDialoguePath PreviousDialoguePath)
|
||||||
|
{
|
||||||
|
return FDialoguePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UDialogueNPC::GotoDialoguePath(FString PathId)
|
||||||
|
{
|
||||||
|
for (FDialoguePath DialogPath : DialoguePaths)
|
||||||
|
{
|
||||||
|
if (DialogPath.Dialogue[0] == PathId)
|
||||||
|
{
|
||||||
|
CurrentDialoguePath = DialogPath.Dialogue;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
FDialoguePath UDialogueNPC::AddDialogue(FText TextInput, FDialoguePath DialoguePath)
|
||||||
|
{
|
||||||
|
if (TextInput.IsEmpty()) return DialoguePath;
|
||||||
|
DialoguePath.Dialogue.Add(TextInput.ToString());
|
||||||
|
return DialoguePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDialogueNPC::GetFinalDialogue(TArray<FString> DialogueArray)
|
void UDialogueNPC::GetFinalDialogue(TArray<FString> DialogueArray)
|
||||||
{
|
{
|
||||||
Dialogue = DialogueArray;
|
DialoguePaths.Add(FDialoguePath(DialogueArray));
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,30 @@ enum class EChoices : uint8
|
|||||||
Choice3 UMETA(DisplayName="Choice 3"),
|
Choice3 UMETA(DisplayName="Choice 3"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
USTRUCT(BlueprintType)
|
||||||
|
struct FDialoguePath
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
TArray<FString> Dialogue;
|
||||||
|
|
||||||
|
FDialoguePath()
|
||||||
|
{
|
||||||
|
Dialogue.Add("#ROOT");
|
||||||
|
}
|
||||||
|
|
||||||
|
FDialoguePath(FString Id)
|
||||||
|
{
|
||||||
|
Dialogue.Add(Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit FDialoguePath(TArray<FString> Dialogue)
|
||||||
|
{
|
||||||
|
this->Dialogue = Dialogue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
||||||
class THE_TWILIGHT_ABYSS_API UDialogueNPC : public UActorComponent
|
class THE_TWILIGHT_ABYSS_API UDialogueNPC : public UActorComponent
|
||||||
{
|
{
|
||||||
@ -29,7 +53,9 @@ public:
|
|||||||
FString NPCName;
|
FString NPCName;
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
TArray<FString> Dialogue;
|
TArray<FDialoguePath> DialoguePaths;
|
||||||
|
|
||||||
|
TArray<FString> CurrentDialoguePath;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
float TextAnimationSpeed = 0.05f;
|
float TextAnimationSpeed = 0.05f;
|
||||||
@ -75,7 +101,19 @@ public:
|
|||||||
void EndDialogue();
|
void EndDialogue();
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure)
|
UFUNCTION(BlueprintPure)
|
||||||
TArray<FString> AddDialogue(FText TextInput, TArray<FString> DialogueArrayInput);
|
FDialoguePath CreateRootDialoguePath();
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
FDialoguePath CreateDialoguePath(FDialoguePath ParentDialoguePath);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintPure)
|
||||||
|
FDialoguePath CreateDialogueChoice(FDialoguePath PreviousDialoguePath);
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
bool GotoDialoguePath(FString PathId);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintPure)
|
||||||
|
FDialoguePath AddDialogue(FText TextInput, FDialoguePath DialoguePath);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void GetFinalDialogue(TArray<FString> DialogueArray);
|
void GetFinalDialogue(TArray<FString> DialogueArray);
|
||||||
|
Loading…
Reference in New Issue
Block a user