Пример #1
0
    protected int takeRealDamage(int damageValue, AttributeDataLogic targetAttribute)
    {
        if (damageValue <= 0)
        {
            return(0);
        }

        int hp = targetAttribute.getAttribute(AttributeType.Hp);

        int re = damageValue > hp ? hp : damageValue;

        targetAttribute.subOneAttribute(AttributeType.Hp, damageValue);

        return(re);
    }
Пример #2
0
    /** 生效伤害 */
    public virtual int takeDamage(int damageType, int damageValue, AttributeDataLogic targetAttribute, Unit target)
    {
        switch (damageType)
        {
        case SkillDamageType.PhysicsDamage:
        case SkillDamageType.MagicDamage:
        {
            int shieldType = damageType == SkillDamageType.PhysicsDamage ? AttributeType.PhysicsShield : AttributeType.MagicShield;

            int shield = targetAttribute.getAttribute(shieldType);

            if (shield > 0)
            {
                if (shield >= damageValue)
                {
                    targetAttribute.subOneAttribute(shieldType, damageValue);
                    target.fight.getBuffLogic().onShieldDamage(shieldType, damageValue);
                    damageValue = 0;
                }
                else
                {
                    targetAttribute.subOneAttribute(shieldType, shield);
                    target.fight.getBuffLogic().onShieldDamage(shieldType, shield);

                    damageValue -= shield;
                }
            }

            if (damageValue <= 0)
            {
                return(0);
            }

            return(takeRealDamage(damageValue, targetAttribute));
        }

        case SkillDamageType.HolyDamage:
        {
            return(takeRealDamage(damageValue, targetAttribute));
        }
        }

        return(0);
    }
Пример #3
0
    /** 计算伤害 */
    public int calculateDamage(int[] damages, int attackValue, bool isCrit, AttributeDataLogic attackerAttribute, AttributeDataLogic targetAttribute, Unit attacker, Unit target, AttackData data)
    {
        int   damageType;
        float damage = 0f;

        switch ((damageType = damages[0]))
        {
        case SkillDamageType.PhysicsDamage:
        case SkillDamageType.MagicDamage:
        {
            int defence;
            int addPercent;
            int deratePercent;

            if (damageType == SkillDamageType.PhysicsDamage)
            {
                defence       = targetAttribute.getAttribute(AttributeType.PhysicsDefence);
                addPercent    = attackerAttribute.getAttribute(AttributeType.PhysicsDamageAddPercent);
                deratePercent = targetAttribute.getAttribute(AttributeType.PhysicsDamageDeratePercent);
            }
            else
            {
                defence       = targetAttribute.getAttribute(AttributeType.MagicDefence);
                addPercent    = attackerAttribute.getAttribute(AttributeType.MagicDamageAddPercent);
                deratePercent = targetAttribute.getAttribute(AttributeType.MagicDamageDeratePercent);
            }

            damage = toCalculateBaseDamage(damages, attackValue, defence);

            if (isCrit)
            {
                damage = damageCrit(damage, attackerAttribute.getAttribute(AttributeType.CritDamagePercentAdd));
            }

            damage = damageRandom(damage, attackerAttribute.getAttribute(AttributeType.DamageRandomRatio));

            //伤害增加
            if (addPercent != 0)
            {
                float percent = (1 + addPercent / 1000f);

                if (percent > 0f)
                {
                    damage *= percent;
                }
                else
                {
                    damage = 0f;
                }
            }

            //伤害减少
            if (deratePercent != 0)
            {
                float percent = (1 - deratePercent / 1000f);

                if (percent > 0f)
                {
                    damage *= percent;
                }
                else
                {
                    damage = 0f;
                }
            }
        }
        break;

        case SkillDamageType.HolyDamage:
        {
            damage = toCalculateBaseDamage(damages, attackValue, 0);

            if (isCrit)
            {
                damage = damageCrit(damage, attackerAttribute.getAttribute(AttributeType.CritDamagePercentAdd));
            }

            damage = damageRandom(damage, attackerAttribute.getAttribute(AttributeType.DamageRandomRatio));
        }
        break;
        }

        int allDeratePercent = targetAttribute.getAttribute(AttributeType.AllDemageDeratePercent);

        if (allDeratePercent != 0)
        {
            float percent = (1 - allDeratePercent / 1000f);

            if (percent > 0f)
            {
                damage *= percent;
            }
            else
            {
                damage = 0f;
            }
        }

        return((int)damage);
    }
Пример #4
0
    /** 获取变量源值 */
    public virtual int getSkillVarSourceValue(int[] args, bool isSelf)
    {
        if (isSelf)
        {
            switch (args[0])
            {
            case SkillVarSourceType.SelfAttribute:
            {
                return(attribute.getAttribute(args[1]));
            }

            case SkillVarSourceType.SelfCurrentAttributePercent:
            {
                return(attribute.getCurrentPercent(args[1]));
            }

            case SkillVarSourceType.SelfCurrentAttributeLostPercent:
            {
                return(1000 - attribute.getCurrentPercent(args[1]));
            }

            case SkillVarSourceType.SelfBuffFloor:
            {
                return(buff.getBuffFloor(args[1]));
            }
            }
        }
        else
        {
            switch (args[0])
            {
            case SkillVarSourceType.TargetAttribute:
            {
                return(attribute.getAttribute(args[1]));
            }

            case SkillVarSourceType.TargetCurrentAttributePercent:
            {
                return(attribute.getCurrentPercent(args[1]));
            }

            case SkillVarSourceType.TargetCurrentAttributeLostPercent:
            {
                return(1000 - attribute.getCurrentPercent(args[1]));
            }

            case SkillVarSourceType.TargetBuffFloor:
            {
                return(buff.getBuffFloor(args[1]));
            }
            }
        }

        Unit unit;

        if ((unit = _unit) != null)
        {
            return(unit.fight.toGetSkillVarSourceValue(args, isSelf));
        }

        return(0);
    }