diff --git a/Content/Assets/NewTargetSystem/Missile_NT.uasset b/Content/Assets/NewTargetSystem/Missile_NT.uasset index 190071d..188e738 100644 --- a/Content/Assets/NewTargetSystem/Missile_NT.uasset +++ b/Content/Assets/NewTargetSystem/Missile_NT.uasset Binary files differ diff --git a/Content/Assets/NormieAsset/Test_anim.uasset b/Content/Assets/NormieAsset/Test_anim.uasset index 0a3418d..edecf36 100644 --- a/Content/Assets/NormieAsset/Test_anim.uasset +++ b/Content/Assets/NormieAsset/Test_anim.uasset Binary files differ diff --git a/Content/Levels/StartMap.umap b/Content/Levels/StartMap.umap index aa1ba99..219a987 100644 --- a/Content/Levels/StartMap.umap +++ b/Content/Levels/StartMap.umap Binary files differ diff --git a/Content/Matchmaking_Widget.uasset b/Content/Matchmaking_Widget.uasset index 1761516..45b1e4b 100644 --- a/Content/Matchmaking_Widget.uasset +++ b/Content/Matchmaking_Widget.uasset Binary files differ diff --git a/Content/PlaneTest/Projectile_BP.uasset b/Content/PlaneTest/Projectile_BP.uasset index 846f752..c1e0cbc 100644 --- a/Content/PlaneTest/Projectile_BP.uasset +++ b/Content/PlaneTest/Projectile_BP.uasset Binary files differ diff --git a/Content/PlaneTest/Targets_BP.uasset b/Content/PlaneTest/Targets_BP.uasset index 8c11ee6..0b72218 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 3643f42..fd6f219 100644 --- a/Source/SkyFrontier/Private/HealthSystem.cpp +++ b/Source/SkyFrontier/Private/HealthSystem.cpp @@ -1,7 +1,6 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - #include "HealthSystem.h" +#include "Net/UnrealNetwork.h" +#include "Engine/Engine.h" UHealthSystem::UHealthSystem() { @@ -12,7 +11,6 @@ void UHealthSystem::BeginPlay() { Super::BeginPlay(); - Health = MaxHealth; Shield = 0; } @@ -27,66 +25,51 @@ return MaxHealth; } -float UHealthSystem::GetHealthAsPercentage() const -{ - return Health / MaxHealth; -} - float UHealthSystem::GetShield() const { return Shield; } -void UHealthSystem::ModifyHealth(const float Amount) -{ - if(Amount == 0) - return; - - Health += Amount; - - Amount > 0 ? OnDamageHealedEvent.Broadcast(Amount) : OnDamageTakenEvent.Broadcast(Amount); -} - void UHealthSystem::TakeDamage(const float Amount) { - if(Amount > 0) + if (Amount > 0) { Health -= Amount; OnDamageTakenEvent.Broadcast(Amount); } } - + void UHealthSystem::RecoverHealth(const float Amount) { - if(Amount > 0) + if (Amount > 0) { Health += Amount; if (Health >= MaxHealth) { Health = MaxHealth; } - + OnDamageHealedEvent.Broadcast(Amount); } } void UHealthSystem::ReceiveShield(const float Amount) { - if(Amount >= 0) + if (Amount >= 0) { Shield += Amount; - + OnShieldReceiveEvent.Broadcast(Amount); } } void UHealthSystem::RemoveShield(const float Amount) { - if(Amount >= 0) + if (Amount >= 0) { Shield -= Amount; - + if (Shield < 0) { Shield = 0; diff --git a/Source/SkyFrontier/Private/MyPlayerState.cpp b/Source/SkyFrontier/Private/MyPlayerState.cpp index 38f2d07..50738a0 100644 --- a/Source/SkyFrontier/Private/MyPlayerState.cpp +++ b/Source/SkyFrontier/Private/MyPlayerState.cpp @@ -2,7 +2,6 @@ #include "MyPlayerState.h" - #include "MyButton.h" #include "TCPClient.h" #include "Blueprint/UserWidget.h" diff --git a/Source/SkyFrontier/Private/TCPClient.cpp b/Source/SkyFrontier/Private/TCPClient.cpp index 4edafa8..c610cb2 100644 --- a/Source/SkyFrontier/Private/TCPClient.cpp +++ b/Source/SkyFrontier/Private/TCPClient.cpp @@ -46,7 +46,7 @@ int32 sent = 0; bool successful = Socket->Send((uint8*)TCHAR_TO_UTF8(serializedChar), size, sent); if (successful) - {UE_LOG(LogTemp, Log, TEXT("MESSAGE SENT!")); + {UE_LOG(LogTemp, Log, TEXT("MESSAGE SENT THROUGH SOCKET")); return true; } else diff --git a/Source/SkyFrontier/Public/HealthSystem.h b/Source/SkyFrontier/Public/HealthSystem.h index 3f5377b..1254024 100644 --- a/Source/SkyFrontier/Public/HealthSystem.h +++ b/Source/SkyFrontier/Public/HealthSystem.h @@ -1,49 +1,43 @@ -// Fill out your copyright notice in the Description page of Project Settings. - #pragma once #include "CoreMinimal.h" +#include "Net/UnrealNetwork.h" #include "Components/ActorComponent.h" #include "HealthSystem.generated.h" -DECLARE_EVENT_OneParam(UCPP_HealthComponent, DamageTakenEvent, float ) -DECLARE_EVENT_OneParam(UCPP_HealthComponent, HealDamageEvent, float ) -DECLARE_EVENT_OneParam(UCPP_HealthComponent, ShieldReceiveEvent, float ) +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) ) +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class SKYFRONTIER_API UHealthSystem : public UActorComponent { GENERATED_BODY() -public: +public: // Sets default values for this component's properties UHealthSystem(); - + UFUNCTION(BlueprintPure) - float GetHealth() const; + float GetHealth() const; UFUNCTION(BlueprintPure) - float GetMaxHealth() const; + float GetMaxHealth() const; UFUNCTION(BlueprintPure) - float GetHealthAsPercentage() const; - UFUNCTION(BlueprintPure) - float GetShield() const; + float GetShield() const; UFUNCTION(BlueprintCallable) - void ModifyHealth(float Amount); - + void TakeDamage(float Amount); UFUNCTION(BlueprintCallable) - void TakeDamage(float Amount); + void RecoverHealth(float Amount); UFUNCTION(BlueprintCallable) - void RecoverHealth(float Amount); + void ReceiveShield(float Amount); UFUNCTION(BlueprintCallable) - void ReceiveShield(float Amount); - UFUNCTION(BlueprintCallable) - void RemoveShield(float Amount); + void RemoveShield(float Amount); protected: // Functions - virtual void BeginPlay() override; - + virtual void BeginPlay() override; + public: // Events DamageTakenEvent OnDamageTakenEvent; @@ -53,10 +47,9 @@ private: // This can be protected if we want to subclass the Health Component UPROPERTY(VisibleAnywhere) - float Health; + float Health; UPROPERTY(EditAnywhere) - float MaxHealth; + float MaxHealth; UPROPERTY(VisibleAnywhere) - float Shield; - + float Shield; };