void ApplyDamageTo(GameObject otherGameObject) { var otherUnit = otherGameObject.GetComponent <GameUnit>(); if (otherUnit != null) { if (CanDamageUnit(otherUnit)) { bool wasDead = otherUnit.IsDead(); otherUnit.ApplyDamage(damage); bool isDead = otherUnit.IsDead(); if (wasDead == false && isDead == true && ownerUnit != null) { ownerUnit.DidKill(otherUnit); } } } }