Пример #1
0
    //hit

    /** 打击每帧 */
    protected void bulletHitFrame()
    {
        if (_config.attackID <= 0)
        {
            return;
        }

        //自己不能控制伤害
        if (!_unit.isSelfDriveAttackHapen())
        {
            return;
        }

        //不该走到这里
        if (BaseC.constlist.bulletCast_isSimpleBullet(_levelConfig.castType))
        {
            return;
        }

        SList <Unit> tempUnitList;

        getFrameHittedUnits(tempUnitList = _tempUnitList);

        if (tempUnitList.isEmpty())
        {
            return;
        }

        //是否可吸收
        bool canAbsorb = !_config.cantAbsorb;

        int eachHitMax      = _levelConfig.eachHitNum;
        int maxInfluenceNum = _levelConfig.maxInfluenceNum;

        IntIntMap hitTargetNums = _hitTargetNums;

        foreach (Unit unit in tempUnitList)
        {
            int instanceID = unit.instanceID;

            //打击次数内
            if (eachHitMax == 0 || hitTargetNums.get(instanceID) < eachHitMax)
            {
                //吸收子弹
                if (canAbsorb && unit.fight.getStatusLogic().getStatus(StatusType.AbsorbBullet))
                {
                    bulletOverInitiative();
                    return;
                }

                if (_hitEnabled)
                {
                    AttackData aData = _unit.fight.createAttackData(_config.attackID, _data.level, SkillTargetData.createByTargetUnit(instanceID));

                    aData.isBulletFirstHit = hitTargetNums.isEmpty();

                    hitTargetNums.addValue(instanceID, 1);

                    _scene.fight.executeAndReleaseAttack(aData);

                    //到达上限了
                    if (maxInfluenceNum > 0 && hitTargetNums.size() >= maxInfluenceNum)
                    {
                        _hitEnabled = false;

                        if (!_config.keepAtMaxHit)
                        {
                            bulletOverInitiative();
                        }

                        return;
                    }
                }
            }
        }

        _tempUnitList.clear();
    }