AzureAbyss/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h

219 lines
4.6 KiB
C++

// 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"
#include "StatusEffect.h"
#include "NiagaraComponent.h"
#include "NiagaraFunctionLibrary.h"
#include "GameFramework/GameStateBase.h"
#include "Components/WidgetComponent.h"
#include "StatusEffects/Thorns.h"
#include "TurnBaseCombatV2.generated.h"
class UNiagaraSystem;
UCLASS()
class THE_TWILIGHT_ABYSS_API ATurnBaseCombatV2 : public AGameStateBase
{
GENERATED_BODY()
public:
ATurnBaseCombatV2();
int* EnemyHealth = nullptr;
float* PlayerHealth = nullptr;
bool bIsInCombat = false;
UPROPERTY(EditDefaultsOnly)
int DefaultActionPoints = 2;
UPROPERTY(EditDefaultsOnly)
int ActiveActionPoints = 0;
UPROPERTY(EditDefaultsOnly)
int ProbertiumResource = 10;
UPROPERTY(EditDefaultsOnly)
int EisResource = 10;
UPROPERTY(EditDefaultsOnly)
int AzosResource = 10;
UPROPERTY(EditDefaultsOnly)
int IroquoidResource = 10;
UPROPERTY(EditDefaultsOnly)
UNiagaraSystem* GunEffect;
UPROPERTY(VisibleAnywhere)
AActor* PlayerActor;
UPROPERTY(VisibleAnywhere)
AActor* EnemyActor;
// AActor* ActiveActor;
UPROPERTY(BlueprintReadWrite)
UUserWidget* HUD;
UPROPERTY()
UUserWidget* BookHUD;
UPROPERTY()
UUserWidget* CombatTutorialWidgetInstance;
UPROPERTY()
UWidgetComponent* PlayerWidget;
/*
TODO:
Reference Player Inventory
*/
UPROPERTY(EditAnywhere)
TSubclassOf<UUserWidget> HUDWidget;
UPROPERTY(EditAnywhere)
TSubclassOf<UUserWidget> CombatTutorialWidget;
UPROPERTY()
bool HasSeenTutorial = false;
UPROPERTY(EditAnywhere)
TMap<FString, int32> ValidCombos =
{
{"PE", 15},
{"PA", 15},
{"PI", 15},
{"EA", 15},
{"EI", 15},
{"AI", 15},
{"PP", 20},
{"EE", 20},
{"AA", 20},
{"II", 20}
};
UPROPERTY(EditAnywhere)
TMap<FString, FString> SpecialCombos =
{
{"PA", "Thorns"},
{"PI", "DamageOverTime"}
};
FString BattleLog;
UFUNCTION(BlueprintCallable)
void StartCombat(AActor* Enemy);
UFUNCTION(BlueprintCallable)
void EndCombat();
DECLARE_EVENT_TwoParams(ATurnBaseCombatV2, FOnPlayerTurn, AActor*, AActor*);
DECLARE_EVENT_TwoParams(ATurnBaseCombatV2, FOnEnemyTurn, AActor*, AActor*);
FOnPlayerTurn OnPlayerTurn;
FOnEnemyTurn OnEnemyTurn;
void DamagePlayer(int Damage, FString DamageType = "unknown");
void DamageEnemy(int Damage, FString DamageType = "unknown");
protected:
virtual void BeginPlay() override;
void ExecuteCast(FString Combo);
void UseActionPoint();
void ReuseActionPoint();
void RevertActionPoints();
void UpdateProgressBars() const;
bool bPlayerHasExtraTurn = false;
bool bEnemyHasExtraTurn = false;
float EscapePercentage = 0.0f;
float CalculateEscapePercentage() const;
private:
bool IsValidCombo(FString Combo) const;
bool IsSpecialCombo(FString Combo) const;
UPROPERTY()
TSubclassOf<UStatusEffect> ThornsStatusEffect;
UPROPERTY()
TSubclassOf<UStatusEffect> DOTStatusEffect;
UPROPERTY()
TArray<UStatusEffect*> StatusEffects;
UPROPERTY(VisibleAnywhere)
bool bIsPlayerTurn = true;
UPROPERTY(VisibleAnywhere)
FString CurrentComboString = "";
void SwitchTurn();
UPROPERTY()
UTextBlock* TurnIndicatorTextBlock;
UPROPERTY()
UTextBlock* CurrentComboTextBlock;
UPROPERTY()
UTextBlock* CurrentComboTextBlock1;
UPROPERTY()
UTextBlock* CurrentComboTextBlock2;
UPROPERTY()
UTextBlock* BattleLogTextBlock;
UPROPERTY()
UTextBlock* EscapePercentageTextBlock;
UPROPERTY()
UProgressBar* PlayerHealthBar;
UPROPERTY()
UProgressBar* EnemyHealthBar;
UPROPERTY()
UProgressBar* ProbertiumResourceBar;
UPROPERTY()
UProgressBar* EisResourceBar;
UPROPERTY()
UProgressBar* AzosResourceBar;
UPROPERTY()
UProgressBar* IroquoidResourceBar;
UPROPERTY()
UButton* CastButton;
UPROPERTY()
UButton* PButton;
UPROPERTY()
UButton* EButton;
UPROPERTY()
UButton* AButton;
UPROPERTY()
UButton* IButton;
UPROPERTY()
UButton* BackspaceButton;
UPROPERTY()
UButton* RunButton;
UFUNCTION()
void CastButtonOnClick();
UFUNCTION()
void PButtonOnClick();
UFUNCTION()
void EButtonOnClick();
UFUNCTION()
void AButtonOnClick();
UFUNCTION()
void IButtonOnClick();
UFUNCTION()
void BackspaceButtonOnClick();
UFUNCTION()
void RunButtonOnClick();
void UpdateComboString(FString NewCombo) const;
void UpdateActionPoints() const;
void AddBattleLogMessage(FString Message);
void ClearBattleLog();
void UpdateBattleLog();
void UpdateResourceBars() const;
UFUNCTION(BlueprintCallable)
void ToggleButtons() const;
void EnemyTurn();
UPROPERTY()
UUserWidget* DeathScreenWidget;
UPROPERTY()
TSubclassOf<UUserWidget> DeathScreenWidgetSubclass;
};