Updated DialogueNPC for Structs and Dialogue Paths
This commit is contained in:
parent
a16de31aa2
commit
d1fab9f9a1
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,5 +115,5 @@ TArray<FString> UDialogueNPC::AddDialogue(FText TextInput, TArray<FString> Dialo
|
|||||||
|
|
||||||
void UDialogueNPC::GetFinalDialogue(TArray<FString> DialogueArray)
|
void UDialogueNPC::GetFinalDialogue(TArray<FString> DialogueArray)
|
||||||
{
|
{
|
||||||
Dialogue = DialogueArray;
|
DialoguePaths.Add(FDialoguePath(DialogueArray));
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,20 @@ enum class EChoices : uint8
|
|||||||
Choice3 UMETA(DisplayName="Choice 3"),
|
Choice3 UMETA(DisplayName="Choice 3"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
USTRUCT(BlueprintType)
|
||||||
|
struct FDialoguePath
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
TArray<FString> Dialogue;
|
||||||
|
|
||||||
|
explicit FDialoguePath(const 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 +43,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;
|
||||||
|
Loading…
Reference in New Issue
Block a user