public void Hit(Damage damage, Collider relativeCollider) { health -= damage.damageValue; if (damage.explosive) { Blob head = GetBodyPart(LimbType.Head); if (head != null) { if (head.GetComponent <Limb>().head == Limb.HeadSubType.Bomb) { BombHead bombHead = (BombHead)head.AddComponent(new BombHead(null, LimbType.Head)); bombHead.MaxCharge(); bombHead.Explode(collider.Center()); RemoveBodyPart(LimbType.Head); } } } if (health <= 0) { //die Die(); } else { LimbFly(health, damage.damageValue); //knockback if (relativeCollider == null) { relativeCollider = damage.blob.collider; } Vector2 direction = collider.Center() - relativeCollider.Center(); direction.Normalize(); blob.transform.Translate(direction * damage.knockbackPower); SoundManager.PlaySound(SoundManager.SFX_HIT_2); } }
public Vector2 GetColliderCenter() { return(collider.Center()); }