Implement enemies getting to a finish, enemy dying
This commit is contained in:
36
Assets/Scripts/Components/EnemyComponent.cs
Normal file
36
Assets/Scripts/Components/EnemyComponent.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Sirenix.OdinInspector;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class EnemyComponent : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
[Required]
|
||||
[OnValueChanged("Setup")]
|
||||
private Enemy enemy;
|
||||
|
||||
[ReadOnly]
|
||||
[SerializeField]
|
||||
private bool isDead;
|
||||
|
||||
[SerializeField]
|
||||
private UnityEvent<int> updateInitialHealth;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Setup();
|
||||
}
|
||||
|
||||
private void Setup()
|
||||
{
|
||||
updateInitialHealth.Invoke(enemy.health);
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
Destroy(gameObject, 3);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user