Created
December 29, 2016 06:30
-
-
Save unity3dcollege/b3d745903d6baf4fd10d01eaed33ffd4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEngine; | |
public class NPC : MonoBehaviour | |
{ | |
[SerializeField] private ParticleSystem deathParticlePrefab; | |
public event Action OnNPCDied = delegate { }; | |
internal void TakeDamage(int amount) | |
{ | |
GetComponent<Health>().TakeDamage(amount); | |
if (GetComponent<Health>().CurrentHpPctent <= 0) | |
Die(); | |
} | |
private void Die() | |
{ | |
OnNPCDied(); | |
GameObject.Destroy(this.gameObject); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment