public void TakeDamage(int damage) { currentHP -= damage; textMesh.text = currentHP.ToString(); if (currentHP <= 0) { OnBlockDestroy?.Invoke(this); GetComponent <Collider2D>().enabled = false; Instantiate(destroyEffect, transform.position, Quaternion.identity); Destroy(gameObject); } }
public void Destroy() { OnBlockDestroy?.Invoke(this); GetComponent <Collider2D>().enabled = false; Destroy(gameObject); }