diff --git a/Content/Assets/Items/MagneticShield_BP.uasset b/Content/Assets/Items/MagneticShield_BP.uasset index 8dd8391..b2ec69c 100644 --- a/Content/Assets/Items/MagneticShield_BP.uasset +++ b/Content/Assets/Items/MagneticShield_BP.uasset Binary files differ diff --git a/Content/Assets/Items/Overcharge_BP.uasset b/Content/Assets/Items/Overcharge_BP.uasset deleted file mode 100644 index b3533e6..0000000 --- a/Content/Assets/Items/Overcharge_BP.uasset +++ /dev/null Binary files differ diff --git a/Content/Assets/Items/RepairKit_BP.uasset b/Content/Assets/Items/RepairKit_BP.uasset index bcc4530..24c8746 100644 --- a/Content/Assets/Items/RepairKit_BP.uasset +++ b/Content/Assets/Items/RepairKit_BP.uasset Binary files differ diff --git a/Content/Levels/Sergio_Level.umap b/Content/Levels/Sergio_Level.umap index c328913..0749cd0 100644 --- a/Content/Levels/Sergio_Level.umap +++ b/Content/Levels/Sergio_Level.umap Binary files differ diff --git a/Content/PlaneTest/Targets_BP.uasset b/Content/PlaneTest/Targets_BP.uasset index 29f1c42..64148cc 100644 --- a/Content/PlaneTest/Targets_BP.uasset +++ b/Content/PlaneTest/Targets_BP.uasset Binary files differ diff --git a/Source/SkyFrontier/Private/HealthSystem.cpp b/Source/SkyFrontier/Private/HealthSystem.cpp index 92990cc..59e7244 100644 --- a/Source/SkyFrontier/Private/HealthSystem.cpp +++ b/Source/SkyFrontier/Private/HealthSystem.cpp @@ -14,8 +14,9 @@ { Super::BeginPlay(); - // This is here for now, but if you ever do anything serialization related you might not want this. + MaxHealth = 100; Health = MaxHealth; + Shield = 0; } float UHealthSystem::GetHealth() const @@ -33,6 +34,11 @@ return Health / MaxHealth; } +float UHealthSystem::GetShield() const +{ + return Shield; +} + void UHealthSystem::ModifyHealth(const float Amount) { if(Amount == 0) @@ -58,7 +64,35 @@ if(Amount > 0) { Health += Amount; - + if (Health >= MaxHealth) + { + Health = MaxHealth; + } + OnDamageHealedEvent.Broadcast(Amount); } +} + +void UHealthSystem::ReceiveShield(const float Amount) +{ + if(Amount >= 0) + { + Shield += Amount; + + OnShieldReceiveEvent.Broadcast(Amount); + } +} + +void UHealthSystem::RemoveShield(const float Amount) +{ + if(Amount >= 0) + { + Shield -= Amount; + + if (Shield < 0) + { + Shield = 0; + } + OnShieldReceiveEvent.Broadcast(Amount); + } } \ No newline at end of file diff --git a/Source/SkyFrontier/Public/HealthSystem.h b/Source/SkyFrontier/Public/HealthSystem.h index 2e0e911..3f5377b 100644 --- a/Source/SkyFrontier/Public/HealthSystem.h +++ b/Source/SkyFrontier/Public/HealthSystem.h @@ -8,6 +8,7 @@ DECLARE_EVENT_OneParam(UCPP_HealthComponent, DamageTakenEvent, float ) DECLARE_EVENT_OneParam(UCPP_HealthComponent, HealDamageEvent, float ) +DECLARE_EVENT_OneParam(UCPP_HealthComponent, ShieldReceiveEvent, float ) UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) class SKYFRONTIER_API UHealthSystem : public UActorComponent @@ -24,6 +25,8 @@ float GetMaxHealth() const; UFUNCTION(BlueprintPure) float GetHealthAsPercentage() const; + UFUNCTION(BlueprintPure) + float GetShield() const; UFUNCTION(BlueprintCallable) void ModifyHealth(float Amount); @@ -32,6 +35,10 @@ void TakeDamage(float Amount); UFUNCTION(BlueprintCallable) void RecoverHealth(float Amount); + UFUNCTION(BlueprintCallable) + void ReceiveShield(float Amount); + UFUNCTION(BlueprintCallable) + void RemoveShield(float Amount); protected: // Functions @@ -41,6 +48,7 @@ DamageTakenEvent OnDamageTakenEvent; HealDamageEvent OnDamageHealedEvent; + ShieldReceiveEvent OnShieldReceiveEvent; private: // This can be protected if we want to subclass the Health Component @@ -48,5 +56,7 @@ float Health; UPROPERTY(EditAnywhere) float MaxHealth; - + UPROPERTY(VisibleAnywhere) + float Shield; + };