From a402de0781055426a5bbbb3d77006d3ced7d189d Mon Sep 17 00:00:00 2001 From: Louis Hobbs Date: Mon, 3 Jul 2023 20:05:31 +0100 Subject: [PATCH] Add new Weapon HUD UI --- Content/UI/WidgetHUD.uasset | 4 ++-- Source/Nakatomi/PlayerCharacter.cpp | 34 +++++++++++++++++++++++++++-- Source/Nakatomi/PlayerCharacter.h | 9 ++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/Content/UI/WidgetHUD.uasset b/Content/UI/WidgetHUD.uasset index 38e7c8f..d2ef768 100644 --- a/Content/UI/WidgetHUD.uasset +++ b/Content/UI/WidgetHUD.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d9f9fa7c114d0a2a43d994d503b61a2c79246bea1a6ef4bfe70d40b0c1ee2e6c -size 64644 +oid sha256:d5b4aff67a929712c453e2cc68f6894087dd4a549e1eac242da0fd924c888b70 +size 118095 diff --git a/Source/Nakatomi/PlayerCharacter.cpp b/Source/Nakatomi/PlayerCharacter.cpp index 4d136bf..5185cee 100644 --- a/Source/Nakatomi/PlayerCharacter.cpp +++ b/Source/Nakatomi/PlayerCharacter.cpp @@ -412,7 +412,7 @@ int APlayerCharacter::GetCurrentAmmoCount() { if (CurrentWeapon == nullptr) { - return -1; + return 0; } return CurrentWeapon->GetAmmoCount(); @@ -422,8 +422,38 @@ float APlayerCharacter::GetCurrentHealthCount() { if (!GetHealthComponent()) { - return -1; + return 0; } return GetHealthComponent()->GetCurrentHealth(); } + +int APlayerCharacter::GetWeaponProjectiles() +{ + if (CurrentWeapon == nullptr) + { + return 0; + } + + return CurrentWeapon->GetWeaponProperties()->ProjectilesPerShot; +} + +float APlayerCharacter::GetWeaponCooldown() +{ + if (CurrentWeapon == nullptr) + { + return 0; + } + + return CurrentWeapon->GetWeaponProperties()->WeaponCooldown; +} + +float APlayerCharacter::GetWeaponSpread() +{ + if (CurrentWeapon == nullptr) + { + return 0; + } + + return CurrentWeapon->GetWeaponProperties()->WeaponSpread; +} diff --git a/Source/Nakatomi/PlayerCharacter.h b/Source/Nakatomi/PlayerCharacter.h index df0d773..63b4bce 100644 --- a/Source/Nakatomi/PlayerCharacter.h +++ b/Source/Nakatomi/PlayerCharacter.h @@ -129,6 +129,15 @@ public: UFUNCTION(BlueprintCallable) float GetCurrentHealthCount(); + UFUNCTION(BlueprintCallable) + int GetWeaponProjectiles(); + + UFUNCTION(BlueprintCallable) + float GetWeaponCooldown(); + + UFUNCTION(BlueprintCallable) + float GetWeaponSpread(); + protected: virtual void CalculateHits(TArray* hits) override;