protected virtual void OnOnTookDamage() { if (hurtClip.Length > 0) { GetComponent <AudioSource>().PlayOneShot(hurtClip[UnityEngine.Random.Range(0, hurtClip.Length)]); } OnTookDamage?.Invoke(); }
public virtual void TakeDamage(float damageAmount) { if (IsAlive) { OnTookDamage?.Invoke(); return; } Die(); }
// -------------------------------------------------------------------------------------------- private void TakeDamage(Unit sourceUnit, int amount) { int previousHealth = Health; Health = Mathf.Clamp(Health - amount, 0, Health); OnTookDamage?.Invoke(this, new DamageEventArgs(sourceUnit, this, previousHealth, Health, Health <= 0)); if (Health <= 0) { Destroy(); } }
//public enum Lane //deprecated //{ // Median, // Lateral //} // Start is called before the first frame update void Start() { ReachedTheEnd = false; OnTookDamage = new OnTookDamage(); }