void OnTriggerEnter2D(Collider2D target) { switch (target.gameObject.tag) { case "Projectile": //DamageStatus targetDamage = target.transform.root.gameObject.GetComponent<DamageStatus>(); DamageStatus targetDamage = target.transform.parent.gameObject.GetComponent <DamageStatus>(); if (targetDamage && _hpStatus) { _hpStatus.AddHp(-targetDamage.GetDamage()); } //Enemy를 삭제합니다 if (_hpStatus.GetHp() == 0) { Destroy(transform.gameObject); } break; case "Planet": _hpStatus.AddHp(-float.MaxValue); if (_hpStatus.GetHp() == 0) { Destroy(transform.gameObject); } break; } }
private void OnTriggerStay2D(Collider2D target) { switch (target.gameObject.tag) { case "Projectile": DamageStatus targetDamage = target.transform.parent.gameObject.GetComponent <DamageStatus>(); if (targetDamage && _hpStatus) { _hpStatus.AddHp(-targetDamage.GetDamage()); } //Enemy를 삭제합니다 if (_hpStatus.GetHp() == 0) { Destroy(transform.gameObject); } break; } }