Create PlayerHUDWidget
This commit is contained in:
parent
771f85bc13
commit
dc9339ef90
BIN
Content/UI/WidgetHUD.uasset (Stored with Git LFS)
BIN
Content/UI/WidgetHUD.uasset (Stored with Git LFS)
Binary file not shown.
|
@ -11,7 +11,8 @@
|
|||
"AdditionalDependencies": [
|
||||
"Engine",
|
||||
"FieldSystemEngine",
|
||||
"AIModule"
|
||||
"AIModule",
|
||||
"UMG"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
|
@ -211,6 +211,7 @@ int ANakatomiCharacter::GetCurrentInventorySlot()
|
|||
|
||||
void ANakatomiCharacter::OnFire()
|
||||
{
|
||||
OnFired.ExecuteIfBound();
|
||||
}
|
||||
|
||||
void ANakatomiCharacter::CalculateHits(TArray<FHitResult>* hits)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -479,6 +479,8 @@ void APlayerCharacter::OnFire()
|
|||
{
|
||||
RemoveCurrentWeaponFromInventory();
|
||||
}
|
||||
|
||||
Super::OnFire();
|
||||
}
|
||||
|
||||
void APlayerCharacter::WeaponCooldownHandler()
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
}
|
|
@ -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;
|
||||
};
|
Loading…
Reference in New Issue