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"
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
};
|