AzureAbyss/Source/the_twilight_abyss/Dialogue/DialogueNPC.h

99 lines
2.0 KiB
C
Raw Normal View History

// 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"
UENUM(BlueprintType)
enum class EChoices : uint8
{
Choice1 UMETA(DisplayName="Choice 1"),
Choice2 UMETA(DisplayName="Choice 2"),
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))
class THE_TWILIGHT_ABYSS_API UDialogueNPC : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UDialogueNPC();
UPROPERTY(EditAnywhere)
FString NPCName;
UPROPERTY()
TArray<FDialoguePath> DialoguePaths;
TArray<FString> CurrentDialoguePath;
UPROPERTY(EditAnywhere)
float TextAnimationSpeed = 0.05f;
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;
int DialogueIndex = 1;
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();
UFUNCTION(BlueprintPure)
TArray<FString> AddDialogue(FText TextInput, TArray<FString> DialogueArrayInput);
UFUNCTION(BlueprintCallable)
void GetFinalDialogue(TArray<FString> DialogueArray);
};