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,18 +16,15 @@ UEatableItems::UEatableItems() | |||||||
| 
 | 
 | ||||||
| void UEatableItems::Use(ATempCharacter* Character) | void UEatableItems::Use(ATempCharacter* Character) | ||||||
| { | { | ||||||
| 	if(Character) | 	if (Character) | ||||||
| 	{ | 	{ | ||||||
| 		if(isHealingItem) | 		if (isHealingItem) | ||||||
| 		{ | 		{ | ||||||
| 			if (Character->Health < 100) | 			if (Character->Health < 100) | ||||||
| 			{ | 			{ | ||||||
| 				/*Character->Health += 10;
 |  | ||||||
| 				UE_LOG(LogTemp, Display, TEXT("Healed")); |  | ||||||
| 				Character->Inventory->RemoveItem(this);*/ |  | ||||||
| 
 |  | ||||||
| 				UStatusSystem* StatusSystem = Character->FindComponentByClass<UStatusSystem>(); | 				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) | 			else if (Character->Health >= 100) | ||||||
| 			{ | 			{ | ||||||
| @ -35,7 +32,7 @@ void UEatableItems::Use(ATempCharacter* Character) | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if(isDamageBuffItem) | 		if (isDamageBuffItem) | ||||||
| 		{ | 		{ | ||||||
| 			// need to add the damage buff functionality here
 | 			// need to add the damage buff functionality here
 | ||||||
| 			UE_LOG(LogTemp, Display, TEXT("Damage Buffed")); | 			UE_LOG(LogTemp, Display, TEXT("Damage Buffed")); | ||||||
| @ -57,4 +54,3 @@ void UEatableItems::Use(ATempCharacter* Character) | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 |  | ||||||
|  | |||||||
| @ -5,10 +5,11 @@ | |||||||
| 
 | 
 | ||||||
| #include "StatusSystem.h" | #include "StatusSystem.h" | ||||||
| #include "Kismet/GameplayStatics.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) | void UStatusEffect::OnExpiry(AActor* Character) | ||||||
| @ -26,4 +27,8 @@ void UStatusEffect::CheckForExpiry(const float TimeOfExpiry, AActor* Character) | |||||||
| 	{ | 	{ | ||||||
| 		OnExpiry(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 "CoreMinimal.h" | ||||||
| #include "Components/ActorComponent.h" | #include "Components/ActorComponent.h" | ||||||
| #include "StatusEffect.h" | #include "StatusEffect.h" | ||||||
| #include "Components/TextBlock.h" |  | ||||||
| #include "Components/WrapBox.h" | #include "Components/WrapBox.h" | ||||||
| #include "StatusSystem.generated.h" | #include "StatusSystem.generated.h" | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user