AzureAbyss/Source/the_twilight_abyss/Dialogue/DialogueNPC.h

147 lines
3.4 KiB
C++

// 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 "Components/Image.h"
#include "../Quest/Quest.h"
#include "DialogueNPC.generated.h"
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class UDialoguePath : public UObject
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite)
TArray<FString> Dialogue;
UPROPERTY(BlueprintReadWrite)
TArray<UDialoguePath*> Choices;
};
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(BlueprintReadWrite)
UDialoguePath* RootDialoguePath;
UPROPERTY()
UDialoguePath* CurrentDialoguePath;
TArray<FString> CurrentDialogueStringPath;
UPROPERTY(EditAnywhere)
UTexture2D* NPCPortrait;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Instanced)
TArray<UBaseItem*> ItemsToGive;
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()
UImage* NPCPortraitImage;
UPROPERTY()
UButton* Choice1Button;
UPROPERTY()
UButton* Choice2Button;
UPROPERTY()
UButton* Choice3Button;
UPROPERTY()
UTextBlock* Choice1Text;
UPROPERTY()
UTextBlock* Choice2Text;
UPROPERTY()
UTextBlock* Choice3Text;
UPROPERTY()
UTextBlock* NextArrow;
UPROPERTY()
UButton* NextButton;
int DialogueIndex = 1;
FString CurrentDialogue;
UPROPERTY()
FTimerHandle TextAnimationTimerHandle;
UFUNCTION()
void NextDialogue();
void NextCharacter();
UPROPERTY()
TMap<int, UQuest*> Quests;
UPROPERTY()
TMap<int, FString> BlueprintFunctions;
UPROPERTY()
TMap<int, int> ItemIndexes;
UPROPERTY()
TMap<int, FString> QuestFlags;
UPROPERTY()
bool bInShop = false;
void ResetDialogueUI();
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
UFUNCTION(BlueprintCallable)
void StartDialogue();
UFUNCTION(BlueprintCallable)
void EndDialogue();
UFUNCTION(BlueprintCallable)
UDialoguePath* CreateRootDialoguePath();
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);
UFUNCTION(BlueprintCallable)
UDialoguePath* AddQuest(UDialoguePath* DialoguePath, UQuest* Quest);
UFUNCTION(BlueprintCallable)
UDialoguePath* CallBlueprintFunction(UDialoguePath* DialoguePath, FString FunctionName);
UFUNCTION(BlueprintCallable)
UDialoguePath* AddItem(UDialoguePath* DialoguePath, int ItemIndex);
UFUNCTION(BlueprintCallable)
UDialoguePath* AddQuestFlag(UDialoguePath* DialoguePath, FString Flag);
UFUNCTION()
void Choice1();
UFUNCTION()
void Choice2();
UFUNCTION()
void Choice3();
};