Ejemplo n.º 1
0
        private void ApplyImpactForce(DamageInfo info, DamageablePart damageable)
        {
            //if this AI if no dead it is being controlled by the Animator so dont apply any impact force
            if (!IsDead)
            {
                return;
            }

            if (com != null && info.damageType == DamageType.Explosion)
            {
                com.AddExplosionForce(info.hitForce, info.hitPoint, info.explosionRadius, info.upwardsModifier, info.forceMode);
            }
            else if (damageable.RB != null && info.damageType == DamageType.Shoot)
            {
                damageable.RB.AddForceAtPosition(info.hitForce * info.hitDir, info.hitPoint, info.forceMode);
            }
        }
        public void DoDamage(DamageInfo info, DamageablePart damageable)
        {
            //if we are dead just apply the impact force
            if (isDead)
            {
                //ApplyImpactForce( info, damageable );

                if (onDamage != null)
                {
                    onDamage.Invoke(info, damageable);
                }
                return;
            }


            //hp -= info.dmg;

            ModifyHP(-info.dmg);


            if (hp <= 0.0f)
            {
                if (onDie != null)
                {
                    onDie.Invoke();
                }

                isDead = true;

                //ApplyImpactForce( info, damageable );
            }

            if (onDamage != null)
            {
                onDamage.Invoke(info, damageable);
            }
        }