158 - Speed Buffs
This commit is contained in:
parent
babbfda3cf
commit
1f473d78ce
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -256,6 +256,7 @@ void ABlasterCharacter::PostInitializeComponents()
|
||||||
if (Buff)
|
if (Buff)
|
||||||
{
|
{
|
||||||
Buff->Character = this;
|
Buff->Character = this;
|
||||||
|
Buff->SetInitialSpeeds(GetCharacterMovement()->MaxWalkSpeed, GetCharacterMovement()->MaxWalkSpeedCrouched);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "BuffComponent.h"
|
#include "BuffComponent.h"
|
||||||
|
|
||||||
#include "Blaster/Character/BlasterCharacter.h"
|
#include "Blaster/Character/BlasterCharacter.h"
|
||||||
|
#include "GameFramework/CharacterMovementComponent.h"
|
||||||
|
|
||||||
UBuffComponent::UBuffComponent()
|
UBuffComponent::UBuffComponent()
|
||||||
{
|
{
|
||||||
|
@ -18,13 +19,20 @@ void UBuffComponent::Heal(float HealAmount, float HealingTime)
|
||||||
AmountToHeal += HealAmount;
|
AmountToHeal += HealAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UBuffComponent::BeginPlay()
|
void UBuffComponent::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UBuffComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||||
|
{
|
||||||
|
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||||
|
|
||||||
|
HealRampUp(DeltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void UBuffComponent::HealRampUp(float DeltaTime)
|
void UBuffComponent::HealRampUp(float DeltaTime)
|
||||||
{
|
{
|
||||||
if (!bHealing || Character == nullptr || Character->IsEliminated()) return;
|
if (!bHealing || Character == nullptr || Character->IsEliminated()) return;
|
||||||
|
@ -41,10 +49,46 @@ void UBuffComponent::HealRampUp(float DeltaTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UBuffComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
void UBuffComponent::BuffSpeed(float BuffBaseSpeed, float BuffCrouchSpeed, float BuffTime)
|
||||||
{
|
{
|
||||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
if (Character == nullptr) return;
|
||||||
|
|
||||||
HealRampUp(DeltaTime);
|
Character->GetWorldTimerManager().SetTimer(
|
||||||
|
SpeedBuffTimer,
|
||||||
|
this,
|
||||||
|
&UBuffComponent::ResetSpeeds,
|
||||||
|
BuffTime
|
||||||
|
);
|
||||||
|
|
||||||
|
if (Character->GetCharacterMovement())
|
||||||
|
{
|
||||||
|
Character->GetCharacterMovement()->MaxWalkSpeed = BuffBaseSpeed;
|
||||||
|
Character->GetCharacterMovement()->MaxWalkSpeedCrouched = BuffCrouchSpeed;
|
||||||
|
MulticastSpeedBuff(BuffBaseSpeed, BuffCrouchSpeed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UBuffComponent::MulticastSpeedBuff_Implementation(float BaseSpeed, float CrouchSpeed)
|
||||||
|
{
|
||||||
|
if (Character->GetCharacterMovement())
|
||||||
|
{
|
||||||
|
Character->GetCharacterMovement()->MaxWalkSpeed = BaseSpeed;
|
||||||
|
Character->GetCharacterMovement()->MaxWalkSpeedCrouched = CrouchSpeed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UBuffComponent::ResetSpeeds()
|
||||||
|
{
|
||||||
|
if (Character && Character->GetCharacterMovement())
|
||||||
|
{
|
||||||
|
Character->GetCharacterMovement()->MaxWalkSpeed = InitialBaseSpeed;
|
||||||
|
Character->GetCharacterMovement()->MaxWalkSpeedCrouched = InitialCrouchSpeed;
|
||||||
|
MulticastSpeedBuff(InitialBaseSpeed, InitialCrouchSpeed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UBuffComponent::SetInitialSpeeds(float BaseSpeed, float CrouchSpeed)
|
||||||
|
{
|
||||||
|
InitialBaseSpeed = BaseSpeed;
|
||||||
|
InitialCrouchSpeed = CrouchSpeed;
|
||||||
|
}
|
||||||
|
|
|
@ -17,7 +17,8 @@ public:
|
||||||
friend class ABlasterCharacter;
|
friend class ABlasterCharacter;
|
||||||
|
|
||||||
void Heal(float HealAmount, float HealingTime);
|
void Heal(float HealAmount, float HealingTime);
|
||||||
|
void BuffSpeed(float BuffBaseSpeed, float BuffCrouchSpeed, float BuffTime);
|
||||||
|
void SetInitialSpeeds(float BaseSpeed, float CrouchSpeed);
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
void HealRampUp(float DeltaTime);
|
void HealRampUp(float DeltaTime);
|
||||||
|
@ -26,12 +27,19 @@ private:
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
class ABlasterCharacter* Character;
|
class ABlasterCharacter* Character;
|
||||||
|
|
||||||
|
// Heal Buff
|
||||||
bool bHealing = false;
|
bool bHealing = false;
|
||||||
float HealingRate = 0;
|
float HealingRate = 0;
|
||||||
float AmountToHeal = 0.f;
|
float AmountToHeal = 0.f;
|
||||||
|
|
||||||
|
// Speed Buff
|
||||||
|
FTimerHandle SpeedBuffTimer;
|
||||||
|
void ResetSpeeds();
|
||||||
|
float InitialBaseSpeed;
|
||||||
|
float InitialCrouchSpeed;
|
||||||
|
|
||||||
|
UFUNCTION(NetMulticast, Reliable)
|
||||||
|
void MulticastSpeedBuff(float BaseSpeed, float CrouchSpeed);
|
||||||
public:
|
public:
|
||||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,16 +3,12 @@
|
||||||
|
|
||||||
#include "HealthPickup.h"
|
#include "HealthPickup.h"
|
||||||
|
|
||||||
#include "NiagaraComponent.h"
|
|
||||||
#include "NiagaraFunctionLibrary.h"
|
|
||||||
#include "Blaster/Character/BlasterCharacter.h"
|
#include "Blaster/Character/BlasterCharacter.h"
|
||||||
#include "Blaster/Components/BuffComponent.h"
|
#include "Blaster/Components/BuffComponent.h"
|
||||||
|
|
||||||
AHealthPickup::AHealthPickup()
|
AHealthPickup::AHealthPickup()
|
||||||
{
|
{
|
||||||
bReplicates = true;
|
bReplicates = true;
|
||||||
PickupEffectComponent = CreateDefaultSubobject<UNiagaraComponent>(TEXT("PickupEffectComponent"));
|
|
||||||
PickupEffectComponent->SetupAttachment(RootComponent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AHealthPickup::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex,
|
void AHealthPickup::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex,
|
||||||
|
@ -32,18 +28,3 @@ void AHealthPickup::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AA
|
||||||
|
|
||||||
Destroy();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AHealthPickup::Destroyed()
|
|
||||||
{
|
|
||||||
if (PickupEffect)
|
|
||||||
{
|
|
||||||
UNiagaraFunctionLibrary::SpawnSystemAtLocation(
|
|
||||||
this,
|
|
||||||
PickupEffect,
|
|
||||||
GetActorLocation(),
|
|
||||||
GetActorRotation()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Super::Destroyed();
|
|
||||||
}
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ class BLASTER_API AHealthPickup : public APickup
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AHealthPickup();
|
AHealthPickup();
|
||||||
virtual void Destroyed() override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void OnSphereOverlap(
|
virtual void OnSphereOverlap(
|
||||||
|
@ -35,10 +34,4 @@ private:
|
||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
float HealingTime = 5.f;
|
float HealingTime = 5.f;
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere)
|
|
||||||
class UNiagaraComponent* PickupEffectComponent;
|
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere)
|
|
||||||
class UNiagaraSystem* PickupEffect;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include "Pickup.h"
|
#include "Pickup.h"
|
||||||
|
|
||||||
|
#include "NiagaraComponent.h"
|
||||||
|
#include "NiagaraFunctionLibrary.h"
|
||||||
#include "Blaster/Weapon/WeaponTypes.h"
|
#include "Blaster/Weapon/WeaponTypes.h"
|
||||||
#include "Components/SphereComponent.h"
|
#include "Components/SphereComponent.h"
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
@ -29,6 +31,9 @@ APickup::APickup()
|
||||||
PickupMesh->SetRelativeScale3D(FVector(5.f, 5.f, 5.f));
|
PickupMesh->SetRelativeScale3D(FVector(5.f, 5.f, 5.f));
|
||||||
PickupMesh->SetRenderCustomDepth(true);
|
PickupMesh->SetRenderCustomDepth(true);
|
||||||
PickupMesh->SetCustomDepthStencilValue(CUSTOM_DEPTH_PURPLE);
|
PickupMesh->SetCustomDepthStencilValue(CUSTOM_DEPTH_PURPLE);
|
||||||
|
|
||||||
|
PickupEffectComponent = CreateDefaultSubobject<UNiagaraComponent>(TEXT("PickupEffectComponent"));
|
||||||
|
PickupEffectComponent->SetupAttachment(RootComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void APickup::BeginPlay()
|
void APickup::BeginPlay()
|
||||||
|
@ -69,5 +74,14 @@ void APickup::Destroyed()
|
||||||
GetActorLocation()
|
GetActorLocation()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (PickupEffect)
|
||||||
|
{
|
||||||
|
UNiagaraFunctionLibrary::SpawnSystemAtLocation(
|
||||||
|
this,
|
||||||
|
PickupEffect,
|
||||||
|
GetActorLocation(),
|
||||||
|
GetActorRotation()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,5 +42,10 @@ private:
|
||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
UStaticMeshComponent* PickupMesh;
|
UStaticMeshComponent* PickupMesh;
|
||||||
|
|
||||||
public:
|
UPROPERTY(VisibleAnywhere)
|
||||||
|
class UNiagaraComponent* PickupEffectComponent;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
class UNiagaraSystem* PickupEffect;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "SpeedPickup.h"
|
||||||
|
|
||||||
|
#include "Blaster/Character/BlasterCharacter.h"
|
||||||
|
#include "Blaster/Components/BuffComponent.h"
|
||||||
|
|
||||||
|
void ASpeedPickup::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<ABlasterCharacter>(OtherActor);
|
||||||
|
if (BlasterCharacter)
|
||||||
|
{
|
||||||
|
UBuffComponent* Buff = BlasterCharacter->GetBuff();
|
||||||
|
if (Buff)
|
||||||
|
{
|
||||||
|
Buff->BuffSpeed(BaseSpeedBuff, CrouchSpeedBuff, SpeedBuffTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Destroy();
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Pickup.h"
|
||||||
|
#include "SpeedPickup.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class BLASTER_API ASpeedPickup : 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 BaseSpeedBuff = 1600.f;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
float CrouchSpeedBuff = 850.f;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
float SpeedBuffTime = 30.f;
|
||||||
|
|
||||||
|
};
|
Loading…
Reference in New Issue