Exemplo n.º 1
0
    /// <summary>
    /// 造成技能治疗/辅助
    /// 直接治疗量=(攻击方最终攻击*技能加成百分比+技能加成治疗量)*被治疗方受治疗加成系数*random(0.95,1.05)
    /// </summary>
    public static void FightCure(FightUnit attacker, FightUnit target, ActiveSkill skill)
    {
        if (target == null || target.health == 0)
        {
            return;
        }
        int cureNum = Mathf.Max(0, Mathf.RoundToInt((attacker.fightAttribute.attack * skill.normalSkillLvUp.percent + skill.normalSkillLvUp.additional) * (1 + target.fightAttribute.cureRate) * Random.Range(0.95f, 1.05f)));

        if (cureNum > 0)
        {
            HealthUIManager.instance.DisplayHurtNum(target, cureNum.ToString(), false, false);
            target.health += cureNum;
        }
        skill.StartCoroutine(skill.DisplayHitEffect(target));
        SkillAttachBuff(attacker, target, skill.buffConfigList, (HurtType)skill.normalSkill.attackAttribute);
        //附加效果
        AttachExtension(attacker, target, 0, skill.attachExtension, skill.attachExtensionParam);
    }
Exemplo n.º 2
0
    /// <summary>
    /// 主动技能伤害
    ///	技能伤害=(攻击方最终攻击*技能加成百分比+技能基础值)*防御效果*攻击方伤害加成效果系数*防御方对应属性免伤系数*防御方全免伤系数*属性相克系数*暴击伤害系数*random(0.95,1.05)
    ///		技能的属性在技能中配置
    ///		技能加成百分比和技能基础值直接根据技能id和技能等级读表获得
    ///
    ///	技能真实伤害=(攻击方最终攻击*技能加成百分比+技能基础攻击)*攻击方伤害加成效果系数*防御方全免伤系数*暴击伤害系数*random(0.95,1.05)
    /// </summary>
    public static void ActiveSkillDamage(FightUnit attacker, FightUnit target, ActiveSkill skill)
    {
        if (target == null || attacker == null || target.isInvincible)
        {
            return;
        }
        //判断命中
        if (IsMiss(attacker, target))
        {
            HealthUIManager.instance.DisplayHurtNum(target, "Miss", true, false);
            //当闪避攻击时
            if (target.OnDodge != null)
            {
                target.OnDodge();
            }
            return;
        }
        //判断无敌
        if (target.isInvincible)
        {
            HealthUIManager.instance.DisplayHurtNum(target, "Invincible", true, false);
            return;
        }
        //判断暴击
        bool  isCrit    = false;
        float critScale = 1f;

        if (IsCritical(attacker, target))
        {
            isCrit    = true;
            critScale = Const.CONST_BASIC_CRIT_DMG + attacker.fightAttribute.criticalImprove;
            //当被暴击时
            if (target.OnGotCritil != null)
            {
                target.OnGotCritil();
            }
        }
        float defense = (float)1 / (1 + Const.CONST_DEF_FACTOR * target.fightAttribute.Defence);//防御效果

        defense = Mathf.Clamp(defense, Const.CONST_MIN_DEF_EFFECT, Const.CONST_MAX_DEF_EFFECT);
        int      hurtNum  = 1;
        HurtType hurtType = (HurtType)skill.normalSkill.attackAttribute;

        if (hurtType != HurtType.True)
        {
            float elementFactor        = ElementFactorDic[skill.normalSkill.attackAttribute * 10 + (int)target.fightAttribute.elementType].factor;//属性伤害系数
            float elementDefenseFactor = 0;
            switch (hurtType)
            {
            case HurtType.Fire:
                elementDefenseFactor = target.fightAttribute.fireDefenseRate;
                break;

            case HurtType.Water:
                elementDefenseFactor = target.fightAttribute.waterDefenseRate;
                break;

            case HurtType.Earth:
                elementDefenseFactor = target.fightAttribute.eathDefenseRate;
                break;

            case HurtType.Light:
                elementDefenseFactor = target.fightAttribute.lightDefeneseRate;
                break;

            case HurtType.Dark:
                elementDefenseFactor = target.fightAttribute.darkDefenseRate;
                break;
            }
            hurtNum = Mathf.RoundToInt((float)(attacker.fightAttribute.attack * skill.normalSkillLvUp.percent + skill.normalSkillLvUp.additional) * defense
                                       * (1 + attacker.fightAttribute.allDamageRate) * (1 - elementDefenseFactor) * (1 - target.fightAttribute.allDefenseRate) * elementFactor * critScale * Random.Range(0.95f, 1.05f));
        }
        else
        {
            hurtNum = Mathf.RoundToInt((float)(attacker.fightAttribute.attack * skill.normalSkillLvUp.percent + skill.normalSkillLvUp.additional)
                                       * (1 + attacker.fightAttribute.allDamageRate) * (1 - target.fightAttribute.allDefenseRate) * critScale * Random.Range(0.95f, 1.05f));
        }
        hurtNum = Mathf.Max(0, hurtNum);

        //受击特效
        skill.StartCoroutine(skill.DisplayHitEffect(target));
        //触发技能命中事件
        if (attacker.OnSkillHit != null)
        {
            attacker.OnSkillHit(hurtNum);
        }
        //触发反弹事件
        if (target.OnFantan != null)
        {
            target.OnFantan(hurtNum, skill, hurtType);
        }
        //护盾计算
        hurtNum = CaculateHudun(hurtNum, target, hurtType);
        //附加buff
        SkillAttachBuff(attacker, target, skill.buffConfigList, (HurtType)skill.normalSkill.attackAttribute);
        //附加效果
        AttachExtension(attacker, target, hurtNum, skill.attachExtension, skill.attachExtensionParam);
        //伤血
        if (hurtNum == 0)
        {
            return;
        }
        HealthUIManager.instance.DisplayHurtNum(target, hurtNum.ToString(), true, isCrit);
        target.health -= hurtNum;
        if (target.health == 0)
        {
            FightManager.GetInstance().UnitDead(attacker, target);
        }
    }