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);
|
||||
|
||||
DOREPLIFETIME_CONDITION(ABlasterCharacter, OverlappingWeapon, COND_OwnerOnly);
|
||||
DOREPLIFETIME(ABlasterCharacter, Health);
|
||||
}
|
||||
|
||||
void ABlasterCharacter::OnRep_ReplicatedMovement()
|
||||
|
@ -401,6 +402,11 @@ float ABlasterCharacter::CalculateSpeed()
|
|||
return Velocity.Size();
|
||||
}
|
||||
|
||||
void ABlasterCharacter::OnRep_Health()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ABlasterCharacter::SetOverlappingWeapon(AWeapon* Weapon)
|
||||
{
|
||||
if (OverlappingWeapon)
|
||||
|
|
|
@ -93,6 +93,17 @@ private:
|
|||
float TimeSinceLastMovementReplication;
|
||||
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:
|
||||
void SetOverlappingWeapon(AWeapon* Weapon);
|
||||
bool IsWeaponEquipped();
|
||||
|
|
|
@ -3,6 +3,26 @@
|
|||
|
||||
#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()
|
||||
{
|
||||
Super::DrawHUD();
|
||||
|
|
|
@ -32,6 +32,16 @@ class BLASTER_API ABlasterHUD : public AHUD
|
|||
public:
|
||||
virtual void DrawHUD() override;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Player Stats")
|
||||
TSubclassOf<class UUserWidget> CharacterOverlayClass;
|
||||
|
||||
class UCharacterOverlay* CharacterOverlay;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void BeginPlay() override;
|
||||
void AddCharacterOverlay();
|
||||
|
||||
private:
|
||||
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