Create PlayerHUDWidget

This commit is contained in:
Louis Hobbs 2023-08-01 23:02:32 +01:00
parent 771f85bc13
commit dc9339ef90
7 changed files with 84 additions and 3 deletions

BIN
Content/UI/WidgetHUD.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -11,7 +11,8 @@
"AdditionalDependencies": [
"Engine",
"FieldSystemEngine",
"AIModule"
"AIModule",
"UMG"
]
}
],

View File

@ -211,6 +211,7 @@ int ANakatomiCharacter::GetCurrentInventorySlot()
void ANakatomiCharacter::OnFire()
{
OnFired.ExecuteIfBound();
}
void ANakatomiCharacter::CalculateHits(TArray<FHitResult>* hits)

View File

@ -8,6 +8,10 @@
#include "Weapon.h"
#include "NakatomiCharacter.generated.h"
DECLARE_DELEGATE(FOnFireDelegate)
/**
*
*/
@ -16,6 +20,10 @@ class NAKATOMI_API ANakatomiCharacter : public ACharacter
{
GENERATED_BODY()
public:
FOnFireDelegate OnFired;
public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TArray<TSubclassOf<class AWeapon>> DefaultWeaponInventory;

View File

@ -479,6 +479,8 @@ void APlayerCharacter::OnFire()
{
RemoveCurrentWeaponFromInventory();
}
Super::OnFire();
}
void APlayerCharacter::WeaponCooldownHandler()

View File

@ -0,0 +1,20 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "PlayerHUDWidget.h"
#include <Kismet/GameplayStatics.h>
#include "PlayerCharacter.h"
void UPlayerHUDWidget::NativeConstruct()
{
auto player = Cast<APlayerCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));
if (player)
{
player->OnFired.BindUFunction(this, "ExpandCrosshair");
}
}
void UPlayerHUDWidget::ExpandCrosshair()
{
}

View File

@ -0,0 +1,49 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include <Components/TextBlock.h>
#include <Components/Image.h>
#include "PlayerHUDWidget.generated.h"
/**
*
*/
UCLASS()
class NAKATOMI_API UPlayerHUDWidget : public UUserWidget
{
GENERATED_BODY()
public:
virtual void NativeConstruct() override;
UFUNCTION()
void ExpandCrosshair();
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UTextBlock* HealthText;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UTextBlock* AmmoText;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UTextBlock* AmmoStaticText;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UTextBlock* ProjectilesText;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UTextBlock* CooldownText;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UTextBlock* SpreadText;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UImage* CrosshairImage;
};