Implement enemies getting to a finish, enemy dying

This commit is contained in:
2024-08-13 16:46:46 +02:00
parent 3f715b2bbc
commit 5c6c425d9a
18 changed files with 514 additions and 461 deletions

View File

@@ -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()
{