2023-05-02 10:23:35 +00:00
|
|
|
|
// Fill out your copyright notice in the Description page of Project Settings.
|
2023-02-02 01:59:33 +00:00
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
#include "Components/ActorComponent.h"
|
|
|
|
|
#include "Components/Button.h"
|
|
|
|
|
#include "Components/TextBlock.h"
|
2023-03-13 04:49:09 +00:00
|
|
|
|
#include "Components/Image.h"
|
2023-05-02 06:16:40 +00:00
|
|
|
|
#include "../Quest/Quest.h"
|
2023-02-02 01:59:33 +00:00
|
|
|
|
#include "DialogueNPC.generated.h"
|
|
|
|
|
|
2023-03-13 04:49:09 +00:00
|
|
|
|
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
|
|
|
|
class UDialoguePath : public UObject
|
2023-02-09 03:12:27 +00:00
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
2023-03-13 04:49:09 +00:00
|
|
|
|
public:
|
|
|
|
|
UPROPERTY(BlueprintReadWrite)
|
2023-02-09 03:12:27 +00:00
|
|
|
|
TArray<FString> Dialogue;
|
|
|
|
|
|
2023-03-13 04:49:09 +00:00
|
|
|
|
UPROPERTY(BlueprintReadWrite)
|
|
|
|
|
TArray<UDialoguePath*> Choices;
|
2023-02-09 03:12:27 +00:00
|
|
|
|
};
|
|
|
|
|
|
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-03-13 04:49:09 +00:00
|
|
|
|
|
2023-05-04 05:31:59 +00:00
|
|
|
|
UPROPERTY(BlueprintReadWrite)
|
2023-03-13 04:49:09 +00:00
|
|
|
|
UDialoguePath* RootDialoguePath;
|
2023-02-06 03:28:53 +00:00
|
|
|
|
UPROPERTY()
|
2023-03-13 04:49:09 +00:00
|
|
|
|
UDialoguePath* CurrentDialoguePath;
|
|
|
|
|
TArray<FString> CurrentDialogueStringPath;
|
2023-02-09 03:12:27 +00:00
|
|
|
|
|
2023-03-13 04:49:09 +00:00
|
|
|
|
UPROPERTY(EditAnywhere)
|
|
|
|
|
UTexture2D* NPCPortrait;
|
2023-02-02 01:59:33 +00:00
|
|
|
|
|
2023-05-11 07:52:30 +00:00
|
|
|
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Instanced)
|
|
|
|
|
TArray<UBaseItem*> ItemsToGive;
|
|
|
|
|
|
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;
|
2023-03-13 04:49:09 +00:00
|
|
|
|
|
2023-02-02 01:59:33 +00:00
|
|
|
|
UPROPERTY()
|
|
|
|
|
UTextBlock* NPCNameText;
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
UTextBlock* DialogueText;
|
2023-03-13 04:49:09 +00:00
|
|
|
|
UPROPERTY()
|
|
|
|
|
UImage* NPCPortraitImage;
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
UButton* Choice1Button;
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
UButton* Choice2Button;
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
UButton* Choice3Button;
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
UTextBlock* Choice1Text;
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
UTextBlock* Choice2Text;
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
UTextBlock* Choice3Text;
|
2023-05-01 04:23:43 +00:00
|
|
|
|
UPROPERTY()
|
|
|
|
|
UTextBlock* NextArrow;
|
2023-03-13 04:49:09 +00:00
|
|
|
|
|
2023-02-02 01:59:33 +00:00
|
|
|
|
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();
|
|
|
|
|
|
2023-05-02 06:16:40 +00:00
|
|
|
|
UPROPERTY()
|
|
|
|
|
TMap<int, UQuest*> Quests;
|
2023-05-11 05:32:11 +00:00
|
|
|
|
UPROPERTY()
|
|
|
|
|
TMap<int, FString> BlueprintFunctions;
|
2023-05-11 07:52:30 +00:00
|
|
|
|
UPROPERTY()
|
|
|
|
|
TMap<int, int> ItemIndexes;
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
TMap<int, FString> QuestFlags;
|
|
|
|
|
|
|
|
|
|
UPROPERTY()
|
|
|
|
|
bool bInShop = false;
|
2023-05-02 06:16:40 +00:00
|
|
|
|
|
2023-05-04 00:42:54 +00:00
|
|
|
|
void ResetDialogueUI();
|
|
|
|
|
|
2023-02-02 01:59:33 +00:00
|
|
|
|
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
|
|
|
|
|
2023-03-13 04:49:09 +00:00
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
|
|
|
UDialoguePath* CreateRootDialoguePath();
|
2023-02-09 17:01:03 +00:00
|
|
|
|
|
2023-03-13 04:49:09 +00:00
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
|
|
|
UDialoguePath* AddDialogue(UDialoguePath* DialoguePath, FText TextInput);
|
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
|
|
|
void AddChoices(UDialoguePath* ParentPath, FText ChoiceText1, FText ChoiceText2, FText ChoiceText3,
|
|
|
|
|
UDialoguePath*& ChoicePath1, UDialoguePath*& ChoicePath2, UDialoguePath*& ChoicePath3);
|
2023-02-09 17:01:03 +00:00
|
|
|
|
|
2023-05-02 06:16:40 +00:00
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
|
|
|
UDialoguePath* AddQuest(UDialoguePath* DialoguePath, UQuest* Quest);
|
2023-05-11 05:32:11 +00:00
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
|
|
|
UDialoguePath* CallBlueprintFunction(UDialoguePath* DialoguePath, FString FunctionName);
|
2023-05-11 07:52:30 +00:00
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
|
|
|
UDialoguePath* AddItem(UDialoguePath* DialoguePath, int ItemIndex);
|
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
|
|
|
UDialoguePath* AddQuestFlag(UDialoguePath* DialoguePath, FString Flag);
|
2023-05-02 06:16:40 +00:00
|
|
|
|
|
2023-02-09 17:01:03 +00:00
|
|
|
|
UFUNCTION()
|
2023-03-13 04:49:09 +00:00
|
|
|
|
void Choice1();
|
|
|
|
|
UFUNCTION()
|
|
|
|
|
void Choice2();
|
|
|
|
|
UFUNCTION()
|
|
|
|
|
void Choice3();
|
2023-02-02 01:59:33 +00:00
|
|
|
|
};
|