Updated Combat_UI for Battle Log
This commit is contained in:
parent
b765f633d6
commit
f2857b3c57
BIN
Content/Blueprints/Combat_UI/Combat_UI.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Combat_UI/Combat_UI.uasset
(Stored with Git LFS)
Binary file not shown.
@ -32,14 +32,15 @@ void ATurnBaseCombat::BeginPlay()
|
||||
|
||||
if (PC)
|
||||
{
|
||||
PC->bShowMouseCursor = true;
|
||||
PC->bEnableClickEvents = true;
|
||||
PC->bShowMouseCursor = true;
|
||||
PC->bEnableClickEvents = true;
|
||||
PC->bEnableMouseOverEvents = true;
|
||||
}
|
||||
|
||||
TurnIndicatorTextBlock = Cast<UTextBlock>(HUD->GetWidgetFromName("TurnIndicator"));
|
||||
CurrentComboTextBlock = Cast<UTextBlock>(HUD->GetWidgetFromName("CurrentCombo"));
|
||||
ActionPointsTextBlock = Cast<UTextBlock>(HUD->GetWidgetFromName("ActionPoints"));
|
||||
BattleLogTextBlock = Cast<UTextBlock>(HUD->GetWidgetFromName("BattleLog"));
|
||||
PlayerHealthBar = Cast<UProgressBar>(HUD->GetWidgetFromName("PlayerHealthBar"));
|
||||
EnemyHealthBar = Cast<UProgressBar>(HUD->GetWidgetFromName("EnemyHealthBar"));
|
||||
CastButton = Cast<UButton>(HUD->GetWidgetFromName("CastButton"));
|
||||
@ -107,12 +108,14 @@ void ATurnBaseCombat::DamagePlayer(int Damage)
|
||||
{
|
||||
PlayerHealth -= FMath::Clamp(Damage, 0, 100);
|
||||
UpdateProgressBars();
|
||||
AddBattleLogMessage("Player was damaged for " + FString::FromInt(Damage) + " damage.");
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::DamageEnemy(int Damage)
|
||||
{
|
||||
EnemyHealth -= FMath::Clamp(Damage, 0, 100);
|
||||
UpdateProgressBars();
|
||||
AddBattleLogMessage("Enemy was damaged for " + FString::FromInt(Damage) + " damage.");
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::UpdateProgressBars() const
|
||||
@ -189,8 +192,23 @@ void ATurnBaseCombat::UpdateActionPoints() const
|
||||
|
||||
void ATurnBaseCombat::AddBattleLogMessage(FString Message)
|
||||
{
|
||||
FString* tempTextBlock;
|
||||
BattleLog.Enqueue(Message);
|
||||
tempTextBlock = BattleLog.Peek();
|
||||
|
||||
BattleLog.Append(Message + "\n");
|
||||
UpdateBattleLog();
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::ClearBattleLog()
|
||||
{
|
||||
BattleLog = "";
|
||||
}
|
||||
|
||||
void ATurnBaseCombat::UpdateBattleLog()
|
||||
{
|
||||
TArray<FString> tempArray;
|
||||
//Get the amount of lines in the battle log
|
||||
int32 LineCount = BattleLog.ParseIntoArray(tempArray, TEXT("\n"), true);
|
||||
if (LineCount > 10) //If there are more than 10 lines
|
||||
{
|
||||
ClearBattleLog();
|
||||
}
|
||||
BattleLogTextBlock->SetText(FText::FromString(BattleLog));
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
{"FW", 20}
|
||||
};
|
||||
|
||||
TQueue<FString> BattleLog;
|
||||
FString BattleLog;
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
@ -62,56 +62,61 @@ protected:
|
||||
|
||||
private:
|
||||
bool IsValidCombo(FString Combo) const;
|
||||
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
bool bIsPlayerTurn = true;
|
||||
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
FString CurrentComboString = "";
|
||||
|
||||
|
||||
void SwitchTurn();
|
||||
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UTextBlock* TurnIndicatorTextBlock;
|
||||
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UTextBlock* CurrentComboTextBlock;
|
||||
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UTextBlock* BattleLogTextBlock;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UTextBlock* ActionPointsTextBlock;
|
||||
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UProgressBar* PlayerHealthBar;
|
||||
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UProgressBar* EnemyHealthBar;
|
||||
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UButton* CastButton;
|
||||
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UButton* FButton;
|
||||
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UButton* WButton;
|
||||
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UButton* BackspaceButton;
|
||||
|
||||
|
||||
UFUNCTION()
|
||||
void CastButtonOnClick();
|
||||
|
||||
|
||||
UFUNCTION()
|
||||
void FButtonOnClick();
|
||||
|
||||
|
||||
UFUNCTION()
|
||||
void WButtonOnClick();
|
||||
|
||||
|
||||
UFUNCTION()
|
||||
void BackspaceButtonOnClick();
|
||||
|
||||
|
||||
void UpdateComboString(FString NewCombo) const;
|
||||
void UpdateActionPoints() const;
|
||||
|
||||
void AddBattleLogMessage(FString Message);
|
||||
};
|
||||
void ClearBattleLog();
|
||||
void UpdateBattleLog();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user