Example #1
0
        private void handleDirectDamage(Damage damage)
        {
            Health health = (Health)_HealthMapper.get(damage.Target);

            if (health != null)
            {
                //damage target
                health.CurrentHealth -= damage.DamageAmount;

                if (damage.DamageAmount > 0)
                {
                    if (((Interactable)_InteractMapper.get(damage.Target)).SupportedInteractions.MAY_ADVANCE)
                    {
                        int endurance = ((Statistics)_AttributeMapper.get(damage.Target)).Endurance.Value;

                        if (health.MaxHealth < (endurance * 5))
                        {
                            if (_Rand.NextDouble() <= ((double)(endurance * 5) - (double)health.MaxHealth) / (double)(endurance * 5))
                            {
                                UtilFactory.createHealthAward(damage.Target, 1);
                            }
                        }
                    }


                    //FIX
                    switch (_Rand.Next(0, 7))
                    {
                    case 1:
                        UtilFactory.createSound("audio\\effects\\hurt", true, 1f);
                        break;

                    case 3:
                        UtilFactory.createSound("audio\\effects\\hurt2", true, 1f);
                        break;

                    case 5:
                        UtilFactory.createSound("audio\\effects\\hurt3", true, 1f);
                        break;

                    case 7:
                        UtilFactory.createSound("audio\\effects\\hurt4", true, 1f);
                        break;

                    default:
                        break;
                    }
                }
            }

            damage.IsActive = false;
        }