Example #1
0
    public override int getSkillVarValueT(int varID, int adderID)
    {
        if (_unit == null)
        {
            UnitFightDataLogic self = null;

            if (adderID == -1)
            {
                self = this;
            }

            return(BaseGameUtils.calculateSkillVarValueFull(varID, self, this));
        }

        return(base.getSkillVarValueT(varID, adderID));
    }
Example #2
0
    /** 执行攻击数据 */
    private void toExecuteAttack(AttackData data)
    {
        Unit from = _scene.getFightUnit(data.fromInstanceID);

        if (from == null)
        {
            return;
        }

        Unit attacker = from.fight.getAttackerUnit();

        if (attacker == null)
        {
            return;
        }

        int attackerInstanceID = attacker.instanceID;

        SkillTargetData   tData       = data.targetData;
        AttackConfig      config      = data.config;
        AttackLevelConfig levelConfig = data.levelConfig;

        //主目标
        Unit mTarget = _scene.getFightUnit(tData.targetInstanceID);

        SList <Unit> tempTargets = new SList <Unit>();

        //构造目标组
        toMakeTargets(tempTargets, from, attacker, mTarget, tData, config, levelConfig);

        Unit target;

        //TODO:攻击前动作组

        //如果跳过伤害阶段
        if (config.passDamage)
        {
            for (int i = 0, len = tempTargets.size(); i < len; ++i)
            {
                target = tempTargets[i];

                //不可被攻击
                if (target.fight.getStatusLogic().cantBeAttackTarget())
                {
                    continue;
                }

                //添加buff
                if (levelConfig.addBuffProbID > 0)
                {
                    if (attacker.fight.randomProb(levelConfig.addBuffProbID))
                    {
                        int adderInstanceID = attackerInstanceID == target.instanceID ? -1 :attackerInstanceID;

                        foreach (DIntData v in levelConfig.addBuffs)
                        {
                            target.fight.getBuffLogic().addBuff(v.key, v.value, adderInstanceID);
                        }
                    }
                }

                //有子弹
                if (levelConfig.bullet.key > 0)
                {
                    from.fight.createAndExecuteBullet(levelConfig.bullet.key, levelConfig.bullet.value, tData);
                }
            }
        }
        else
        {
            doAttackMoment(AttackMomentType.AttackBeforeHit, @from, attacker, null, data, null);

            if (!tempTargets.isEmpty())
            {
                SList <Unit> tempKilledUnits = null;

                SList <DamageOneData> damageDataList = new SList <DamageOneData>();

                StatusDataLogic    attackerStatus    = attacker.fight.getStatusLogic();
                AttributeDataLogic attackerAttribute = attacker.fight.getAttributeLogic();
                BuffDataLogic      attackerBuffLogic = attacker.fight.getBuffLogic();
                StatusDataLogic    targetStatus;
                AttributeDataLogic targetAttribute;

                bool momentHitted = false;

                for (int i = 0, len = tempTargets.size(); i < len; ++i)
                {
                    target = tempTargets[i];

                    targetStatus    = target.fight.getStatusLogic();
                    targetAttribute = target.fight.getAttributeLogic();

                    //不可被攻击
                    if (targetStatus.cantBeAttackTarget())
                    {
                        continue;
                    }

                    //上次血量
                    int lastHp = targetAttribute.getHp();

                    DamageOneData damageOneData = new DamageOneData();
                    damageOneData.instanceID = target.instanceID;

                    damageDataList.add(damageOneData);

                    SList <DIntData> damageList = new SList <DIntData>();
                    damageOneData.damages = damageList;

                    damageOneData.isHit = toCountIsHit(data, attacker, target);

                    doAttackMoment(AttackMomentType.BeAttackBeforeHit, target, target, attacker, data, damageOneData);

                    int realDamage = 0;

                    if (damageOneData.isHit)
                    {
                        if (!momentHitted)
                        {
                            momentHitted = true;
                            doAttackMoment(AttackMomentType.AttackOnHitAnyTarget, @from, attacker, target, data, damageOneData);
                        }

                        if (target == mTarget)
                        {
                            doAttackMoment(AttackMomentType.AttackBeforeDamageMainTarget, @from, attacker, target, data, damageOneData);
                        }

                        doAttackMoment(AttackMomentType.AttackBeforeDamageEachTarget, @from, attacker, target, data, damageOneData);
                        doAttackMoment(AttackMomentType.BeAttackBeforeDamage, target, target, attacker, data, damageOneData);

                        //添加buff
                        if (levelConfig.addBuffProbID > 0)
                        {
                            if (attacker.fight.randomProb(levelConfig.addBuffProbID))
                            {
                                int adderInstanceID = attackerInstanceID == target.instanceID ? -1 :attackerInstanceID;

                                foreach (DIntData v in levelConfig.addBuffs)
                                {
                                    target.fight.getBuffLogic().addBuff(v.key, v.value, adderInstanceID);
                                }
                            }
                        }

                        //有子弹
                        DIntData levelConfigBullet;

                        if ((levelConfigBullet = levelConfig.bullet).key > 0)
                        {
                            from.fight.createAndExecuteBullet(levelConfigBullet.key, levelConfigBullet.value, tData);
                        }

                        bool isCrit = damageOneData.isCrit = toCountIsCrit(data, attacker, target);

                        SkillVarConfig varConfig;
                        int[]          damages;
                        int            damageType;
                        int            damageValue;
                        int            attackValue;
                        int            damageVarIndex = 0;

                        //伤害组
                        for (int j = 0, jLen = levelConfig.damages.Length; j < jLen; ++j)
                        {
                            varConfig  = levelConfig.varConfigT[j];
                            damages    = levelConfig.damages[j];
                            damageType = damages[0];

                            if (data.isRecorded)
                            {
                                attackValue     = BaseGameUtils.calculateSkillVarValueForSelf(varConfig, data.selfAttackValues, damageVarIndex, target.fight.getDataLogic());
                                damageVarIndex += varConfig.args.Length;
                            }
                            else
                            {
                                attackValue = BaseGameUtils.calculateSkillVarValueFull(varConfig, attacker.fight.getDataLogic(), target.fight.getDataLogic());
                            }

                            damageValue = toCalculateDamage(data, damageType, damages, attackValue, isCrit, attackerAttribute, targetAttribute, attacker, target);

                            if (damageValue > 0)
                            {
                                if (needDamageHurt(damageType))
                                {
                                    int rd = 0;

                                    if (!targetStatus.isDamageImmun())
                                    {
                                        rd = takeDamage(damageType, damageValue, targetAttribute, target);
                                    }

                                    if (Global.damageValueUseRealDamage)
                                    {
                                        damageValue = rd;
                                    }

                                    realDamage += rd;
                                }

                                //TODO:反伤类

                                damageList.add(DIntData.create(damageType, damageValue));
                            }
                        }

                        if (realDamage > 0)
                        {
                            _scene.method.onUnitTakeDamage(target, realDamage, attacker);
                        }

                        if (target == mTarget)
                        {
                            doAttackMoment(AttackMomentType.AttackAfterDamageMainTarget, @from, attacker, target, data, damageOneData);
                        }

                        doAttackMoment(AttackMomentType.AttackAfterDamageEachTarget, @from, attacker, target, data, damageOneData);
                        doAttackMoment(AttackMomentType.BeAttackAfterDamage, target, target, attacker, data, damageOneData);

                        //扣除buff次数
                        attackerBuffLogic.subBuffNumArr(BuffSubNumType.UseAttackFromGroup, config.groups);
                        attackerBuffLogic.subBuffNumArr(BuffSubNumType.MakeDamage, levelConfig.damageTypesT);
                        target.fight.getBuffLogic().subBuffNumArr(BuffSubNumType.BeDamage, levelConfig.damageTypesT);

                        //血减到0
                        if (lastHp > 0 && targetAttribute.getAttribute(AttributeType.Hp) <= 0 && targetStatus.isAlive())
                        {
                            if (tempKilledUnits == null)
                            {
                                tempKilledUnits = new SList <Unit>();
                            }

                            tempKilledUnits.add(target);
                        }
                    }

                    //受伤(客户端受伤即使realDamage为0也需要)
                    target.fight.onDamage(from, attacker, config, damageOneData);
                }

                onAttackDamage(from, config, tData);

                //处理击杀
                if (tempKilledUnits != null)
                {
                    for (int i = 0, len = tempKilledUnits.size(); i < len; ++i)
                    {
                        //活着
                        if ((target = tempKilledUnits[i]).fight.isAlive())
                        {
                            //被击杀时刻
                            doAttackMoment(AttackMomentType.BeforeBeKill, target, target, attacker, data, null);

                            //可被伤害击杀
                            if (!target.fight.getStatusLogic().cantBeKillByDamage())
                            {
                                target.fight.doDead(attacker, config.killType);
                            }

                            //击杀时刻
                            doAttackMoment(AttackMomentType.AfterKill, from, attacker, target, data, null);
                        }
                    }
                }
            }

            doAttackMoment(AttackMomentType.AttackAfterHit, from, attacker, null, data, null);
        }
    }
Example #3
0
    //公式部分

    /** 计算完整技能值 */
    public int calculateSkillVar(int varID, Unit attacker, Unit target)
    {
        return(BaseGameUtils.calculateSkillVarValueFull(varID, attacker.fight.getDataLogic(), target.fight.getDataLogic()));
    }
Example #4
0
 /** 获取某变量值表示的值(总值)(自身) */
 public int getSkillVarValue(int varID)
 {
     return(BaseGameUtils.calculateSkillVarValueFull(varID, this, null));
 }