private void OnCollisionEnter2D(Collision2D collider) { if (collider.gameObject.CompareTag("Enemy")) { IHealthDamager health = collider.gameObject.GetComponent <IHealthDamager>(); if (health != null) { health.TakeDamage(damage); StopAllCoroutines(); pocket.AddToPocket(new Costs(2)); } } Destroy(gameObject); }
private void CastExplosin() { Collider2D[] col = Physics2D.OverlapCircleAll(transform.position, range, enemyMask); foreach (Collider2D collider in col) { if (collider.CompareTag("Enemy")) { IHealthDamager hitable = collider.gameObject.GetComponent <IHealthDamager>(); if (hitable != null) { hitable.TakeDamage(new Damage(damage.HP, damage.Sheelds, gameObject)); } } } }
private void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.CompareTag("Player")) { IHealthDamager health = other.gameObject.GetComponent <IHealthDamager>(); if (isReadyToAttak && health != null) { health.TakeDamage(damage); isReadyToAttak = false; PlayerPocket.Pocket.AddToPocket(new Costs(2)); Audio.PlaySound("PlayerTakesDmg"); Destroy(gameObject); } } }