private void Destroyed(bool withPoints) { //signal that it is destroyed OnDestroyedEnemy?.Invoke(_pointValue, this.gameObject, withPoints); //play animation/effect Destroy(this.gameObject); }
IEnumerator DestroyWithExplosion() { _isDead = true; _rigidBody.velocity = Vector2.zero; _explosion.Play(); OnDestroyedEnemy?.Invoke(_pointValue, this.gameObject, true); yield return(new WaitForSeconds(2.5f)); Destroy(this.gameObject); }