diff --git a/Assets/Entities/EntityBase.cs b/Assets/Entities/EntityBase.cs index 86bbda6..2e2491c 100644 --- a/Assets/Entities/EntityBase.cs +++ b/Assets/Entities/EntityBase.cs @@ -5,15 +5,21 @@ namespace AsteroidGame.Entities { public class EntityBase : MonoBehaviour, IDamageable { - [SerializeField] protected int health; [SerializeField] protected int maxHealth; + [SerializeField] protected bool isInvulnerable; + public bool IsInvulnerable { get; } + public void ModifyHealth(int healthChange) { - health += healthChange; + if (!isInvulnerable) + { + health += healthChange; + } } + public void SetHealth(int newHealth) { health = newHealth; @@ -24,6 +30,11 @@ namespace AsteroidGame.Entities maxHealth = newHealth; } + public void SetInvulnerable(bool newState) + { + isInvulnerable = newState; + } + public int GetHealth() { return health; diff --git a/Assets/Interfaces/IDamageable.cs b/Assets/Interfaces/IDamageable.cs index 162560e..28e12f5 100644 --- a/Assets/Interfaces/IDamageable.cs +++ b/Assets/Interfaces/IDamageable.cs @@ -4,14 +4,28 @@ namespace AsteroidGame.Interfaces { public void ModifyHealth(int healthChange); + #region PublicProperties + + public bool IsInvulnerable { get; } + + #endregion + + #region Setters public void SetHealth(int newHealth); public void SetMaxHealth(int newHealth); + + public void SetInvulnerable (bool newState); + + #endregion + #region Getters public int GetHealth(); public int GetMaxHealth(); public float GetHealthFactor(); + + #endregion } }