Updated TurnBaseCombat to Reference HUD Blueprint
This commit is contained in:
parent
c085aae130
commit
58db9e7459
BIN
Content/Blueprints/Combat_UI/Combat_Test.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Combat_UI/Combat_Test.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Combat_UI/Combat_UI.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Combat_UI/Combat_UI.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -2,36 +2,51 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "TurnBaseCombat.h"
|
#include "TurnBaseCombat.h"
|
||||||
|
|
||||||
|
#include "Blueprint/UserWidget.h"
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
|
||||||
|
ATurnBaseCombat::ATurnBaseCombat()
|
||||||
|
{
|
||||||
|
if (HUDWidget == nullptr)
|
||||||
|
{
|
||||||
|
// Load the HUD widget from the specified path
|
||||||
|
static ConstructorHelpers::FClassFinder<UUserWidget> HUDWidgetClass(TEXT("/Game/Blueprints/Combat_UI/Combat_UI"));
|
||||||
|
HUDWidget = HUDWidgetClass.Class;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ATurnBaseCombat::BeginPlay()
|
void ATurnBaseCombat::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
TArray<AActor*> AllCharacterActorsInScene;
|
TArray<AActor*> AllCharacterActorsInScene;
|
||||||
UGameplayStatics::GetAllActorsOfClassWithTag(GetWorld(), AActor::StaticClass(), FName("Character"), AllCharacterActorsInScene);
|
UGameplayStatics::GetAllActorsOfClassWithTag(GetWorld(), AActor::StaticClass(), FName("Character"),
|
||||||
activeActionPoints = defaultActionPoints;
|
AllCharacterActorsInScene);
|
||||||
|
ActiveActionPoints = DefaultActionPoints;
|
||||||
|
|
||||||
|
UUserWidget* HUD = CreateWidget<UUserWidget>(GetWorld(), HUDWidget);
|
||||||
|
HUD->AddToViewport();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATurnBaseCombat::useActionPoint()
|
void ATurnBaseCombat::UseActionPoint()
|
||||||
{
|
{
|
||||||
activeActionPoints -= 1;
|
ActiveActionPoints -= 1;
|
||||||
activeActionPoints = FMath::Clamp(activeActionPoints, 0, defaultActionPoints);
|
ActiveActionPoints = FMath::Clamp(ActiveActionPoints, 0, DefaultActionPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATurnBaseCombat::reuseActionPoint()
|
void ATurnBaseCombat::ReuseActionPoint()
|
||||||
{
|
{
|
||||||
activeActionPoints += 1;
|
ActiveActionPoints += 1;
|
||||||
activeActionPoints = FMath::Clamp(activeActionPoints, 0, defaultActionPoints);
|
ActiveActionPoints = FMath::Clamp(ActiveActionPoints, 0, DefaultActionPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATurnBaseCombat::revertActionPoints()
|
void ATurnBaseCombat::RevertActionPoints()
|
||||||
{
|
{
|
||||||
activeActionPoints = defaultActionPoints;
|
ActiveActionPoints = DefaultActionPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATurnBaseCombat::switchTurn()
|
void ATurnBaseCombat::SwitchTurn()
|
||||||
{
|
{
|
||||||
activeActor = (isPlayerTurn) ? enemyActor : playerActor;
|
activeActor = bIsPlayerTurn ? enemyActor : playerActor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user