Implement enemies getting to a finish, enemy dying
This commit is contained in:
@@ -7,26 +7,15 @@ using UnityEngine.EventSystems;
|
||||
|
||||
public class HealthComponent : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
[Required]
|
||||
[OnValueChanged("Setup")]
|
||||
private Enemy enemy;
|
||||
|
||||
[ReadOnly]
|
||||
[SerializeField]
|
||||
private int health;
|
||||
|
||||
[ReadOnly]
|
||||
[SerializeField]
|
||||
private bool isDead;
|
||||
|
||||
public UnityEvent onDied;
|
||||
|
||||
[Button]
|
||||
public void Setup()
|
||||
public void Setup(int health)
|
||||
{
|
||||
health = enemy.health;
|
||||
isDead = false;
|
||||
this.health = health;
|
||||
}
|
||||
|
||||
public void TakeDamage(int damage)
|
||||
@@ -40,17 +29,10 @@ public class HealthComponent : MonoBehaviour
|
||||
|
||||
if (health == 0)
|
||||
{
|
||||
isDead = true;
|
||||
onDied.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
[Button]
|
||||
private void Take10Damage()
|
||||
{
|
||||
TakeDamage(10);
|
||||
}
|
||||
|
||||
[Button]
|
||||
private void Kill()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user