void OnTriggerEnter2D (Collider2D coll) { foreach (string tag in targetedTags) { if (coll.gameObject.tag == tag) { IDamageable d = coll.GetComponent<IDamageable> (); if (d != null && d.IsDamageable) { Damage (d); if (destructible != null) destructible.Destroy (null); } break; } } }
private void OnTriggerEnter2D(Collider2D collision) { if (!isCollected) { if (collision.CompareTag("Player")) { playerCollectables.IncreaseKeysAmount(1); OnCollection.Raise(); if (destructible != null) { destructible.Destroy(transform); } isCollected = true; } } }
private void OnTriggerEnter2D(Collider2D collision) { if (!isCollected) { if (collision.CompareTag("Player")) { if (playerStats.currentHP < playerStats.maxHP) { playerStats.currentHP++; OnCollection.Raise(); if (destructible != null) { destructible.Destroy(transform); } isCollected = true; } } } }
static void invocation(IDestructible destructible) => destructible.Destroy();
void DestroyProjectile() { destructible.Destroy(null); }