AzureAbyss/Source/the_twilight_abyss/TurnBasedCombat/TurnBaseCombat.h

144 lines
2.8 KiB
C
Raw Normal View History

2022-11-09 20:32:31 +00:00
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/Button.h"
#include "Components/ProgressBar.h"
#include "Components/TextBlock.h"
2022-11-09 20:32:31 +00:00
#include "GameFramework/GameStateBase.h"
#include "TurnBaseCombat.generated.h"
/**
*
*/
UCLASS()
class THE_TWILIGHT_ABYSS_API ATurnBaseCombat : public AGameStateBase
{
GENERATED_BODY()
public:
ATurnBaseCombat();
2022-11-09 20:32:31 +00:00
UPROPERTY(EditDefaultsOnly)
int PlayerHealth = 100;
2022-11-09 20:32:31 +00:00
UPROPERTY(EditDefaultsOnly)
int EnemyHealth = 100;
2022-11-09 20:32:31 +00:00
UPROPERTY(EditDefaultsOnly)
int DefaultActionPoints = 3;
UPROPERTY(EditDefaultsOnly)
int ActiveActionPoints = 0;
UPROPERTY(EditDefaultsOnly)
int IronResource = 10; // F
UPROPERTY(EditDefaultsOnly)
int SulfurResource = 10; // W
2022-11-09 20:32:31 +00:00
// AActor* PlayerActor;
UPROPERTY(VisibleAnywhere)
AActor* EnemyActor;
// AActor* ActiveActor;
2022-11-09 20:32:31 +00:00
/*
TODO:
Reference Player Inventory
2022-11-09 20:32:31 +00:00
*/
UPROPERTY(EditAnywhere)
TSubclassOf<UUserWidget> HUDWidget;
UPROPERTY(EditAnywhere)
TMap<FString, int32> ValidCombos =
{
{"F", 10},
{"W", 10},
2022-11-14 22:40:22 +00:00
{"WW", 15},
{"FW", 20},
{"FFW", 30}
};
2022-11-09 20:32:31 +00:00
2022-11-14 22:30:31 +00:00
FString BattleLog;
2022-11-14 11:31:51 +00:00
UFUNCTION(BlueprintCallable)
void StartCombat(AActor* Enemy);
UFUNCTION(BlueprintCallable)
void EndCombat();
2022-11-09 20:32:31 +00:00
protected:
virtual void BeginPlay() override;
void ExecuteCast(FString Combo);
void UseActionPoint();
void ReuseActionPoint();
void RevertActionPoints();
void DamagePlayer(int Damage);
void DamageEnemy(int Damage);
void UpdateProgressBars() const;
2022-11-09 20:32:31 +00:00
private:
bool IsValidCombo(FString Combo) const;
UUserWidget* HUD;
2022-11-14 22:30:31 +00:00
UPROPERTY(VisibleAnywhere)
bool bIsPlayerTurn = true;
2022-11-14 22:30:31 +00:00
UPROPERTY(VisibleAnywhere)
FString CurrentComboString = "";
2022-11-14 22:30:31 +00:00
void SwitchTurn();
2022-11-14 22:30:31 +00:00
UPROPERTY(VisibleAnywhere)
UTextBlock* TurnIndicatorTextBlock;
2022-11-14 22:30:31 +00:00
UPROPERTY(VisibleAnywhere)
UTextBlock* CurrentComboTextBlock;
2022-11-14 22:30:31 +00:00
UPROPERTY(VisibleAnywhere)
UTextBlock* BattleLogTextBlock;
UPROPERTY(VisibleAnywhere)
UTextBlock* ActionPointsTextBlock;
2022-11-14 22:30:31 +00:00
UPROPERTY(VisibleAnywhere)
UProgressBar* PlayerHealthBar;
2022-11-14 22:30:31 +00:00
UPROPERTY(VisibleAnywhere)
UProgressBar* EnemyHealthBar;
2022-11-14 22:30:31 +00:00
UPROPERTY(VisibleAnywhere)
UProgressBar* IronResourceBar;
UPROPERTY(VisibleAnywhere)
UProgressBar* SulfurResourceBar;
UPROPERTY(VisibleAnywhere)
UButton* CastButton;
2022-11-14 22:30:31 +00:00
UPROPERTY(VisibleAnywhere)
UButton* FButton;
2022-11-14 22:30:31 +00:00
UPROPERTY(VisibleAnywhere)
UButton* WButton;
2022-11-14 22:30:31 +00:00
UPROPERTY(VisibleAnywhere)
UButton* BackspaceButton;
2022-11-14 22:30:31 +00:00
UFUNCTION()
void CastButtonOnClick();
2022-11-14 22:30:31 +00:00
UFUNCTION()
void FButtonOnClick();
2022-11-14 22:30:31 +00:00
UFUNCTION()
void WButtonOnClick();
2022-11-14 22:30:31 +00:00
UFUNCTION()
void BackspaceButtonOnClick();
2022-11-14 22:30:31 +00:00
void UpdateComboString(FString NewCombo) const;
void UpdateActionPoints() const;
2022-11-14 11:31:51 +00:00
void AddBattleLogMessage(FString Message);
2022-11-14 22:30:31 +00:00
void ClearBattleLog();
void UpdateBattleLog();
void UpdateResourceBars() const;
void ToggleButtons() const;
void EnemyTurn();
2022-11-14 22:30:31 +00:00
};