95 - Health
This commit is contained in:
parent
4ef9d3306a
commit
ce6d62f323
Binary file not shown.
Binary file not shown.
|
@ -53,6 +53,7 @@ void ABlasterCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& Ou
|
||||||
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||||
|
|
||||||
DOREPLIFETIME_CONDITION(ABlasterCharacter, OverlappingWeapon, COND_OwnerOnly);
|
DOREPLIFETIME_CONDITION(ABlasterCharacter, OverlappingWeapon, COND_OwnerOnly);
|
||||||
|
DOREPLIFETIME(ABlasterCharacter, Health);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ABlasterCharacter::OnRep_ReplicatedMovement()
|
void ABlasterCharacter::OnRep_ReplicatedMovement()
|
||||||
|
@ -401,6 +402,11 @@ float ABlasterCharacter::CalculateSpeed()
|
||||||
return Velocity.Size();
|
return Velocity.Size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ABlasterCharacter::OnRep_Health()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void ABlasterCharacter::SetOverlappingWeapon(AWeapon* Weapon)
|
void ABlasterCharacter::SetOverlappingWeapon(AWeapon* Weapon)
|
||||||
{
|
{
|
||||||
if (OverlappingWeapon)
|
if (OverlappingWeapon)
|
||||||
|
|
|
@ -92,6 +92,17 @@ private:
|
||||||
float ProxyYaw;
|
float ProxyYaw;
|
||||||
float TimeSinceLastMovementReplication;
|
float TimeSinceLastMovementReplication;
|
||||||
float CalculateSpeed();
|
float CalculateSpeed();
|
||||||
|
|
||||||
|
// Health
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category= "Player Stats")
|
||||||
|
float MaxHealth = 100.f;
|
||||||
|
|
||||||
|
UPROPERTY(ReplicatedUsing = OnRep_Health, VisibleAnywhere, Category= "Player Stats")
|
||||||
|
float Health = 100.f;
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void OnRep_Health();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void SetOverlappingWeapon(AWeapon* Weapon);
|
void SetOverlappingWeapon(AWeapon* Weapon);
|
||||||
|
|
|
@ -3,6 +3,26 @@
|
||||||
|
|
||||||
#include "BlasterHUD.h"
|
#include "BlasterHUD.h"
|
||||||
|
|
||||||
|
#include "CharacterOverlay.h"
|
||||||
|
#include "Blueprint/UserWidget.h"
|
||||||
|
|
||||||
|
void ABlasterHUD::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
AddCharacterOverlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ABlasterHUD::AddCharacterOverlay()
|
||||||
|
{
|
||||||
|
APlayerController* PlayerController = GetOwningPlayerController();
|
||||||
|
if (PlayerController && CharacterOverlayClass)
|
||||||
|
{
|
||||||
|
CharacterOverlay = CreateWidget<UCharacterOverlay>(PlayerController, CharacterOverlayClass);
|
||||||
|
CharacterOverlay->AddToViewport();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ABlasterHUD::DrawHUD()
|
void ABlasterHUD::DrawHUD()
|
||||||
{
|
{
|
||||||
Super::DrawHUD();
|
Super::DrawHUD();
|
||||||
|
|
|
@ -32,6 +32,16 @@ class BLASTER_API ABlasterHUD : public AHUD
|
||||||
public:
|
public:
|
||||||
virtual void DrawHUD() override;
|
virtual void DrawHUD() override;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Player Stats")
|
||||||
|
TSubclassOf<class UUserWidget> CharacterOverlayClass;
|
||||||
|
|
||||||
|
class UCharacterOverlay* CharacterOverlay;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
void AddCharacterOverlay();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FHUDPackage HUDPackage;
|
FHUDPackage HUDPackage;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "CharacterOverlay.h"
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Blueprint/UserWidget.h"
|
||||||
|
#include "CharacterOverlay.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class BLASTER_API UCharacterOverlay : public UUserWidget
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
class UProgressBar* HealthBar;
|
||||||
|
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
class UTextBlock* HealthText;
|
||||||
|
|
||||||
|
};
|
Loading…
Reference in New Issue