Updated StatusSystem for Seconds Countdown
This commit is contained in:
parent
2f47693608
commit
e96c3411c0
BIN
Content/Blueprints/Status_UI/StatusIcon.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Status_UI/StatusIcon.uasset
(Stored with Git LFS)
Binary file not shown.
@ -16,26 +16,23 @@ UEatableItems::UEatableItems()
|
||||
|
||||
void UEatableItems::Use(ATempCharacter* Character)
|
||||
{
|
||||
if(Character)
|
||||
if (Character)
|
||||
{
|
||||
if(isHealingItem)
|
||||
if (isHealingItem)
|
||||
{
|
||||
if (Character->Health < 100)
|
||||
{
|
||||
/*Character->Health += 10;
|
||||
UE_LOG(LogTemp, Display, TEXT("Healed"));
|
||||
Character->Inventory->RemoveItem(this);*/
|
||||
|
||||
UStatusSystem* StatusSystem = Character->FindComponentByClass<UStatusSystem>();
|
||||
StatusSystem->AddStatusEffect(NewObject<UStatusEffect>(this, HealOverTimeStatusEffect));
|
||||
StatusSystem->AddStatusEffect(NewObject<UStatusEffect>(Character, HealOverTimeStatusEffect));
|
||||
Character->Inventory->RemoveItem(this);
|
||||
}
|
||||
else if (Character->Health >= 100)
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("Health is full"));
|
||||
}
|
||||
}
|
||||
|
||||
if(isDamageBuffItem)
|
||||
|
||||
if (isDamageBuffItem)
|
||||
{
|
||||
// need to add the damage buff functionality here
|
||||
UE_LOG(LogTemp, Display, TEXT("Damage Buffed"));
|
||||
@ -57,4 +54,3 @@ void UEatableItems::Use(ATempCharacter* Character)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,17 +5,18 @@
|
||||
|
||||
#include "StatusSystem.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "Components/TextBlock.h"
|
||||
|
||||
void UStatusEffect::Invoke(AActor* Character, float TimeOfExpiry)
|
||||
void UStatusEffect::Invoke(AActor* Character, float TimeOfInit)
|
||||
{
|
||||
GetWorld()->GetTimerManager().SetTimer(ExpiryTimerHandle, [this, Character, TimeOfExpiry] { CheckForExpiry(TimeOfExpiry, Character); }, 1, true, 0);
|
||||
GetWorld()->GetTimerManager().SetTimer(ExpiryTimerHandle, [this, Character, TimeOfInit] { CheckForExpiry(TimeOfInit, Character); }, 1, true, 0);
|
||||
}
|
||||
|
||||
void UStatusEffect::OnExpiry(AActor* Character)
|
||||
{
|
||||
GetWorld()->GetTimerManager().ClearTimer(ExpiryTimerHandle);
|
||||
UStatusSystem* StatusSystem = Cast<UStatusSystem>(Character->GetComponentByClass(UStatusSystem::StaticClass()));
|
||||
if (StatusSystem->GetActiveStatusEffect(this).StatusIcon == nullptr) return;
|
||||
if (StatusSystem->GetActiveStatusEffect(this).StatusIcon == nullptr) return;
|
||||
StatusSystem->GetActiveStatusEffect(this).StatusIcon->RemoveFromParent();
|
||||
StatusSystem->RemoveStatusEffect(this);
|
||||
}
|
||||
@ -26,4 +27,8 @@ void UStatusEffect::CheckForExpiry(const float TimeOfExpiry, AActor* Character)
|
||||
{
|
||||
OnExpiry(Character);
|
||||
}
|
||||
UStatusSystem* StatusSystem = Cast<UStatusSystem>(Character->GetComponentByClass(UStatusSystem::StaticClass()));
|
||||
if (StatusSystem->GetActiveStatusEffect(this).StatusIcon == nullptr) return;
|
||||
UTextBlock* StatusText = Cast<UTextBlock>(StatusSystem->GetActiveStatusEffect(this).StatusIcon->GetWidgetFromName(TEXT("DurationText")));
|
||||
StatusText->SetText(FText::FromString(FString::FromInt(TimeOfExpiry - UGameplayStatics::GetRealTimeSeconds(GetWorld()))));
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "StatusEffect.h"
|
||||
#include "Components/TextBlock.h"
|
||||
#include "Components/WrapBox.h"
|
||||
#include "StatusSystem.generated.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user