public void TakeDamage(int amount) { if (currHealth > 0) { currHealth -= amount; if (currHealth <= 0) { onDeath.Invoke(); if (destroyAction != null) { if (healthDraw != null) { healthDraw.ChangeHealthState(0); } destroyAction.StartDestroy(); } else { Destroy(gameObject); } } else if (healthDraw != null) { healthDraw.ChangeHealthState((float)currHealth / maxHealth); } } }
public void DestroyArrow() { if (!isDestroyed) { isDestroyed = true; if (destroyAction != null) { Stop(); destroyAction.StartDestroy(); } else { Destroy(gameObject); } } }
private void OnTriggerEnter2D(Collider2D coll) { if (damageLayers == (damageLayers | (1 << coll.gameObject.layer))) { HealthScript health = coll.GetComponent <HealthScript>(); if (health != null) { health.TakeDamage(damageAmount); } if (destroyOnColl) { if (destroyAction != null) { destroyAction.StartDestroy(); } else { Destroy(gameObject); } } } }