Fix: Health Manager
Fixed an issue with health manager not responding properly to zero potions
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -14,6 +14,7 @@ public class PlayerSkillHandler: MonoBehaviour
|
||||
private Dictionary<PlayerSkillTree.Skills, float> cooldowns;
|
||||
private Dictionary<PlayerSkillTree.Skills, float> cooldownsActivated;
|
||||
private PlayerSkillTree playerSkillTree;
|
||||
private HealthManager healthManager;
|
||||
|
||||
private CharacterController controller;
|
||||
|
||||
@@ -25,6 +26,7 @@ public class PlayerSkillHandler: MonoBehaviour
|
||||
cooldownsActivated = new Dictionary<PlayerSkillTree.Skills, float>();
|
||||
controller = GetComponent<CharacterController>();
|
||||
playerSkillTree = PlayerSkillTree.Instance;
|
||||
healthManager = GetComponent<HealthManager>();
|
||||
AssignCooldowns();
|
||||
}
|
||||
|
||||
@@ -45,6 +47,7 @@ public class PlayerSkillHandler: MonoBehaviour
|
||||
if (playerSkillTree.TryUsePotion(PotionHandler.PotionType.HealthBig))
|
||||
{
|
||||
Debug.Log("Potion used!");
|
||||
healthManager.ModifyHealth(10);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user