Example #1
0
 public CarDamageInformation()
 {
     Engine       = new DamageInformation();
     Transmission = new DamageInformation();
     Suspension   = new DamageInformation();
     Bodywork     = new DamageInformation();
 }
    public DamageInformation ApplyDamage(DamageInformation a_damageInformation)
    {
        DamageInformation damageInfo = a_damageInformation;
        if (m_shieldAlive)
        {
            float damageDealt = m_shieldCurrentHitPoints;
            float damageReduction = Mathf.Abs(1 - Mathf.Clamp((m_energyResistance - damageInfo.m_energyPierceModifier) / 100, 0, 1)); //calculate the damage the standard damage will deal
            //damageReduction = Mathf.Clamp(damageReduction, 0, 1);

            m_shieldCurrentHitPoints -= damageInfo.m_physicalDamageMagnitude * damageReduction + damageInfo.m_energyDamageMagnitude; //Apply damagereduced armour damage + bonus damage vs shield
            damageDealt -= m_shieldCurrentHitPoints;

            //if(damageInfo.m_physicalDamageMagnitude > damageDealt) //May remove this. Prevents the base damage then done to the armour underneath from exceeding the damage that was just done to the shield
            //{
            //    damageInfo.m_physicalDamageMagnitude = damageDealt;
            //}
            damageReduction = Mathf.Abs(1 - Mathf.Clamp((m_physicalResistance - damageInfo.m_energyPierceModifier) / 100, 0, 1)); //Calculate the damage that will then be applied to the base ship behind the shield. PAY ATTENTION TO THE MODIFIER, IT SHOULD BE ENERGY

            damageInfo.m_physicalDamageMagnitude *= damageReduction;

            if (m_shieldCurrentHitPoints <= 0)
            {
                m_shieldAlive = false;
            }
        }

        return damageInfo;
    }
    Vector3 m_velocity; //The actual velocity applied to the transform at the end of the frame

    #endregion Fields

    #region Methods

    public void ApplyDamage(DamageInformation a_damageInformation)
    {
        DamageInformation damageInfo = a_damageInformation;

        damageInfo = m_activeShield.ApplyDamage(damageInfo);

        float damageReduction = Mathf.Abs(1 - Mathf.Clamp((m_physicalResistance - damageInfo.m_physicalPierceModifier) / 100, 0, 1));
        m_currentHitPoints -= damageInfo.m_physicalDamageMagnitude * damageReduction;
    }
Example #4
0
        private static void ApplyDamage(DamageInformation damageInformation, StatusIconViewModel viewModel)
        {
            viewModel.AdditionalText = damageInformation.Damage > 0 ? Math.Ceiling(damageInformation.Damage * 100).ToString("F0") : string.Empty;

            if (damageInformation.Damage < damageInformation.MediumDamageThreshold)
            {
                viewModel.IconState = StatusIconState.Unlit;
                return;
            }

            if (damageInformation.Damage < damageInformation.HeavyDamageThreshold)
            {
                viewModel.IconState = StatusIconState.Warning;
                return;
            }

            viewModel.IconState = StatusIconState.Error;
        }
Example #5
0
        private static void ApplyDamage(DamageInformation damageInformation, StatusIconViewModel viewModel)
        {
            viewModel.AdditionalText = damageInformation.Damage < 0.01 ? string.Empty : ((int)(damageInformation.Damage * 100)).ToString(CultureInfo.CurrentCulture);

            if (damageInformation.Damage < damageInformation.MediumDamageThreshold)
            {
                viewModel.IconState = StatusIconState.Unlit;
                return;
            }

            if (damageInformation.Damage < damageInformation.HeavyDamageThreshold)
            {
                viewModel.IconState = StatusIconState.Warning;
                return;
            }

            viewModel.IconState = StatusIconState.Error;
        }