Updated Combat UI for User Experience Improvements

Hide buttons until they are available to use and disable resource buttons if there isn't any resources left
This commit is contained in:
Philip W 2023-05-09 02:55:31 +01:00
parent cfde5f9d68
commit aa78522127
2 changed files with 31 additions and 41 deletions

View File

@ -48,7 +48,7 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, bool bWasShot)
bIsInCombat = true;
UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(Enemy->GetInstigatorController())->GetBlackboardComponent();
Cast<UQuestSystem>(PlayerActor->GetComponentByClass(UQuestSystem::StaticClass()))->QuestWidgetInstance->SetVisibility(ESlateVisibility::Hidden);
//Disable Character Movement
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
PlayerController->SetIgnoreMoveInput(true);
@ -419,7 +419,7 @@ void ATurnBaseCombatV2::SwitchTurn()
//TurnIndicatorTextBlock->SetText(FText::FromString(bIsPlayerTurn ? "Enemy Turn" : "Player Turn"));
//bIsPlayerTurn = !bIsPlayerTurn;
TurnIndicatorTextBlock->SetText(FText::FromString("Enemy Turn"));
ToggleButtons();
DisableButtons();
FTimerHandle UnusedHandle;
GetWorldTimerManager().SetTimer(UnusedHandle, this, &ATurnBaseCombatV2::EnemyTurn, 2.0f, false);
@ -539,26 +539,6 @@ void ATurnBaseCombatV2::BackspaceButtonOnClick()
RevertActionPoints();
UpdateActionPoints();
UpdateResourceBars();
// ReuseActionPoint();
// if (CurrentComboString.Right(1) == "P")
// {
// ProbertiumResource += 1;
// }
// else if (CurrentComboString.Right(1) == "E")
// {
// EisResource += 1;
// }
// else if (CurrentComboString.Right(1) == "A")
// {
// AzosResource += 1;
// }
// else if (CurrentComboString.Right(1) == "I")
// {
// IroquoidResource += 1;
// }
// CurrentComboString.RemoveAt(CurrentComboString.Len() - 1);
// UpdateComboString(CurrentComboString);
// UpdateResourceBars();
}
void ATurnBaseCombatV2::RunButtonOnClick()
@ -584,7 +564,18 @@ void ATurnBaseCombatV2::UpdateComboString(FString NewCombo) const
CurrentComboTextBlock1->SetText(FText::FromString("?"));
CurrentComboTextBlock2->SetText(FText::FromString("?"));
if (IsValidCombo(NewCombo)) CurrentComboTextBlock->SetText(FText::FromString(NewCombo));
if (NewCombo.Len() > 0) BackspaceButton->SetVisibility(ESlateVisibility::Visible);
else BackspaceButton->SetVisibility(ESlateVisibility::Hidden);
if (IsValidCombo(NewCombo))
{
CurrentComboTextBlock->SetText(FText::FromString(NewCombo));
CastButton->SetVisibility(ESlateVisibility::Visible);
}
else
{
CastButton->SetVisibility(ESlateVisibility::Hidden);
}
if (NewCombo.Len() == 1)
{
CurrentComboTextBlock1->SetText(FText::FromString(NewCombo));
@ -628,17 +619,7 @@ void ATurnBaseCombatV2::UpdateResourceBars() const
EisResourceBar->SetPercent(EisResource / 10.0f);
AzosResourceBar->SetPercent(AzosResource / 10.0f);
IroquoidResourceBar->SetPercent(IroquoidResource / 10.0f);
}
void ATurnBaseCombatV2::ToggleButtons() const
{
PButton->SetIsEnabled(!PButton->GetIsEnabled());
EButton->SetIsEnabled(!EButton->GetIsEnabled());
AButton->SetIsEnabled(!AButton->GetIsEnabled());
IButton->SetIsEnabled(!IButton->GetIsEnabled());
BackspaceButton->SetIsEnabled(!BackspaceButton->GetIsEnabled());
CastButton->SetIsEnabled(!CastButton->GetIsEnabled());
RunButton->SetIsEnabled(!RunButton->GetIsEnabled());
ToggleButtonIfResourceAvailable();
}
void ATurnBaseCombatV2::DisableButtons() const
@ -654,10 +635,7 @@ void ATurnBaseCombatV2::DisableButtons() const
void ATurnBaseCombatV2::EnableButtons() const
{
PButton->SetIsEnabled(true);
EButton->SetIsEnabled(true);
AButton->SetIsEnabled(true);
IButton->SetIsEnabled(true);
ToggleButtonIfResourceAvailable();
BackspaceButton->SetIsEnabled(true);
CastButton->SetIsEnabled(true);
RunButton->SetIsEnabled(true);
@ -668,5 +646,17 @@ void ATurnBaseCombatV2::EnemyTurn()
DamagePlayer(10);
OnEnemyTurn.Broadcast(EnemyActor, PlayerActor);
TurnIndicatorTextBlock->SetText(FText::FromString("Player Turn"));
ToggleButtons();
EnableButtons();
}
void ATurnBaseCombatV2::ToggleButtonIfResourceAvailable() const
{
if (ProbertiumResource >= 1) PButton->SetIsEnabled(true);
else PButton->SetIsEnabled(false);
if (EisResource >= 1) EButton->SetIsEnabled(true);
else EButton->SetIsEnabled(false);
if (AzosResource >= 1) AButton->SetIsEnabled(true);
else AButton->SetIsEnabled(false);
if (IroquoidResource >= 1) IButton->SetIsEnabled(true);
else IButton->SetIsEnabled(false);
}

View File

@ -224,12 +224,12 @@ private:
void UpdateBattleLog();
void UpdateResourceBars() const;
UFUNCTION(BlueprintCallable)
void ToggleButtons() const;
UFUNCTION(BlueprintCallable)
void DisableButtons() const;
UFUNCTION(BlueprintCallable)
void EnableButtons() const;
void EnemyTurn();
UFUNCTION(BlueprintCallable)
void ToggleButtonIfResourceAvailable() const;
UPROPERTY()
UUserWidget* DeathScreenWidget;