Updated Thorns Status Effect to Trigger OnPlayerDamage
This commit is contained in:
parent
6227b4952c
commit
0be235f6b1
BIN
Content/Blueprints/StatusEffects/BP_Thorns.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/StatusEffects/BP_Thorns.uasset
(Stored with Git LFS)
Binary file not shown.
@ -20,6 +20,9 @@ void UStatusEffect::OnExpiry(AActor* Character)
|
||||
if (StatusSystem->GetActiveStatusEffect(this).StatusIcon == nullptr) return;
|
||||
StatusSystem->GetActiveStatusEffect(this).StatusIcon->RemoveFromParent();
|
||||
StatusSystem->RemoveStatusEffect(this);
|
||||
ATurnBaseCombatV2* CombatSystem = Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState());
|
||||
CombatSystem->OnPlayerTurn.Remove(OnPlayerTurnDelegateHandle);
|
||||
CombatSystem->OnEnemyTurn.Remove(OnEnemyTurnDelegateHandle);
|
||||
}
|
||||
|
||||
void UStatusEffect::OnPlayerTurn(AActor* Character, AActor* Enemy)
|
||||
@ -35,8 +38,8 @@ void UStatusEffect::OnEnemyTurn(AActor* Enemy, AActor* Character)
|
||||
void UStatusEffect::OnStatusEffectAdd()
|
||||
{
|
||||
ATurnBaseCombatV2* CombatSystem = Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState());
|
||||
CombatSystem->OnPlayerTurn.AddUObject(this, &UStatusEffect::OnPlayerTurn);
|
||||
CombatSystem->OnEnemyTurn.AddUObject(this, &UStatusEffect::OnEnemyTurn);
|
||||
OnPlayerTurnDelegateHandle = CombatSystem->OnPlayerTurn.AddUObject(this, &UStatusEffect::OnPlayerTurn);
|
||||
OnEnemyTurnDelegateHandle = CombatSystem->OnEnemyTurn.AddUObject(this, &UStatusEffect::OnEnemyTurn);
|
||||
}
|
||||
|
||||
void UStatusEffect::CheckForExpiry(const float TimeOfExpiry, AActor* Character)
|
||||
|
@ -20,6 +20,8 @@ public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
FString Description;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
bool IsForCombatOnly = false;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
float BaseDuration;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UTexture2D* Icon;
|
||||
@ -42,4 +44,7 @@ protected:
|
||||
FTimerHandle ExpiryTimerHandle;
|
||||
UFUNCTION()
|
||||
void CheckForExpiry(float TimeOfExpiry, AActor* Character);
|
||||
|
||||
FDelegateHandle OnPlayerTurnDelegateHandle;
|
||||
FDelegateHandle OnEnemyTurnDelegateHandle;
|
||||
};
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include "Thorns.h"
|
||||
|
||||
#include "the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h"
|
||||
|
||||
void UThorns::Invoke(AActor* Character, float TimeOfExpiry)
|
||||
{
|
||||
Super::Invoke(Character, TimeOfExpiry);
|
||||
@ -12,3 +14,15 @@ void UThorns::OnExpiry(AActor* Character)
|
||||
{
|
||||
Super::OnExpiry(Character);
|
||||
}
|
||||
|
||||
void UThorns::OnEnemyTurn(AActor* Enemy, AActor* Character)
|
||||
{
|
||||
Super::OnEnemyTurn(Enemy, Character);
|
||||
ATurnBaseCombatV2* CombatSystem = Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState());
|
||||
CombatSystem->DamageEnemy(DamagePerTurn, "thorns");
|
||||
BaseDuration -= 1.0f;
|
||||
if (BaseDuration <= 0.0f)
|
||||
{
|
||||
OnExpiry(Character);
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,10 @@ class THE_TWILIGHT_ABYSS_API UThorns : public UStatusEffect
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
float DamagePerTurn = 3.0f;
|
||||
|
||||
virtual void Invoke(AActor* Character, float TimeOfExpiry) override;
|
||||
virtual void OnExpiry(AActor* Character) override;
|
||||
virtual void OnEnemyTurn(AActor* Enemy, AActor* Character) override;
|
||||
};
|
||||
|
@ -43,7 +43,14 @@ void UStatusSystem::AddStatusEffect(UStatusEffect* StatusEffect, const float Dur
|
||||
FActiveStatusEffect NewStatusEffect;
|
||||
NewStatusEffect.StatusEffect = StatusEffect;
|
||||
NewStatusEffect.TimeInitiated = UGameplayStatics::GetRealTimeSeconds(GetWorld());
|
||||
NewStatusEffect.TimeTillExpiry = UGameplayStatics::GetRealTimeSeconds(GetWorld()) + StatusEffect->BaseDuration * DurationMultiplier;
|
||||
if (StatusEffect->IsForCombatOnly)
|
||||
{
|
||||
NewStatusEffect.TimeTillExpiry = StatusEffect->BaseDuration * DurationMultiplier;
|
||||
}
|
||||
else
|
||||
{
|
||||
NewStatusEffect.TimeTillExpiry = UGameplayStatics::GetRealTimeSeconds(GetWorld()) + StatusEffect->BaseDuration * DurationMultiplier;
|
||||
}
|
||||
NewStatusEffect.StatusIcon = CreateWidget<UUserWidget>(GetWorld(), HUDStatusIconWidget);
|
||||
UImage* StatusIconImage = Cast<UImage>(NewStatusEffect.StatusIcon->GetWidgetFromName(TEXT("StatusIconImage")));
|
||||
StatusIconImage->SetBrushFromTexture(StatusEffect->Icon);
|
||||
|
@ -86,15 +86,15 @@ void ATurnBaseCombatV2::EndCombat()
|
||||
PlayerController->bShowMouseCursor = false;
|
||||
}
|
||||
|
||||
void ATurnBaseCombatV2::FKeyPressed()
|
||||
{
|
||||
PButtonOnClick();
|
||||
}
|
||||
|
||||
void ATurnBaseCombatV2::WKeyPressed()
|
||||
{
|
||||
EButtonOnClick();
|
||||
}
|
||||
// void ATurnBaseCombatV2::FKeyPressed()
|
||||
// {
|
||||
// PButtonOnClick();
|
||||
// }
|
||||
//
|
||||
// void ATurnBaseCombatV2::WKeyPressed()
|
||||
// {
|
||||
// EButtonOnClick();
|
||||
// }
|
||||
|
||||
void ATurnBaseCombatV2::BeginPlay()
|
||||
{
|
||||
@ -176,6 +176,7 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
|
||||
UStatusEffect* TempThornsStatusEffect = NewObject<UStatusEffect>(PlayerActor, ThornsStatusEffect);
|
||||
StatusSystem->AddStatusEffect(TempThornsStatusEffect, 1, false);
|
||||
StatusEffects.Add(TempThornsStatusEffect);
|
||||
AddBattleLogMessage("Player Casted Thorns");
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,6 +192,7 @@ void ATurnBaseCombatV2::ExecuteCast(FString Combo)
|
||||
RevertActionPoints();
|
||||
UpdateActionPoints();
|
||||
|
||||
//Damage Calculation
|
||||
switch (bIsPlayerTurn)
|
||||
{
|
||||
case true:
|
||||
@ -241,18 +243,18 @@ void ATurnBaseCombatV2::RevertActionPoints()
|
||||
UpdateActionPoints();
|
||||
}
|
||||
|
||||
void ATurnBaseCombatV2::DamagePlayer(int Damage)
|
||||
void ATurnBaseCombatV2::DamagePlayer(int Damage, FString DamageType)
|
||||
{
|
||||
*PlayerHealth -= FMath::Clamp(Damage, 0, 100);
|
||||
UpdateProgressBars();
|
||||
AddBattleLogMessage("Player was damaged for " + FString::FromInt(Damage) + " damage.");
|
||||
AddBattleLogMessage("Player was damaged for " + FString::FromInt(Damage) + " HP by " + DamageType + ".");
|
||||
}
|
||||
|
||||
void ATurnBaseCombatV2::DamageEnemy(int Damage)
|
||||
void ATurnBaseCombatV2::DamageEnemy(int Damage, FString DamageType)
|
||||
{
|
||||
*EnemyHealth -= FMath::Clamp(Damage, 0, 100);
|
||||
UpdateProgressBars();
|
||||
AddBattleLogMessage("Enemy was damaged for " + FString::FromInt(Damage) + " damage.");
|
||||
AddBattleLogMessage("Enemy was damaged for " + FString::FromInt(Damage) + " HP by " + DamageType + ".");
|
||||
}
|
||||
|
||||
void ATurnBaseCombatV2::UpdateProgressBars() const
|
||||
@ -455,6 +457,7 @@ void ATurnBaseCombatV2::ToggleButtons() const
|
||||
void ATurnBaseCombatV2::EnemyTurn()
|
||||
{
|
||||
DamagePlayer(10);
|
||||
OnEnemyTurn.Broadcast(EnemyActor, PlayerActor);
|
||||
TurnIndicatorTextBlock->SetText(FText::FromString("Player Turn"));
|
||||
ToggleButtons();
|
||||
}
|
||||
|
@ -94,15 +94,18 @@ public:
|
||||
void StartCombat(AActor* Enemy);
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void EndCombat();
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void FKeyPressed();
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void WKeyPressed();
|
||||
// UFUNCTION(BlueprintCallable)
|
||||
// void FKeyPressed();
|
||||
// UFUNCTION(BlueprintCallable)
|
||||
// void WKeyPressed();
|
||||
|
||||
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;
|
||||
@ -110,8 +113,6 @@ protected:
|
||||
void UseActionPoint();
|
||||
void ReuseActionPoint();
|
||||
void RevertActionPoints();
|
||||
void DamagePlayer(int Damage);
|
||||
void DamageEnemy(int Damage);
|
||||
void UpdateProgressBars() const;
|
||||
|
||||
private:
|
||||
|
@ -1,4 +1,5 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Azos/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Iroquoid/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Probertium/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Probertium/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=UFUNCTION/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
Loading…
Reference in New Issue
Block a user