AzureAbyss/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h

227 lines
4.8 KiB
C
Raw Normal View History

2022-11-17 03:02:58 +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"
#include "StatusEffect.h"
#include "NiagaraComponent.h"
#include "NiagaraFunctionLibrary.h"
2022-11-17 03:02:58 +00:00
#include "GameFramework/GameStateBase.h"
#include "Components/WidgetComponent.h"
#include "StatusEffects/Thorns.h"
2022-11-17 03:02:58 +00:00
#include "TurnBaseCombatV2.generated.h"
class UNiagaraSystem;
2022-11-17 03:02:58 +00:00
UCLASS()
class THE_TWILIGHT_ABYSS_API ATurnBaseCombatV2 : public AGameStateBase
{
GENERATED_BODY()
public:
ATurnBaseCombatV2();
int* EnemyHealth = nullptr;
float* PlayerHealth = nullptr;
bool bIsInCombat = false;
2022-11-17 03:02:58 +00:00
UPROPERTY(EditDefaultsOnly)
float BaseDamageMultiplier = 1.0f;
2022-11-17 03:02:58 +00:00
UPROPERTY(EditDefaultsOnly)
float BaseDefenseMultiplier = 1.0f;
UPROPERTY()
float ChainDamageMultiplier = 1.0f;
UPROPERTY(EditDefaultsOnly)
int DefaultActionPoints = 2;
UPROPERTY()
2022-11-17 03:02:58 +00:00
int ActiveActionPoints = 0;
2022-11-17 03:02:58 +00:00
UPROPERTY(EditDefaultsOnly)
int ProbertiumResource = 10;
2022-11-17 03:02:58 +00:00
UPROPERTY(EditDefaultsOnly)
int EisResource = 10;
UPROPERTY(EditDefaultsOnly)
int AzosResource = 10;
UPROPERTY(EditDefaultsOnly)
int IroquoidResource = 10;
2022-11-17 03:02:58 +00:00
UPROPERTY(EditDefaultsOnly)
UNiagaraSystem* GunEffect;
UPROPERTY(VisibleAnywhere)
AActor* PlayerActor;
2022-11-17 03:02:58 +00:00
UPROPERTY(VisibleAnywhere)
AActor* EnemyActor;
// AActor* ActiveActor;
UPROPERTY(BlueprintReadWrite)
UUserWidget* HUD;
UPROPERTY()
UUserWidget* BookHUD;
UPROPERTY()
UUserWidget* CombatTutorialWidgetInstance;
UPROPERTY()
UWidgetComponent* PlayerWidget;
2022-11-17 03:02:58 +00:00
UPROPERTY(EditAnywhere)
TSubclassOf<UUserWidget> HUDWidget;
UPROPERTY(EditAnywhere)
TSubclassOf<UUserWidget> CombatTutorialWidget;
UPROPERTY()
bool HasSeenTutorial = false;
UPROPERTY(EditAnywhere)
2022-11-17 03:02:58 +00:00
TMap<FString, int32> ValidCombos =
{
2023-04-25 03:38:06 +00:00
{"PE", 15},
{"PA", 15},
{"PI", 15},
2023-04-25 03:38:06 +00:00
{"EA", 15},
{"EI", 15},
{"AI", 15},
{"PP", 20},
{"EE", 20},
{"AA", 20},
{"II", 20}
2022-11-17 03:02:58 +00:00
};
UPROPERTY(EditAnywhere)
TMap<FString, FString> SpecialCombos =
{
2023-04-25 03:38:06 +00:00
{"PA", "Thorns"},
{"PI", "DamageOverTime"}
};
2022-11-17 03:02:58 +00:00
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");
2022-11-17 03:02:58 +00:00
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;
2022-11-17 03:02:58 +00:00
private:
bool IsValidCombo(FString Combo) const;
bool IsSpecialCombo(FString Combo) const;
UPROPERTY()
TSubclassOf<UStatusEffect> ThornsStatusEffect;
UPROPERTY()
TSubclassOf<UStatusEffect> DOTStatusEffect;
UPROPERTY()
TArray<UStatusEffect*> StatusEffects;
2022-11-17 03:02:58 +00:00
UPROPERTY(VisibleAnywhere)
bool bIsPlayerTurn = true;
FString PreviousComboString = "";
2022-11-17 03:02:58 +00:00
UPROPERTY(VisibleAnywhere)
FString CurrentComboString = "";
void SwitchTurn();
UPROPERTY()
2022-11-17 03:02:58 +00:00
UTextBlock* TurnIndicatorTextBlock;
UPROPERTY()
2022-11-17 03:02:58 +00:00
UTextBlock* CurrentComboTextBlock;
UPROPERTY()
UTextBlock* CurrentComboTextBlock1;
UPROPERTY()
UTextBlock* CurrentComboTextBlock2;
UPROPERTY()
2022-11-17 03:02:58 +00:00
UTextBlock* BattleLogTextBlock;
UPROPERTY()
UTextBlock* EscapePercentageTextBlock;
UPROPERTY()
UTextBlock* DamageMultiplierTextBlock;
2022-11-17 03:02:58 +00:00
UPROPERTY()
2022-11-17 03:02:58 +00:00
UProgressBar* PlayerHealthBar;
UPROPERTY()
2022-11-17 03:02:58 +00:00
UProgressBar* EnemyHealthBar;
UPROPERTY()
UProgressBar* ProbertiumResourceBar;
UPROPERTY()
UProgressBar* EisResourceBar;
UPROPERTY()
UProgressBar* AzosResourceBar;
UPROPERTY()
UProgressBar* IroquoidResourceBar;
2022-11-17 03:02:58 +00:00
UPROPERTY()
2022-11-17 03:02:58 +00:00
UButton* CastButton;
UPROPERTY()
UButton* PButton;
UPROPERTY()
UButton* EButton;
UPROPERTY()
UButton* AButton;
UPROPERTY()
UButton* IButton;
2022-11-17 03:02:58 +00:00
UPROPERTY()
2022-11-17 03:02:58 +00:00
UButton* BackspaceButton;
UPROPERTY()
UButton* RunButton;
2022-11-17 03:02:58 +00:00
UFUNCTION()
void CastButtonOnClick();
UFUNCTION()
void PButtonOnClick();
UFUNCTION()
void EButtonOnClick();
2022-11-17 03:02:58 +00:00
UFUNCTION()
void AButtonOnClick();
UFUNCTION()
void IButtonOnClick();
2022-11-17 03:02:58 +00:00
UFUNCTION()
void BackspaceButtonOnClick();
UFUNCTION()
void RunButtonOnClick();
2022-11-17 03:02:58 +00:00
void UpdateComboString(FString NewCombo) const;
void UpdateActionPoints() const;
void AddBattleLogMessage(FString Message);
void ClearBattleLog();
void UpdateBattleLog();
void UpdateResourceBars() const;
UFUNCTION(BlueprintCallable)
2022-11-17 03:02:58 +00:00
void ToggleButtons() const;
void EnemyTurn();
2023-03-14 04:17:29 +00:00
UPROPERTY()
UUserWidget* DeathScreenWidget;
UPROPERTY()
TSubclassOf<UUserWidget> DeathScreenWidgetSubclass;
2022-11-17 03:02:58 +00:00
};