diff --git a/Content/Blueprints/Combat_UI/TestCombatCharacter.uasset b/Content/Blueprints/Combat_UI/TestCombatCharacter.uasset index 26525f9..e018216 100644 --- a/Content/Blueprints/Combat_UI/TestCombatCharacter.uasset +++ b/Content/Blueprints/Combat_UI/TestCombatCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8d8a15505e76c4565b030eeec3812dec9ddea6dc9317a9fa854f9c28596a76f6 -size 68993 +oid sha256:52c661eb9501db06a66485f2a9fd9a78cd3aa7a7a6d5e7144140d89fbcc74767 +size 92597 diff --git a/Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.cpp b/Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.cpp index c89d182..e7d7bdc 100644 --- a/Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.cpp +++ b/Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.cpp @@ -18,14 +18,9 @@ ATurnBaseCombat::ATurnBaseCombat() } } -void ATurnBaseCombat::BeginPlay() +void ATurnBaseCombat::StartCombat() { - Super::BeginPlay(); - - TArray AllCharacterActorsInScene; - UGameplayStatics::GetAllActorsOfClassWithTag(GetWorld(), AActor::StaticClass(), FName("Character"), AllCharacterActorsInScene); - - UUserWidget* HUD = CreateWidget(GetWorld(), HUDWidget); + if (HUD->IsInViewport()) return; HUD->AddToViewport(); APlayerController* PC = Cast(GetWorld()->GetFirstPlayerController()); @@ -36,6 +31,22 @@ void ATurnBaseCombat::BeginPlay() PC->bEnableClickEvents = true; PC->bEnableMouseOverEvents = true; } +} + +void ATurnBaseCombat::EndCombat() +{ + //Remove the HUD from the viewport + HUD->RemoveFromViewport(); +} + +void ATurnBaseCombat::BeginPlay() +{ + Super::BeginPlay(); + + TArray AllCharacterActorsInScene; + UGameplayStatics::GetAllActorsOfClassWithTag(GetWorld(), AActor::StaticClass(), FName("Character"), AllCharacterActorsInScene); + + HUD = CreateWidget(GetWorld(), HUDWidget); TurnIndicatorTextBlock = Cast(HUD->GetWidgetFromName("TurnIndicator")); CurrentComboTextBlock = Cast(HUD->GetWidgetFromName("CurrentCombo")); diff --git a/Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.h b/Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.h index 004a960..af1c25e 100644 --- a/Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.h +++ b/Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.h @@ -52,6 +52,11 @@ public: FString BattleLog; + UFUNCTION(BlueprintCallable) + void StartCombat(); + UFUNCTION(BlueprintCallable) + void EndCombat(); + protected: virtual void BeginPlay() override; void ExecuteCast(FString Combo); @@ -64,6 +69,7 @@ protected: private: bool IsValidCombo(FString Combo) const; + UUserWidget* HUD; UPROPERTY(VisibleAnywhere) bool bIsPlayerTurn = true;