Added entity invulnerability
This commit is contained in:
parent
29d86194ca
commit
146cc9d965
|
@ -5,14 +5,20 @@ namespace AsteroidGame.Entities
|
||||||
{
|
{
|
||||||
public class EntityBase : MonoBehaviour, IDamageable
|
public class EntityBase : MonoBehaviour, IDamageable
|
||||||
{
|
{
|
||||||
|
|
||||||
[SerializeField] protected int health;
|
[SerializeField] protected int health;
|
||||||
[SerializeField] protected int maxHealth;
|
[SerializeField] protected int maxHealth;
|
||||||
|
[SerializeField] protected bool isInvulnerable;
|
||||||
|
|
||||||
|
public bool IsInvulnerable { get; }
|
||||||
|
|
||||||
public void ModifyHealth(int healthChange)
|
public void ModifyHealth(int healthChange)
|
||||||
|
{
|
||||||
|
if (!isInvulnerable)
|
||||||
{
|
{
|
||||||
health += healthChange;
|
health += healthChange;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SetHealth(int newHealth)
|
public void SetHealth(int newHealth)
|
||||||
{
|
{
|
||||||
|
@ -24,6 +30,11 @@ namespace AsteroidGame.Entities
|
||||||
maxHealth = newHealth;
|
maxHealth = newHealth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetInvulnerable(bool newState)
|
||||||
|
{
|
||||||
|
isInvulnerable = newState;
|
||||||
|
}
|
||||||
|
|
||||||
public int GetHealth()
|
public int GetHealth()
|
||||||
{
|
{
|
||||||
return health;
|
return health;
|
||||||
|
|
|
@ -4,14 +4,28 @@ namespace AsteroidGame.Interfaces
|
||||||
{
|
{
|
||||||
public void ModifyHealth(int healthChange);
|
public void ModifyHealth(int healthChange);
|
||||||
|
|
||||||
|
#region PublicProperties
|
||||||
|
|
||||||
|
public bool IsInvulnerable { get; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Setters
|
||||||
public void SetHealth(int newHealth);
|
public void SetHealth(int newHealth);
|
||||||
|
|
||||||
public void SetMaxHealth(int newHealth);
|
public void SetMaxHealth(int newHealth);
|
||||||
|
|
||||||
|
public void SetInvulnerable (bool newState);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Getters
|
||||||
public int GetHealth();
|
public int GetHealth();
|
||||||
|
|
||||||
public int GetMaxHealth();
|
public int GetMaxHealth();
|
||||||
|
|
||||||
public float GetHealthFactor();
|
public float GetHealthFactor();
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue