diff --git a/Config/DefaultInput.ini b/Config/DefaultInput.ini index 21eb291..5b7cca1 100644 --- a/Config/DefaultInput.ini +++ b/Config/DefaultInput.ini @@ -85,6 +85,7 @@ +ActionMappings=(ActionName="Shooting",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Gamepad_FaceButton_Left) +ActionMappings=(ActionName="Ability",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftShift) +ActionMappings=(ActionName="Ability",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Gamepad_FaceButton_Right) ++ActionMappings=(ActionName="GetDamaged",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=P) +AxisMappings=(AxisName="Roll",Scale=1.000000,Key=Q) +AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=W) +AxisMappings=(AxisName="MoveRight",Scale=1.000000,Key=D) diff --git a/Content/Assets/NormieAsset/Test_anim.uasset b/Content/Assets/NormieAsset/Test_anim.uasset index bba2e25..d5c29d3 100644 --- a/Content/Assets/NormieAsset/Test_anim.uasset +++ b/Content/Assets/NormieAsset/Test_anim.uasset Binary files differ diff --git a/Content/Levels/Sergio_Level.umap b/Content/Levels/Sergio_Level.umap index 8d2aeab..1083dd4 100644 --- a/Content/Levels/Sergio_Level.umap +++ b/Content/Levels/Sergio_Level.umap Binary files differ diff --git a/Content/PlaneTest/Missile.uasset b/Content/PlaneTest/Missile.uasset index 84ddcc4..bae5632 100644 --- a/Content/PlaneTest/Missile.uasset +++ b/Content/PlaneTest/Missile.uasset Binary files differ diff --git a/Content/PlaneTest/Targets_BP.uasset b/Content/PlaneTest/Targets_BP.uasset index abf0d91..29f1c42 100644 --- a/Content/PlaneTest/Targets_BP.uasset +++ b/Content/PlaneTest/Targets_BP.uasset Binary files differ diff --git a/SkyFrontier.uproject b/SkyFrontier.uproject index cb72138..1e6d8c8 100644 --- a/SkyFrontier.uproject +++ b/SkyFrontier.uproject @@ -7,30 +7,16 @@ { "Name": "SkyFrontier", "Type": "Runtime", - "LoadingPhase": "Default" + "LoadingPhase": "Default", + "AdditionalDependencies": [ + "Engine" + ] } ], "Plugins": [ { "Name": "RawInput", "Enabled": true - }, - { - "Name": "UniversalCameraPlugin", - "Enabled": true, - "MarketplaceURL": "com.epicgames.launcher://ue/marketplace/product/a9172fdfc87c464eae3a49860ee2610f" - }, - { - "Name": "Landmass", - "Enabled": true - }, - { - "Name": "Water", - "Enabled": true - }, - { - "Name": "ShallowWater", - "Enabled": true } ] } \ No newline at end of file diff --git a/Source/SkyFrontier/Private/HealthSystem.cpp b/Source/SkyFrontier/Private/HealthSystem.cpp new file mode 100644 index 0000000..aacb077 --- /dev/null +++ b/Source/SkyFrontier/Private/HealthSystem.cpp @@ -0,0 +1,64 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "HealthSystem.h" + +UHealthSystem::UHealthSystem() +{ + // This is a component that doesn't need a tick so lets disable it + PrimaryComponentTick.bCanEverTick = false; + PrimaryComponentTick.bStartWithTickEnabled = false; +} + +void UHealthSystem::BeginPlay() +{ + Super::BeginPlay(); + + // This is here for now, but if you ever do anything serialization related you might not want this. + Health = MaxHealth; +} + +float UHealthSystem::GetHealth() const +{ + return Health; +} + +float UHealthSystem::GetMaxHealth() const +{ + return MaxHealth; +} + +float UHealthSystem::GetHealthAsPercentage() const +{ + return Health / MaxHealth; +} + +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) + { + Health -= Amount; + + OnDamageTakenEvent.Broadcast(Amount); + } +} + +void UHealthSystem::RecoverHealth(const float Amount) +{ + if(Amount > 0) + { + Health += Amount; + + OnDamageHealedEvent.Broadcast(Amount); + } +} \ No newline at end of file diff --git a/Source/SkyFrontier/Public/HealthSystem.h b/Source/SkyFrontier/Public/HealthSystem.h new file mode 100644 index 0000000..2e0e911 --- /dev/null +++ b/Source/SkyFrontier/Public/HealthSystem.h @@ -0,0 +1,52 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Components/ActorComponent.h" +#include "HealthSystem.generated.h" + +DECLARE_EVENT_OneParam(UCPP_HealthComponent, DamageTakenEvent, float ) +DECLARE_EVENT_OneParam(UCPP_HealthComponent, HealDamageEvent, float ) + +UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +class SKYFRONTIER_API UHealthSystem : public UActorComponent +{ + GENERATED_BODY() + +public: + // Sets default values for this component's properties + UHealthSystem(); + + UFUNCTION(BlueprintPure) + float GetHealth() const; + UFUNCTION(BlueprintPure) + float GetMaxHealth() const; + UFUNCTION(BlueprintPure) + float GetHealthAsPercentage() const; + + UFUNCTION(BlueprintCallable) + void ModifyHealth(float Amount); + + UFUNCTION(BlueprintCallable) + void TakeDamage(float Amount); + UFUNCTION(BlueprintCallable) + void RecoverHealth(float Amount); + +protected: // Functions + + virtual void BeginPlay() override; + +public: // Events + + DamageTakenEvent OnDamageTakenEvent; + HealDamageEvent OnDamageHealedEvent; + +private: // This can be protected if we want to subclass the Health Component + + UPROPERTY(VisibleAnywhere) + float Health; + UPROPERTY(EditAnywhere) + float MaxHealth; + +};