From 3b07854bd174456c091331dbd1c2d745e1313827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20P=C4=9Bnkava?= Date: Thu, 4 Sep 2025 01:54:39 +0200 Subject: [PATCH] Fix: Health Manager Fixed an issue with health manager not responding properly to zero potions --- 3D blobici/Assets/Scripts/HP/Health Manager.cs | 12 ------------ .../Assets/Scripts/Player/PlayerSkillHandler.cs | 3 +++ .../Assets/Scripts/PotionsSkills/PotionHandler.cs | 5 +++++ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/3D blobici/Assets/Scripts/HP/Health Manager.cs b/3D blobici/Assets/Scripts/HP/Health Manager.cs index b1641dc..c6c14a1 100644 --- a/3D blobici/Assets/Scripts/HP/Health Manager.cs +++ b/3D blobici/Assets/Scripts/HP/Health Manager.cs @@ -21,18 +21,6 @@ public class HealthManager : MonoBehaviour if (_healthText != null) _healthText.text = _currentHealth.ToString() + "/" + _maxHealth.ToString(); - - // These are only for debugging!!!! - if(Input.GetKeyDown(KeyCode.K)) - if(transform.tag == "Player") - ModifyHealth(-10); - - if(Input.GetKeyDown(KeyCode.L)) - ModifyHealth(10); - - if (Input.GetKeyDown(KeyCode.M)) - if(transform.tag == "Enemy") - ModifyHealth(-50); } public void ModifyHealth(float amount) diff --git a/3D blobici/Assets/Scripts/Player/PlayerSkillHandler.cs b/3D blobici/Assets/Scripts/Player/PlayerSkillHandler.cs index d5f0243..17f02da 100644 --- a/3D blobici/Assets/Scripts/Player/PlayerSkillHandler.cs +++ b/3D blobici/Assets/Scripts/Player/PlayerSkillHandler.cs @@ -14,6 +14,7 @@ public class PlayerSkillHandler: MonoBehaviour private Dictionary cooldowns; private Dictionary cooldownsActivated; private PlayerSkillTree playerSkillTree; + private HealthManager healthManager; private CharacterController controller; @@ -25,6 +26,7 @@ public class PlayerSkillHandler: MonoBehaviour cooldownsActivated = new Dictionary(); controller = GetComponent(); playerSkillTree = PlayerSkillTree.Instance; + healthManager = GetComponent(); AssignCooldowns(); } @@ -45,6 +47,7 @@ public class PlayerSkillHandler: MonoBehaviour if (playerSkillTree.TryUsePotion(PotionHandler.PotionType.HealthBig)) { Debug.Log("Potion used!"); + healthManager.ModifyHealth(10); } else { diff --git a/3D blobici/Assets/Scripts/PotionsSkills/PotionHandler.cs b/3D blobici/Assets/Scripts/PotionsSkills/PotionHandler.cs index c5cdcaa..f951ced 100644 --- a/3D blobici/Assets/Scripts/PotionsSkills/PotionHandler.cs +++ b/3D blobici/Assets/Scripts/PotionsSkills/PotionHandler.cs @@ -45,7 +45,12 @@ public class PotionHandler:MonoBehaviour public bool UsePotion(PotionType type, int amount = 1) { + if(potions[type] == 0) + return false; + + potions[type] -= amount; + Debug.Log($"Amount of potions of type {type} is: {potions[type]}"); if (type == potionType) {