159 - Jump Buffs
This commit is contained in:
parent
1f473d78ce
commit
81ae27f9fb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -257,6 +257,7 @@ void ABlasterCharacter::PostInitializeComponents()
|
|||
{
|
||||
Buff->Character = this;
|
||||
Buff->SetInitialSpeeds(GetCharacterMovement()->MaxWalkSpeed, GetCharacterMovement()->MaxWalkSpeedCrouched);
|
||||
Buff->SetInitialJumpVelocity(GetCharacterMovement()->JumpZVelocity);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
UBuffComponent::UBuffComponent()
|
||||
{
|
||||
PrimaryComponentTick.bCanEverTick = true;
|
||||
|
||||
}
|
||||
|
||||
void UBuffComponent::Heal(float HealAmount, float HealingTime)
|
||||
|
@ -22,7 +21,6 @@ void UBuffComponent::Heal(float HealAmount, float HealingTime)
|
|||
void UBuffComponent::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
}
|
||||
|
||||
void UBuffComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||
|
@ -70,7 +68,7 @@ void UBuffComponent::BuffSpeed(float BuffBaseSpeed, float BuffCrouchSpeed, float
|
|||
|
||||
void UBuffComponent::MulticastSpeedBuff_Implementation(float BaseSpeed, float CrouchSpeed)
|
||||
{
|
||||
if (Character->GetCharacterMovement())
|
||||
if (Character && Character->GetCharacterMovement())
|
||||
{
|
||||
Character->GetCharacterMovement()->MaxWalkSpeed = BaseSpeed;
|
||||
Character->GetCharacterMovement()->MaxWalkSpeedCrouched = CrouchSpeed;
|
||||
|
@ -92,3 +90,43 @@ void UBuffComponent::SetInitialSpeeds(float BaseSpeed, float CrouchSpeed)
|
|||
InitialBaseSpeed = BaseSpeed;
|
||||
InitialCrouchSpeed = CrouchSpeed;
|
||||
}
|
||||
|
||||
void UBuffComponent::SetInitialJumpVelocity(float Velocity)
|
||||
{
|
||||
InitialJumpZVelocity = Velocity;
|
||||
}
|
||||
|
||||
void UBuffComponent::BuffJump(float BuffJumpVelocity, float BuffTime)
|
||||
{
|
||||
if (Character == nullptr) return;
|
||||
|
||||
Character->GetWorldTimerManager().SetTimer(
|
||||
JumpBuffTimer,
|
||||
this,
|
||||
&UBuffComponent::ResetJump,
|
||||
BuffTime
|
||||
);
|
||||
|
||||
if (Character->GetCharacterMovement())
|
||||
{
|
||||
Character->GetCharacterMovement()->JumpZVelocity = BuffJumpVelocity;
|
||||
MulticastJumpBuff(BuffJumpVelocity);
|
||||
}
|
||||
}
|
||||
|
||||
void UBuffComponent::MulticastJumpBuff_Implementation(float JumpVelocity)
|
||||
{
|
||||
if (Character && Character->GetCharacterMovement())
|
||||
{
|
||||
Character->GetCharacterMovement()->JumpZVelocity = JumpVelocity;
|
||||
}
|
||||
}
|
||||
|
||||
void UBuffComponent::ResetJump()
|
||||
{
|
||||
if (Character && Character->GetCharacterMovement())
|
||||
{
|
||||
Character->GetCharacterMovement()->JumpZVelocity = InitialJumpZVelocity;
|
||||
MulticastJumpBuff(InitialJumpZVelocity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,9 @@ public:
|
|||
|
||||
void Heal(float HealAmount, float HealingTime);
|
||||
void BuffSpeed(float BuffBaseSpeed, float BuffCrouchSpeed, float BuffTime);
|
||||
void BuffJump(float BuffJumpVelocity, float BuffTime);
|
||||
void SetInitialSpeeds(float BaseSpeed, float CrouchSpeed);
|
||||
void SetInitialJumpVelocity(float Velocity);
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
void HealRampUp(float DeltaTime);
|
||||
|
@ -40,6 +42,16 @@ private:
|
|||
|
||||
UFUNCTION(NetMulticast, Reliable)
|
||||
void MulticastSpeedBuff(float BaseSpeed, float CrouchSpeed);
|
||||
|
||||
// Jump Buff
|
||||
|
||||
FTimerHandle JumpBuffTimer;
|
||||
void ResetJump();
|
||||
float InitialJumpZVelocity;
|
||||
|
||||
UFUNCTION(NetMulticast, Reliable)
|
||||
void MulticastJumpBuff(float JumpVelocity);
|
||||
|
||||
public:
|
||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "JumpPickup.h"
|
||||
|
||||
#include "Blaster/Character/BlasterCharacter.h"
|
||||
#include "Blaster/Components/BuffComponent.h"
|
||||
|
||||
void AJumpPickup::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->BuffJump(JumpZVelocity, JumpBuffTime);
|
||||
}
|
||||
}
|
||||
|
||||
Destroy();
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Pickup.h"
|
||||
#include "JumpPickup.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class BLASTER_API AJumpPickup : 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 JumpZVelocity = 2500.f;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
float JumpBuffTime = 10.f;
|
||||
};
|
Loading…
Reference in New Issue