// 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 Dialogue; UPROPERTY(BlueprintReadWrite) TArray 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 CurrentDialogueStringPath; UPROPERTY(EditAnywhere) UTexture2D* NPCPortrait; UPROPERTY(EditAnywhere) float TextAnimationSpeed = 0.05f; protected: // Called when the game starts virtual void BeginPlay() override; UPROPERTY() TSubclassOf 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 Quests; 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() void Choice1(); UFUNCTION() void Choice2(); UFUNCTION() void Choice3(); };