AzureAbyss/Source/the_twilight_abyss/Dialogue/DialogueNPC.h

80 lines
1.6 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()
enum class EDialogueType
{
Text UMETA(DisplayName="Text"),
End UMETA(DisplayName="End"),
Action UMETA(DisplayName="Action"),
};
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(EditAnywhere)
TArray<EDialogueType> DialogueType;
UPROPERTY(EditAnywhere)
TArray<FString> Dialogue;
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 = 0;
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();
};