diff --git a/Content/Assets/Sounds/Pickups/Pickup_Shield_Cue.uasset b/Content/Assets/Sounds/Pickups/Pickup_Shield_Cue.uasset new file mode 100644 index 0000000..3922e2b Binary files /dev/null and b/Content/Assets/Sounds/Pickups/Pickup_Shield_Cue.uasset differ diff --git a/Content/Assets/Sounds/Pickups/Special_Powerup_01_wav.uasset b/Content/Assets/Sounds/Pickups/Special_Powerup_01_wav.uasset new file mode 100644 index 0000000..0a2cd1b Binary files /dev/null and b/Content/Assets/Sounds/Pickups/Special_Powerup_01_wav.uasset differ diff --git a/Content/Assets/sA_PickupSet_1/Fx/NiagaraSystems/NS_Pickup_4.uasset b/Content/Assets/sA_PickupSet_1/Fx/NiagaraSystems/NS_Pickup_4.uasset index a5d967d..052021d 100644 Binary files a/Content/Assets/sA_PickupSet_1/Fx/NiagaraSystems/NS_Pickup_4.uasset and b/Content/Assets/sA_PickupSet_1/Fx/NiagaraSystems/NS_Pickup_4.uasset differ diff --git a/Content/Assets/sA_PickupSet_1/Fx/NiagaraSystems/NS_Shielding_1.uasset b/Content/Assets/sA_PickupSet_1/Fx/NiagaraSystems/NS_Shielding_1.uasset new file mode 100644 index 0000000..bed343a Binary files /dev/null and b/Content/Assets/sA_PickupSet_1/Fx/NiagaraSystems/NS_Shielding_1.uasset differ diff --git a/Content/Blueprints/Pickups/Buff/BP_ShieldPickup.uasset b/Content/Blueprints/Pickups/Buff/BP_ShieldPickup.uasset new file mode 100644 index 0000000..fbc0b06 Binary files /dev/null and b/Content/Blueprints/Pickups/Buff/BP_ShieldPickup.uasset differ diff --git a/Content/Maps/BlasterMap.umap b/Content/Maps/BlasterMap.umap index 4ccb630..0d213bd 100644 Binary files a/Content/Maps/BlasterMap.umap and b/Content/Maps/BlasterMap.umap differ diff --git a/Source/Blaster/Character/BlasterCharacter.h b/Source/Blaster/Character/BlasterCharacter.h index f4b6df5..7dbcddf 100644 --- a/Source/Blaster/Character/BlasterCharacter.h +++ b/Source/Blaster/Character/BlasterCharacter.h @@ -154,8 +154,8 @@ private: UPROPERTY(EditAnywhere, Category= "Player Stats") float MaxShield = 100.f; - UPROPERTY(ReplicatedUsing = OnRep_Shield, VisibleAnywhere, Category= "Player Stats") - float Shield = 50.f; + UPROPERTY(ReplicatedUsing = OnRep_Shield, EditAnywhere, Category= "Player Stats") + float Shield = 0.f; UFUNCTION() void OnRep_Shield(float LastShield); @@ -221,6 +221,9 @@ public: FORCEINLINE float GetHealth() const { return Health; } FORCEINLINE void SetHealth(float Amount) { Health = Amount; } FORCEINLINE float GetMaxHealth() const { return MaxHealth; } + FORCEINLINE float GetShield() const { return Shield; } + FORCEINLINE void SetShield(float Amount) { Shield = Amount; } + FORCEINLINE float GetMaxShield() const { return MaxShield; } ECombatState GetCombatState() const; FORCEINLINE UCombatComponent* GetCombat() const { return Combat; } FORCEINLINE UBuffComponent* GetBuff() const { return Buff; } diff --git a/Source/Blaster/Components/BuffComponent.cpp b/Source/Blaster/Components/BuffComponent.cpp index c25a737..4bd6207 100644 --- a/Source/Blaster/Components/BuffComponent.cpp +++ b/Source/Blaster/Components/BuffComponent.cpp @@ -18,6 +18,13 @@ void UBuffComponent::Heal(float HealAmount, float HealingTime) AmountToHeal += HealAmount; } +void UBuffComponent::ReplenishShield(float ShieldAmount, float ReplenishTime) +{ + bReplenishingShield = true; + ShieldReplenishRate = ShieldAmount / ReplenishTime; + ShieldReplenishAmount += ShieldAmount; +} + void UBuffComponent::BeginPlay() { Super::BeginPlay(); @@ -28,6 +35,7 @@ void UBuffComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorC Super::TickComponent(DeltaTime, TickType, ThisTickFunction); HealRampUp(DeltaTime); + ShieldRampUp(DeltaTime); } @@ -47,6 +55,22 @@ void UBuffComponent::HealRampUp(float DeltaTime) } } +void UBuffComponent::ShieldRampUp(float DeltaTime) +{ + if (!bReplenishingShield || Character == nullptr || Character->IsEliminated()) return; + + const float ReplenishThisFrame = ShieldReplenishRate * DeltaTime; + Character->SetShield(FMath::Clamp(Character->GetShield() + ReplenishThisFrame, 0, Character->GetMaxShield())); + Character->UpdateHUDShield(); + ShieldReplenishAmount -= ReplenishThisFrame; + + if (ShieldReplenishAmount <= 0 || Character->GetShield() >= Character->GetMaxShield()) + { + bReplenishingShield = false; + ShieldReplenishAmount = 0.f; + } +} + void UBuffComponent::BuffSpeed(float BuffBaseSpeed, float BuffCrouchSpeed, float BuffTime) { if (Character == nullptr) return; diff --git a/Source/Blaster/Components/BuffComponent.h b/Source/Blaster/Components/BuffComponent.h index 5b4e5f1..3fa97f1 100644 --- a/Source/Blaster/Components/BuffComponent.h +++ b/Source/Blaster/Components/BuffComponent.h @@ -17,6 +17,7 @@ public: friend class ABlasterCharacter; void Heal(float HealAmount, float HealingTime); + void ReplenishShield(float ShieldAmount, float ReplenishTime); void BuffSpeed(float BuffBaseSpeed, float BuffCrouchSpeed, float BuffTime); void BuffJump(float BuffJumpVelocity, float BuffTime); void SetInitialSpeeds(float BaseSpeed, float CrouchSpeed); @@ -24,6 +25,7 @@ public: protected: virtual void BeginPlay() override; void HealRampUp(float DeltaTime); + void ShieldRampUp(float DeltaTime); private: UPROPERTY() @@ -34,6 +36,11 @@ private: float HealingRate = 0; float AmountToHeal = 0.f; + // Shield Buff + bool bReplenishingShield = false; + float ShieldReplenishRate = 0; + float ShieldReplenishAmount = 0.f; + // Speed Buff FTimerHandle SpeedBuffTimer; void ResetSpeeds(); diff --git a/Source/Blaster/Pickups/HealthPickup.h b/Source/Blaster/Pickups/HealthPickup.h index cba445d..e0da305 100644 --- a/Source/Blaster/Pickups/HealthPickup.h +++ b/Source/Blaster/Pickups/HealthPickup.h @@ -32,6 +32,6 @@ private: float HealAmount = 100.f; UPROPERTY(EditAnywhere) - float HealingTime = 5.f; + float HealingTime = 2.f; }; diff --git a/Source/Blaster/Pickups/ShieldPickup.cpp b/Source/Blaster/Pickups/ShieldPickup.cpp new file mode 100644 index 0000000..e182de0 --- /dev/null +++ b/Source/Blaster/Pickups/ShieldPickup.cpp @@ -0,0 +1,25 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "ShieldPickup.h" + +#include "Blaster/Character/BlasterCharacter.h" +#include "Blaster/Components/BuffComponent.h" + +void AShieldPickup::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, + bool bFromSweep, const FHitResult& SweepResult) +{ + Super::OnSphereOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult); + + ABlasterCharacter* BlasterCharacter = Cast(OtherActor); + if (BlasterCharacter) + { + UBuffComponent* Buff = BlasterCharacter->GetBuff(); + if (Buff) + { + Buff->ReplenishShield(ShieldReplenishAmount, ShieldReplenishTime); + } + } + + Destroy(); +} diff --git a/Source/Blaster/Pickups/ShieldPickup.h b/Source/Blaster/Pickups/ShieldPickup.h new file mode 100644 index 0000000..b3132c6 --- /dev/null +++ b/Source/Blaster/Pickups/ShieldPickup.h @@ -0,0 +1,35 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Pickup.h" +#include "ShieldPickup.generated.h" + +/** + * + */ +UCLASS() +class BLASTER_API AShieldPickup : public APickup +{ + GENERATED_BODY() + + +protected: + virtual void OnSphereOverlap( + UPrimitiveComponent* OverlappedComponent, + AActor* OtherActor, + UPrimitiveComponent* OtherComp, + int32 OtherBodyIndex, + bool bFromSweep, + const FHitResult& SweepResult + ) override; + +private: + UPROPERTY(EditAnywhere) + float ShieldReplenishAmount = 100.f; + + UPROPERTY(EditAnywhere) + float ShieldReplenishTime = 2.f; + +};