Added entity invulnerability
This commit is contained in:
parent
29d86194ca
commit
b0f666b5ed
|
@ -1,50 +1,7 @@
|
|||
using UnityEngine;
|
||||
using AsteroidGame.Interfaces;
|
||||
|
||||
namespace AsteroidGame.Entities.Enemies
|
||||
namespace AsteroidGame.Entities.Enemies.Scripts
|
||||
{
|
||||
public class EnemyBase : MonoBehaviour, IDamageable
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
public class EnemyBase : EntityBase
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void ModifyHealth(int healthChange)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetHealth(int newHealth)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetMaxHealth(int newHealth)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public int GetHealth()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public int GetMaxHealth()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public float GetHealthFactor()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
"references": [
|
||||
"GUID:bc7863ca0989b494d84426bfd28432fa",
|
||||
"GUID:857695c8a9ee988459c9b50e4e75e660",
|
||||
"GUID:17a5862fcd6383b4b97bad4dcb1e2e5d"
|
||||
"GUID:17a5862fcd6383b4b97bad4dcb1e2e5d",
|
||||
"GUID:f26d68a0bdefa1043b120b820f55e190"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
|
|
@ -5,14 +5,20 @@ 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)
|
||||
{
|
||||
if (!isInvulnerable)
|
||||
{
|
||||
health += healthChange;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void SetHealth(int newHealth)
|
||||
{
|
||||
|
@ -24,6 +30,11 @@ namespace AsteroidGame.Entities
|
|||
maxHealth = newHealth;
|
||||
}
|
||||
|
||||
public void SetInvulnerable(bool newState)
|
||||
{
|
||||
isInvulnerable = newState;
|
||||
}
|
||||
|
||||
public int GetHealth()
|
||||
{
|
||||
return health;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue