Exemplo n.º 1
0
        /// <summary>
        /// Applies static damage with only normal rule.
        /// </summary>
        public void TakeDamage(Entity attacker, float incomingDamage, float modifier = 1f)
        {
            if (_IsHit)
            {
                return;
            }
            _IsHit   = true;
            _LastHit = DateTime.Now;

            float blockMultipler = BlockDamageReduction(attacker);
            float damageTaken    = NormalDamageFormula(AttributesComponent.Defense, incomingDamage);
            float overallDamage  = damageTaken * blockMultipler * modifier;

            AttributesComponent.CurrentHealth -= overallDamage;

            FloatingTextComponent.Add(overallDamage, Color.White);

            GamepadComponent.Vibrate(this.Parent, 0.5f, 0f, 0.5f);
            PlayHitSound(blockMultipler);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Applies damage, with the normal rules, based on the attacker's attributes.
        /// </summary>
        public void TakeDamage(AttributesComponent attacker, float modifier = 1f)
        {
            if (_IsHit)
            {
                return;
            }
            _IsHit   = true;
            _LastHit = DateTime.Now;

            float blockMultipler      = BlockDamageReduction(attacker.Parent);
            float damageTaken         = NormalDamageFormula(AttributesComponent.Defense, attacker.Attack);
            float criticalMultiplier  = CriticalDamageChance(attacker.CriticalChance, attacker.CriticalDamage);
            float elementalMultiplier = ElementalDamage(AttributesComponent.ResistantElements, AttributesComponent.ElementPower, attacker.AttackingElements, attacker.ElementPower);
            float overallDamage       = damageTaken * criticalMultiplier * blockMultipler * elementalMultiplier * modifier;

            AttributesComponent.CurrentHealth -= overallDamage;

            if (criticalMultiplier != 1) //critical hit.
            {
                FloatingTextComponent.Add(overallDamage, Color.Orange);
            }
            else if (elementalMultiplier > 1) //entity is weak to that element
            {
                FloatingTextComponent.Add(overallDamage, Color.Crimson);
            }
            else if (elementalMultiplier < 1) //entity is resistant to that element
            {
                FloatingTextComponent.Add(overallDamage, Color.Navy);
            }
            else
            {
                FloatingTextComponent.Add(overallDamage, Color.White);
            }
            //vibrate!
            GamepadComponent.Vibrate(this.Parent, 0.5f, 0f, 0.5f);
            PlayHitSound(blockMultipler);
        }