// 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 HUDWidget; UPROPERTY(EditAnywhere) TSubclassOf CombatTutorialWidget; UPROPERTY() bool HasSeenTutorial = false; UPROPERTY(EditAnywhere) TMap ValidCombos = { {"PE", 15}, {"PA", 15}, {"PI", 15}, {"EA", 15}, {"EI", 15}, {"AI", 15}, {"PP", 20}, {"EE", 20}, {"AA", 20}, {"II", 20} }; UPROPERTY(EditAnywhere) TMap 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 ThornsStatusEffect; UPROPERTY() TSubclassOf DOTStatusEffect; UPROPERTY() TArray StatusEffects; UPROPERTY(VisibleAnywhere) bool bIsPlayerTurn = true; UPROPERTY(VisibleAnywhere) FString CurrentComboString = ""; void SwitchTurn(); UPROPERTY(VisibleAnywhere) UTextBlock* TurnIndicatorTextBlock; UPROPERTY(VisibleAnywhere) UTextBlock* CurrentComboTextBlock; UPROPERTY(VisibleAnywhere) UTextBlock* CurrentComboTextBlock1; UPROPERTY(VisibleAnywhere) UTextBlock* CurrentComboTextBlock2; UPROPERTY(VisibleAnywhere) UTextBlock* BattleLogTextBlock; UPROPERTY(VisibleAnywhere) UTextBlock* EscapePercentageTextBlock; UPROPERTY(VisibleAnywhere) UProgressBar* PlayerHealthBar; UPROPERTY(VisibleAnywhere) UProgressBar* EnemyHealthBar; UPROPERTY(VisibleAnywhere) UProgressBar* ProbertiumResourceBar; UPROPERTY(VisibleAnywhere) UProgressBar* EisResourceBar; UPROPERTY(VisibleAnywhere) UProgressBar* AzosResourceBar; UPROPERTY(VisibleAnywhere) UProgressBar* IroquoidResourceBar; UPROPERTY(VisibleAnywhere) UButton* CastButton; UPROPERTY(VisibleAnywhere) UButton* PButton; UPROPERTY(VisibleAnywhere) UButton* EButton; UPROPERTY(VisibleAnywhere) UButton* AButton; UPROPERTY(VisibleAnywhere) UButton* IButton; UPROPERTY(VisibleAnywhere) UButton* BackspaceButton; UPROPERTY(VisibleAnywhere) 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 DeathScreenWidgetSubclass; };