Updated Dialogue for Optimisations and Abstraction

This commit is contained in:
Philip W 2023-05-04 01:42:54 +01:00
parent d237e6c8de
commit 9bb98b314b
3 changed files with 19 additions and 27 deletions

Binary file not shown.

View File

@ -6,7 +6,6 @@
#include "Components/TextBlock.h"
#include "GameFramework/Character.h"
#include "Kismet/KismetStringLibrary.h"
#include "the_twilight_abyss/PlayerTemp/TempCharacter.h"
#include "the_twilight_abyss/Quest/QuestSystem.h"
// Sets default values for this component's properties
@ -94,6 +93,18 @@ void UDialogueNPC::NextCharacter()
}
}
void UDialogueNPC::ResetDialogueUI()
{
DialogueIndex = 0;
CurrentDialogue = "";
CurrentDialogueStringPath = CurrentDialoguePath->Dialogue;
GetWorld()->GetTimerManager().UnPauseTimer(TextAnimationTimerHandle);
Choice1Button->SetVisibility(ESlateVisibility::Hidden);
Choice2Button->SetVisibility(ESlateVisibility::Hidden);
Choice3Button->SetVisibility(ESlateVisibility::Hidden);
NextArrow->SetVisibility(ESlateVisibility::Visible);
}
// Called every frame
void UDialogueNPC::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
@ -185,38 +196,17 @@ UDialoguePath* UDialogueNPC::AddQuest(UDialoguePath* DialoguePath, UQuest* Quest
void UDialogueNPC::Choice1()
{
CurrentDialoguePath = CurrentDialoguePath->Choices[0];
DialogueIndex = 0;
CurrentDialogue = "";
CurrentDialogueStringPath = CurrentDialoguePath->Dialogue;
GetWorld()->GetTimerManager().UnPauseTimer(TextAnimationTimerHandle);
Choice1Button->SetVisibility(ESlateVisibility::Hidden);
Choice2Button->SetVisibility(ESlateVisibility::Hidden);
Choice3Button->SetVisibility(ESlateVisibility::Hidden);
NextArrow->SetVisibility(ESlateVisibility::Visible);
ResetDialogueUI();
}
void UDialogueNPC::Choice2()
{
CurrentDialoguePath = CurrentDialoguePath->Choices[1];
DialogueIndex = 0;
CurrentDialogue = "";
CurrentDialogueStringPath = CurrentDialoguePath->Dialogue;
GetWorld()->GetTimerManager().UnPauseTimer(TextAnimationTimerHandle);
Choice1Button->SetVisibility(ESlateVisibility::Hidden);
Choice2Button->SetVisibility(ESlateVisibility::Hidden);
Choice3Button->SetVisibility(ESlateVisibility::Hidden);
NextArrow->SetVisibility(ESlateVisibility::Visible);
ResetDialogueUI();
}
void UDialogueNPC::Choice3()
{
CurrentDialoguePath = CurrentDialoguePath->Choices[2];
DialogueIndex = 0;
CurrentDialogue = "";
CurrentDialogueStringPath = CurrentDialoguePath->Dialogue;
GetWorld()->GetTimerManager().UnPauseTimer(TextAnimationTimerHandle);
Choice1Button->SetVisibility(ESlateVisibility::Hidden);
Choice2Button->SetVisibility(ESlateVisibility::Hidden);
Choice3Button->SetVisibility(ESlateVisibility::Hidden);
NextArrow->SetVisibility(ESlateVisibility::Visible);
ResetDialogueUI();
}

View File

@ -95,6 +95,8 @@ private:
UPROPERTY()
TMap<int, UQuest*> Quests;
void ResetDialogueUI();
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;