diff --git a/Content/Player/BP_PlayerController.uasset b/Content/Player/BP_PlayerController.uasset index 6a0aef6..4ac80b2 100644 --- a/Content/Player/BP_PlayerController.uasset +++ b/Content/Player/BP_PlayerController.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:90c5d083c153bc87a9aa35bf43e295c3cb0c7a543a6f0df01d6520e19d7b513e -size 20100 +oid sha256:007440e1bd913da562949c38f8cb50f63205a06def3724a2baf46529333da525 +size 20571 diff --git a/Content/Widgets/HUD/BP_HUDWidget.uasset b/Content/Widgets/HUD/BP_HUDWidget.uasset index 17101d7..1c881b1 100644 --- a/Content/Widgets/HUD/BP_HUDWidget.uasset +++ b/Content/Widgets/HUD/BP_HUDWidget.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c59c729edd4c86eadb9f563f428825660546673fa2ac8b9b7d2fa14b121d9f53 -size 165091 +oid sha256:26c446db9c13f15d492cff4807e3319e2a07686b73310833dd28b3b8f5e75579 +size 154070 diff --git a/Source/vampires/VampirePlayerController.cpp b/Source/vampires/VampirePlayerController.cpp index 69591c7..be47cc3 100644 --- a/Source/vampires/VampirePlayerController.cpp +++ b/Source/vampires/VampirePlayerController.cpp @@ -4,6 +4,7 @@ #include "VampirePlayerController.h" #include "EXPComponent.h" +#include "HealthComponent.h" #include "Blueprint/UserWidget.h" #include "Widgets/HUDWidget.h" @@ -15,6 +16,12 @@ void AVampirePlayerController::OnPossess(APawn* aPawn) { currentPlayerHUD = CreateWidget(this, PlayerHUD.Get()); + if (UEXPComponent* expComponent = aPawn->GetComponentByClass()) + { + expComponent->OnEXPGained.AddUniqueDynamic(this, &AVampirePlayerController::UpdatePlayerEXPHUD); + UpdatePlayerEXPHUD(expComponent->GetCurrentEXP(), expComponent->GetCurrentLevelPercent()); + } + if (currentPlayerHUD) { currentPlayerHUD->AddToViewport(); @@ -22,3 +29,10 @@ void AVampirePlayerController::OnPossess(APawn* aPawn) } } +void AVampirePlayerController::UpdatePlayerEXPHUD(int exp, float currentLevelPercent) +{ + if (currentPlayerHUD) + { + currentPlayerHUD->UpdateEXPBar(currentLevelPercent); + } +} diff --git a/Source/vampires/VampirePlayerController.h b/Source/vampires/VampirePlayerController.h index e4330a7..41a0614 100644 --- a/Source/vampires/VampirePlayerController.h +++ b/Source/vampires/VampirePlayerController.h @@ -27,4 +27,6 @@ private: protected: virtual void OnPossess(APawn* aPawn) override; + UFUNCTION() + void UpdatePlayerEXPHUD(int exp, float currentLevelPercent); }; diff --git a/Source/vampires/Widgets/HUDWidget.cpp b/Source/vampires/Widgets/HUDWidget.cpp index 6967883..25dd251 100644 --- a/Source/vampires/Widgets/HUDWidget.cpp +++ b/Source/vampires/Widgets/HUDWidget.cpp @@ -3,3 +3,21 @@ #include "HUDWidget.h" +#include "Components/ProgressBar.h" + +void UHUDWidget::Init() +{ +} + +void UHUDWidget::UpdateEXPBar(float currentLevelPercent) +{ + EXPbar->SetPercent(currentLevelPercent); +} + +void UHUDWidget::UpdateLevelBlock() +{ +} + +void UHUDWidget::UpdateTimerBlock() +{ +} diff --git a/Source/vampires/Widgets/HUDWidget.h b/Source/vampires/Widgets/HUDWidget.h index 1a5b611..cc515c2 100644 --- a/Source/vampires/Widgets/HUDWidget.h +++ b/Source/vampires/Widgets/HUDWidget.h @@ -15,7 +15,7 @@ UCLASS() class VAMPIRES_API UHUDWidget : public UUserWidget { GENERATED_BODY() - + public: UPROPERTY(BlueprintReadWrite, meta = (BindWidget)) @@ -26,5 +26,16 @@ public: UPROPERTY(BlueprintReadWrite, meta = (BindWidget)) UTextBlock* TimerBLock; + + void Init(); + + UFUNCTION() + void UpdateEXPBar(float currentLevelPercent); + + UFUNCTION() + void UpdateLevelBlock(); + + UFUNCTION() + void UpdateTimerBlock(); };