2023-02-02 01:59:33 +00:00
|
|
|
|
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
#include "Components/ActorComponent.h"
|
|
|
|
|
#include "Components/Button.h"
|
|
|
|
|
#include "Components/TextBlock.h"
|
|
|
|
|
#include "DialogueNPC.generated.h"
|
|
|
|
|
|
2023-02-06 03:28:53 +00:00
|
|
|
|
UENUM(BlueprintType)
|
|
|
|
|
enum class EChoices : uint8
|
2023-02-02 01:59:33 +00:00
|
|
|
|
{
|
2023-02-06 03:28:53 +00:00
|
|
|
|
Choice1 UMETA(DisplayName="Choice 1"),
|
|
|
|
|
Choice2 UMETA(DisplayName="Choice 2"),
|
|
|
|
|
Choice3 UMETA(DisplayName="Choice 3"),
|
2023-02-02 01:59:33 +00:00
|
|
|
|
};
|
|
|
|
|
|
2023-02-09 03:12:27 +00:00
|
|
|
|
USTRUCT(BlueprintType)
|
|
|
|
|
struct FDialoguePath
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
TArray<FString> Dialogue;
|
|
|
|
|
|
2023-02-09 17:01:03 +00:00
|
|
|
|
FDialoguePath()
|
|
|
|
|
{
|
|
|
|
|
Dialogue.Add("#ROOT");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FDialoguePath(FString Id)
|
|
|
|
|
{
|
|
|
|
|
Dialogue.Add(Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
explicit FDialoguePath(TArray<FString> Dialogue)
|
2023-02-09 03:12:27 +00:00
|
|
|
|
{
|
|
|
|
|
this->Dialogue = Dialogue;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2023-02-02 01:59:33 +00:00
|
|
|
|
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
|
|
|
|
class THE_TWILIGHT_ABYSS_API UDialogueNPC : public UActorComponent
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// Sets default values for this component's properties
|
|
|
|
|
UDialogueNPC();
|
|
|
|
|
|
|
|
|
|
UPROPERTY(EditAnywhere)
|
|
|
|
|
FString NPCName;
|
|
|
|
|
|
2023-02-06 03:28:53 +00:00
|
|
|
|
UPROPERTY()
|
2023-02-09 03:12:27 +00:00
|
|
|
|
TArray<FDialoguePath> DialoguePaths;
|
|
|
|
|
|
|
|
|
|
TArray<FString> CurrentDialoguePath;
|
2023-02-02 01:59:33 +00:00
|
|
|
|
|
2023-02-06 01:13:17 +00:00
|
|
|
|
UPROPERTY(EditAnywhere)
|
|
|
|
|
float TextAnimationSpeed = 0.05f;
|
|
|
|
|
|
2023-02-02 01:59:33 +00:00
|
|
|
|
protected:
|
|
|
|
|
// Called when the game starts
|
|
|
|
|
virtual void BeginPlay() override;
|
|
|
|
|
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
TSubclassOf<UUserWidget> DialogueWidget;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
UUserWidget* DialogueWidgetInstance;
|
|
|
|
|
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
UTextBlock* NPCNameText;
|
|
|
|
|
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
UTextBlock* DialogueText;
|
|
|
|
|
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
UButton* NextButton;
|
|
|
|
|
|
2023-02-06 03:28:53 +00:00
|
|
|
|
int DialogueIndex = 1;
|
2023-02-02 01:59:33 +00:00
|
|
|
|
FString CurrentDialogue;
|
|
|
|
|
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
FTimerHandle TextAnimationTimerHandle;
|
|
|
|
|
|
|
|
|
|
UFUNCTION()
|
|
|
|
|
void NextDialogue();
|
|
|
|
|
void NextCharacter();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// Called every frame
|
|
|
|
|
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
|
|
|
|
|
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
|
|
|
void StartDialogue();
|
|
|
|
|
|
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
|
|
|
void EndDialogue();
|
2023-02-06 03:28:53 +00:00
|
|
|
|
|
|
|
|
|
UFUNCTION(BlueprintPure)
|
2023-02-09 17:01:03 +00:00
|
|
|
|
FDialoguePath CreateRootDialoguePath();
|
|
|
|
|
|
|
|
|
|
UFUNCTION()
|
|
|
|
|
FDialoguePath CreateDialoguePath(FDialoguePath ParentDialoguePath);
|
|
|
|
|
|
|
|
|
|
UFUNCTION(BlueprintPure)
|
2023-02-20 09:50:09 +00:00
|
|
|
|
FDialoguePath CreateDialogueChoice(FDialoguePath PreviousDialoguePath);
|
2023-02-09 17:01:03 +00:00
|
|
|
|
|
|
|
|
|
UFUNCTION()
|
|
|
|
|
bool GotoDialoguePath(FString PathId);
|
|
|
|
|
|
|
|
|
|
UFUNCTION(BlueprintPure)
|
|
|
|
|
FDialoguePath AddDialogue(FText TextInput, FDialoguePath DialoguePath);
|
2023-02-06 03:28:53 +00:00
|
|
|
|
|
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
|
|
|
void GetFinalDialogue(TArray<FString> DialogueArray);
|
2023-02-02 01:59:33 +00:00
|
|
|
|
};
|