diff --git a/Content/Player/BP_PlayerCharacter.uasset b/Content/Player/BP_PlayerCharacter.uasset index 834d39e..786a5e9 100644 --- a/Content/Player/BP_PlayerCharacter.uasset +++ b/Content/Player/BP_PlayerCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8d8fc8e0fd6387f12f21f06afa6c121edddbf727d178e4a42a408276612d567a -size 51794 +oid sha256:bcce95e6c31b5dd49f80544da18520f420886f763d1ee74466c0eab9002a253f +size 51902 diff --git a/Content/Widgets/HUD/BP_HUDWidget.uasset b/Content/Widgets/HUD/BP_HUDWidget.uasset new file mode 100644 index 0000000..ab375ab --- /dev/null +++ b/Content/Widgets/HUD/BP_HUDWidget.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4a839e166e06f4c9a4d9cb47442799df7d7bdbaa63d994fc5ace865acfef3b9e +size 129195 diff --git a/Source/vampires/EXPComponent.h b/Source/vampires/EXPComponent.h index a593516..4245f00 100644 --- a/Source/vampires/EXPComponent.h +++ b/Source/vampires/EXPComponent.h @@ -27,19 +27,19 @@ public: // Sets default values for this component's properties UEXPComponent(); - UFUNCTION() + UFUNCTION(BlueprintCallable) void IncrementEXP(int value); - UFUNCTION() + UFUNCTION(BlueprintCallable) void SetCurrentEXP(int value); - UFUNCTION() + UFUNCTION(BlueprintCallable, BlueprintPure) int GetCurrentEXP(); - UFUNCTION() + UFUNCTION(BlueprintCallable, BlueprintPure) int GetCurrentLevel(); - UFUNCTION() + UFUNCTION(BlueprintCallable) void Reset(); protected: diff --git a/Source/vampires/PlayerCharacter.cpp b/Source/vampires/PlayerCharacter.cpp index f09b1b2..0fa9648 100644 --- a/Source/vampires/PlayerCharacter.cpp +++ b/Source/vampires/PlayerCharacter.cpp @@ -40,6 +40,16 @@ APlayerCharacter::APlayerCharacter() void APlayerCharacter::BeginPlay() { Super::BeginPlay(); + + if (PlayerHUD) + { + currentPlayerHUD = UUserWidget::CreateWidgetInstance(*GetWorld(), PlayerHUD, FName("Player HUD")); + + if (currentPlayerHUD) + { + currentPlayerHUD->AddToViewport(); + } + } } void APlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) diff --git a/Source/vampires/PlayerCharacter.h b/Source/vampires/PlayerCharacter.h index 4604d8d..a9f41cd 100644 --- a/Source/vampires/PlayerCharacter.h +++ b/Source/vampires/PlayerCharacter.h @@ -9,6 +9,7 @@ #include "WeaponInventoryComponent.h" #include "Camera/CameraComponent.h" #include "GameFramework/SpringArmComponent.h" +#include "Blueprint/UserWidget.h" #include "PlayerCharacter.generated.h" class UInputMappingContext; @@ -46,9 +47,14 @@ public: FVector2D PreviousMovementDirection = FVector2d(1.0f, 0.0f); + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + TSubclassOf PlayerHUD = nullptr; + private: FTimerHandle GarlicTimerHandle; + UUserWidget* currentPlayerHUD = nullptr; + public: APlayerCharacter(); diff --git a/Source/vampires/Widgets/HUDWidget.cpp b/Source/vampires/Widgets/HUDWidget.cpp new file mode 100644 index 0000000..6967883 --- /dev/null +++ b/Source/vampires/Widgets/HUDWidget.cpp @@ -0,0 +1,5 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "HUDWidget.h" + diff --git a/Source/vampires/Widgets/HUDWidget.h b/Source/vampires/Widgets/HUDWidget.h new file mode 100644 index 0000000..7cf0359 --- /dev/null +++ b/Source/vampires/Widgets/HUDWidget.h @@ -0,0 +1,30 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Blueprint/UserWidget.h" +#include "Components/ProgressBar.h" +#include "Components/TextBlock.h" +#include "HUDWidget.generated.h" + +/** + * + */ +UCLASS() +class VAMPIRES_API UHUDWidget : public UUserWidget +{ + GENERATED_BODY() + +public: + + UPROPERTY(BlueprintReadWrite, meta = (BindWidget)) + UProgressBar* EXPbar; + + UPROPERTY(BlueprintReadWrite, meta = (BindWidget)) + UTextBlock* LevelBlock; + + UPROPERTY(BlueprintReadWrite, meta = (BindWidget)) + UTextBlock* TimerBLock; + +}; diff --git a/vampires.uproject b/vampires.uproject index 31f8750..0b63e47 100644 --- a/vampires.uproject +++ b/vampires.uproject @@ -10,7 +10,8 @@ "LoadingPhase": "Default", "AdditionalDependencies": [ "Engine", - "AIModule" + "AIModule", + "UMG" ] } ],