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 void AttachAbilityToPart(LimbType type, Limb newLimb) { Blob part = GetBodyPart(type); LimbPunch action = null; if (newLimb.type == Limb.LimbComponentType.Head) { if (newLimb.head == Limb.HeadSubType.Bite) { action = new BiteHead(this, type); } else if (newLimb.head == Limb.HeadSubType.Bomb) { action = new BombHead(this, type); } else if (newLimb.head == Limb.HeadSubType.Laser) { action = new LaserHead(this, type); } else if (newLimb.head == Limb.HeadSubType.Human) { action = new HumanHead(this, type); } } else if (newLimb.type == Limb.LimbComponentType.Arm) { if (newLimb.arm == Limb.ArmSubType.Hammer) { action = new HammerArm(this, type); } else if (newLimb.arm == Limb.ArmSubType.Hook) { action = new HookArm(this, type); } else if (newLimb.arm == Limb.ArmSubType.Long) { action = new LongArm(this, type); } else if (newLimb.arm == Limb.ArmSubType.Human) { action = new HumanArm(this, type); } } else if (newLimb.type == Limb.LimbComponentType.Leg) { if (newLimb.leg == Limb.LegSubType.Gun) { action = new GunLeg(this, type); } else if (newLimb.leg == Limb.LegSubType.Rocket) { action = new RocketLeg(this, type); } else if (newLimb.leg == Limb.LegSubType.Human) { action = new HumanArm(this, type); } } part.AddComponent(action); }