Ejemplo n.º 1
0
    /** 刷新单个buff的变量属性 */
    private void refreshOneBuffAttributeVar(BuffData data)
    {
        int[][] actions = data.levelConfig.actions;
        int[]   args;

        for (int index = 0; index < actions.Length; ++index)
        {
            args = actions[index];

            switch (args[0])
            {
            case BuffActionType.AddAttributeVar:
            {
                int oldValue = _attributeVarDic.remove(data.instanceID << CommonSetting.buffActionIndexOff | index);

                int value = _parent.getSkillVarValueT(args[2], data.adderInstanceID);

                if (oldValue != value)
                {
                    _parent.attribute.addOneAttribute(args[1], value - oldValue);

                    _attributeVarDic.put(data.instanceID << CommonSetting.buffActionIndexOff | index, value);
                }
            }
            break;

            case BuffActionType.AddAttributeRefreshVar:
            {
                BuffAddAttributeRefreshVarData oldData = _attributeRefreshVarDic.get(data.instanceID << CommonSetting.buffActionIndexOff | index);

                int value = _parent.getSkillVarValueT(oldData.varID, data.adderInstanceID);

                if (oldData.value != value)
                {
                    _parent.attribute.addOneAttribute(args[1], value - oldData.value);

                    oldData.value = value;
                }
            }
            break;
            }
        }
    }
Ejemplo n.º 2
0
    //buff响应

    /** 执行单个动作 */
    protected virtual void doOneAction(BuffData data, int index, int[] args, bool isAdd, bool isFull)
    {
        bool isDriveAll = _parent.isDriveAll();

        switch (args[0])
        {
        case BuffActionType.AddStatus:
        {
            if (!isDriveAll)
            {
                return;
            }

            if (!isFull)
            {
                return;
            }

            if (isAdd)
            {
                _parent.status.addStatus(args[1]);
            }
            else
            {
                _parent.status.subStatus(args[1]);
            }
        }
        break;

        case BuffActionType.AddAttribute:
        {
            if (!isDriveAll)
            {
                return;
            }

            if (!isFull)
            {
                return;
            }

            _parent.attribute.addOneAttribute(args[1], isAdd ? args[2] : -args[2]);
        }
        break;

        case BuffActionType.AddAttributeVar:
        {
            if (!isDriveAll)
            {
                return;
            }

            if (!isFull)
            {
                return;
            }

            if (isAdd)
            {
                int value = _parent.getSkillVarValueT(args[2], data.adderInstanceID);

                _parent.attribute.addOneAttribute(args[1], value);

                _attributeVarDic.put(data.instanceID << CommonSetting.buffActionIndexOff | index, value);
            }
            else
            {
                int value = _attributeVarDic.remove(data.instanceID << CommonSetting.buffActionIndexOff | index);

                _parent.attribute.subOneAttribute(args[1], value);
            }
        }
        break;

        case BuffActionType.IntervalMakeAttack:
        {
            //不是客户端驱动战斗
//				if(!SceneDriveType.isClientDriveAttackHapen(CommonSetting.sceneDriveType))
//					return;

            //不是客户端驱动战斗
            if (!_parent.isSelfDriveAttackHapen())
            {
                return;
            }

            if (isAdd)
            {
                BuffIntervalActionData mData = GameC.pool.buffIntervalActionDataPool.getOne();
                mData.adderInstanceID = data.adderInstanceID;
                mData.readFromConfig(args);

                mData.type = BuffIntervalActionType.Attack;

                Unit selfUnit = _parent.getUnit();

                UnitFightDataLogic attackerLogic = null;

                if (data.adderInstanceID == -1)
                {
                    attackerLogic = _parent;
                }
                else
                {
                    Unit attacker;

                    if (selfUnit != null && (attacker = selfUnit.getScene().getFightUnit(data.adderInstanceID)) != null)
                    {
                        attackerLogic = attacker.fight.getDataLogic();
                    }
                }

                //存在再添加
                if ((args.Length > 4 && args[4] > 0) && attackerLogic != null)
                {
                    mData.calculateSelfAttackValue(attackerLogic);
                }

                _intervalActions.put(data.instanceID << CommonSetting.buffActionIndexOff | index, mData);
            }
            else
            {
                BuffIntervalActionData mData = _intervalActions.remove(data.instanceID << CommonSetting.buffActionIndexOff | index);

                if (mData == null)
                {
                    Ctrl.throwError("不该找不到BuffIntervalActionData");
                }
                else
                {
                    GameC.pool.buffIntervalActionDataPool.back(mData);
                }
            }
        }
        break;

        case BuffActionType.AddGroupCDTimeMaxPercent:
        {
            if (!isDriveAll)
            {
                return;
            }

            _parent.cd.addGroupTimeMaxPercent(args[1], isAdd ? args[2] : -args[2]);
        }
        break;

        case BuffActionType.AddGroupCDTimeMaxValue:
        {
            if (!isDriveAll)
            {
                return;
            }

            _parent.cd.addGroupTimeMaxValue(args[1], isAdd ? args[2] : -args[2]);
        }
        break;

        case BuffActionType.AddSkillProb:
        {
            addSkillProb(args[1], isAdd ? args[2] : -args[2]);
        }
        break;

        case BuffActionType.ChangeFacade:
        {
            if (!isDriveAll)
            {
                return;
            }

            if (isAdd)
            {
                _parent.avatar.addFacade(args[1]);
            }
            else
            {
                _parent.avatar.removeFacade(args[1]);
            }
        }
        break;

        case BuffActionType.AddAvatarPart:
        {
            if (!isDriveAll)
            {
                return;
            }

            if (isAdd)
            {
                _parent.avatar.addPart(args[1], args[2]);
            }
            else
            {
                _parent.avatar.removePart(args[1], args[2]);
            }
        }
        break;

        case BuffActionType.AttackProbAction:
        {
            if (!isDriveAll)
            {
                return;
            }

            IntObjectMap <int[]> dic = _attackProbActions[args[1]];

            if (dic == null)
            {
                dic = new IntObjectMap <int[]>();
                _attackProbActions[args[1]] = dic;
            }

            if (isAdd)
            {
                dic.put(data.instanceID << CommonSetting.buffActionIndexOff | index, args);
            }
            else
            {
                dic.remove(data.instanceID << CommonSetting.buffActionIndexOff | index);
            }
        }
        break;

        case BuffActionType.AddShield:
        case BuffActionType.AddShieldVar:
        {
            if (!isDriveAll)
            {
                return;
            }

            if (!isFull)
            {
                Ctrl.throwError("不支持初始化添加护盾");
                return;
            }

            //盾同一个buff就存在一个,不然会互斥

            if (isAdd)
            {
                int value;

                if (args[0] == BuffActionType.AddShield)
                {
                    value = args[2];
                }
                else
                {
                    value = _parent.getSkillVarValueT(args[2], data.adderInstanceID);
                }

                //盾值
                _parent.attribute.addOneAttribute(args[1], value);

                _shieldBuffDic.computeIfAbsent(args[1], k => new SList <DIntData>()).add(DIntData.create(data.instanceID, value));
            }
            else
            {
                SList <DIntData> list = _shieldBuffDic.get(args[1]);
                DIntData         v;
                for (int i = 0, len = list.length(); i < len; ++i)
                {
                    if ((v = list.get(i)).key == data.instanceID)
                    {
                        //移除剩余盾值
                        if (v.value > 0)
                        {
                            _parent.attribute.subOneAttribute(args[1], v.value);
                        }

                        list.remove(i);
                        --len;
                        --i;
                    }
                }
            }
        }
        break;

        case BuffActionType.SkillReplace:
        {
            if (isAdd)
            {
                if (ShineSetting.openCheck)
                {
                    if (_skillReplaceDic.contains(args[1]))
                    {
                        Ctrl.throwError("目前,相同技能ID同时只支持一个替换技能");
                    }
                }

                _skillReplaceDic.put(args[1], args[2]);
            }
            else
            {
                _skillReplaceDic.remove(args[1]);
            }
        }
        break;

        case BuffActionType.SkillProbReplace:
        {
            SList <int[]> list = _skillProbReplaceDic.computeIfAbsent(args[1], k => new SList <int[]>());

            if (isAdd)
            {
                int[] a;

                for (int i = 0, len = list.length(); i < len; ++i)
                {
                    a = list.get(i);

                    if (compareSkillProbArgs(args, a) <= 0)
                    {
                        list.insert(i, args);
                        return;
                    }
                }

                list.add(args);
            }
            else
            {
                int[] a;

                for (int i = 0, len = list.length(); i < len; ++i)
                {
                    a = list.get(i);

                    if (args[2] == a[2] && args[3] == a[3])
                    {
                        list.remove(i);
                        break;
                    }
                }
            }
        }
        break;

        case BuffActionType.IntervalAddAttribute:
        {
            if (!isDriveAll)
            {
                return;
            }

            if (!isFull)
            {
                return;
            }

            if (isAdd)
            {
                BuffIntervalActionData mData = GameC.pool.buffIntervalActionDataPool.getOne();
                mData.type = BuffIntervalActionType.AddAttribute;
                mData.readFromConfig(args);

                _intervalActions.put(data.instanceID << CommonSetting.buffActionIndexOff | index, mData);
            }
            else
            {
                BuffIntervalActionData mData = _intervalActions.remove(data.instanceID << CommonSetting.buffActionIndexOff | index);

                if (mData == null)
                {
                    Ctrl.throwError("不该找不到BuffIntervalActionData");
                }
                else
                {
                    GameC.pool.buffIntervalActionDataPool.back(mData);
                }
            }
        }
        break;

        case BuffActionType.IntervalAddAttributeVar:
        {
            if (!isDriveAll)
            {
                return;
            }

            if (!isFull)
            {
                return;
            }

            if (isAdd)
            {
                BuffIntervalActionData mData = GameC.pool.buffIntervalActionDataPool.getOne();
                mData.type = BuffIntervalActionType.AddAttributeVar;
                mData.readFromConfig(args);

                _intervalActions.put(data.instanceID << CommonSetting.buffActionIndexOff | index, mData);
            }
            else
            {
                BuffIntervalActionData mData = _intervalActions.remove(data.instanceID << CommonSetting.buffActionIndexOff | index);

                if (mData == null)
                {
                    Ctrl.throwError("不该找不到BuffIntervalActionData");
                }
                else
                {
                    GameC.pool.buffIntervalActionDataPool.back(mData);
                }
            }
        }
        break;

        case BuffActionType.SkillLevelUp:
        {
            _skillLevelUpDic.addValue(args[1], isAdd ? args[2] : -args[2]);
        }
        break;

        case BuffActionType.AddBuffLastTime:
        {
            if (!isDriveAll)
            {
                return;
            }

            _buffLastTimeAddDic.addValue(args[1], isAdd ? args[2] : -args[2]);
        }
        break;

        case BuffActionType.BuffLevelUp:
        {
            if (!isDriveAll)
            {
                return;
            }

            int level = isAdd ? args[2] : -args[2];

            _buffLevelUpDic.addValue(args[1], level);

            //需要立即更新
            if (args.Length > 3 && args[3] > 0)
            {
                if (data.config.hasGroup(args[1]))
                {
                    Ctrl.throwError("不能影响自己所在组的buffLevel");
                    return;
                }

                refreshBuffLevelUp(args[1], level);
            }
        }
        break;

        case BuffActionType.AddAttributeRefreshVar:
        {
            if (!isDriveAll)
            {
                return;
            }

            if (!isFull)
            {
                return;
            }

            SkillVarConfig vConfig = SkillVarConfig.get(args[2]);

            foreach (int[] v in vConfig.args)
            {
                switch (v[0])
                {
                case SkillVarSourceType.SelfAttribute:
                case SkillVarSourceType.TargetAttribute:
                {
                    _addAttributeRefreshVarASet.addValue(v[1], isAdd ? 1 : -1);
                }
                break;

                case SkillVarSourceType.SelfCurrentAttributePercent:
                case SkillVarSourceType.TargetCurrentAttributePercent:
                case SkillVarSourceType.SelfCurrentAttributeLostPercent:
                case SkillVarSourceType.TargetCurrentAttributeLostPercent:
                {
                    //当前+max
                    _addAttributeRefreshVarASet.addValue(v[1], isAdd ? 1 : -1);
                    _addAttributeRefreshVarASet.addValue(AttributeControl.attribute.currentToMaxMap[v[1]], isAdd ? 1 : -1);
                }
                break;
                }
            }

            if (isAdd)
            {
                int value = _parent.getSkillVarValueT(vConfig.id, data.adderInstanceID);

                _parent.attribute.addOneAttribute(args[1], value);

                BuffAddAttributeRefreshVarData bData = new BuffAddAttributeRefreshVarData();
                bData.adderInstanceID = data.adderInstanceID;
                bData.varID           = vConfig.id;
                bData.type            = args[1];
                bData.value           = value;

                _attributeRefreshVarDic.put(data.instanceID << CommonSetting.buffActionIndexOff | index, bData);
            }
            else
            {
                BuffAddAttributeRefreshVarData bData = _attributeRefreshVarDic.remove(data.instanceID << CommonSetting.buffActionIndexOff | index);

                _parent.attribute.subOneAttribute(args[1], bData.value);
            }
        }
        break;

        case BuffActionType.UseSkillProbAction:
        {
            if (!isDriveAll)
            {
                return;
            }

            if (isAdd)
            {
                _useSkillProbActions.put(data.instanceID << CommonSetting.buffActionIndexOff | index, args);
            }
            else
            {
                _useSkillProbActions.remove(data.instanceID << CommonSetting.buffActionIndexOff | index);
            }
        }
        break;

        case BuffActionType.IgnoreBuffGroup:
        {
            if (!isDriveAll)
            {
                return;
            }

            if (!isFull)
            {
                return;
            }

            _ignoreBuffGroupDic.addValue(args[0], isAdd ? 1 : -1);

            if (isAdd)
            {
                removeBuffByGroup(args[0]);
            }
        }
        break;
        }
    }